Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/joomla4/ |
| [Home] [System Details] [Kill Me] |
home/lmsyaran/public_html/libraries/regularlabs/src/Uri.php000064400000011717151156665560020171
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Router\Route as JRoute;
use Joomla\CMS\Uri\Uri as JUri;
/**
* Class Uri
* @package RegularLabs\Library
*/
class Uri
{
/**
* Returns the full uri and optionally adds/replaces the hash
*
* @param string $hash
*
* @return string
*/
public static function get($hash = '')
{
$url = JUri::getInstance()->toString();
if ($hash == '')
{
return $url;
}
return self::appendHash($url, $hash);
}
/**
* adds the given url parameter (key + value) to the url or replaces it
already exists
*
* @param string $url
* @param string $key
* @param string $value
* @param bool $replace
*
* @return string
*/
public static function addParameter($url, $key, $value = '',
$replace = true)
{
if (empty($key))
{
return $url;
}
$uri = parse_url($url);
$query = isset($uri['query']) ?
self::parse_query($uri['query']) : [];
if ( ! $replace && isset($query[$key]))
{
return $url;
}
$query[$key] = $value;
$uri['query'] = http_build_query($query);
return self::createUrlFromArray($uri);
}
/**
* removes the given url parameter from the url
*
* @param string $url
* @param string $key
*
* @return string
*/
public static function removeParameter($url, $key)
{
if (empty($key))
{
return $url;
}
$uri = parse_url($url);
if ( ! isset($uri['query']))
{
return $url;
}
$query = self::parse_query($uri['query']);
unset($query[$key]);
$uri['query'] = http_build_query($query);
return self::createUrlFromArray($uri);
}
/**
* Converts an array of url parts (like made by parse_url) to a string
*
* @param array $uri
*
* @return string
*/
public static function createUrlFromArray($uri)
{
$user = ! empty($uri['user']) ? $uri['user'] :
'';
$pass = ! empty($uri['pass']) ? ':' .
$uri['pass'] : '';
return (! empty($uri['scheme']) ? $uri['scheme'] .
'://' : '')
. (($user || $pass) ? $user . $pass . '@' : '')
. (! empty($uri['host']) ? $uri['host'] :
'')
. (! empty($uri['port']) ? ':' .
$uri['port'] : '')
. (! empty($uri['path']) ? $uri['path'] :
'')
. (! empty($uri['query']) ? '?' .
$uri['query'] : '')
. (! empty($uri['fragment']) ? '#' .
$uri['fragment'] : '');
}
/**
* Appends the given hash to the url or replaces it if there is already
one
*
* @param string $url
* @param string $hash
*
* @return string
*/
public static function appendHash($url = '', $hash =
'')
{
if (empty($hash))
{
return $url;
}
$uri = parse_url($url);
$uri['fragment'] = $hash;
return self::createUrlFromArray($uri);
}
public static function isExternal($url)
{
if (strpos($url, '://') === false)
{
return false;
}
// hostname: give preference to SERVER_NAME, because this includes
subdomains
$hostname = ($_SERVER['SERVER_NAME']) ?
$_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST'];
return ! (strpos(RegEx::replace('^.*?://', '', $url),
$hostname) === 0);
}
public static function route($url)
{
return JRoute::_(JUri::root(true) . '/' . $url);
}
public static function encode($string)
{
return urlencode(base64_encode(gzdeflate($string)));
}
public static function decode($string)
{
return gzinflate(base64_decode(urldecode($string)));
}
public static function createCompressedAttributes($string)
{
$parameters = [];
$compressed = base64_encode(gzdeflate($string));
$chunk_length = ceil(strlen($compressed) / 10);
$chunks = str_split($compressed, $chunk_length);
foreach ($chunks as $i => $chunk)
{
$parameters[] = 'rlatt_' . $i . '=' .
urlencode($chunk);
}
return implode('&', $parameters);
}
public static function getCompressedAttributes()
{
$input = JFactory::getApplication()->input;
$compressed = '';
for ($i = 0; $i < 10; $i++)
{
$compressed .= $input->getString('rlatt_' . $i,
'');
}
return gzinflate(base64_decode($compressed));
}
/**
* Parse a query string into an associative array.
*
* @param string $string
*
* @return array
*/
private static function parse_query($string)
{
$result = [];
if ($string === '')
{
return $result;
}
$decoder = function ($value) {
return rawurldecode(str_replace('+', ' ', $value));
};
foreach (explode('&', $string) as $kvp)
{
$parts = explode('=', $kvp, 2);
$key = $decoder($parts[0]);
$value = isset($parts[1]) ? $decoder($parts[1]) : null;
if ( ! isset($result[$key]))
{
$result[$key] = $value;
continue;
}
if ( ! is_array($result[$key]))
{
$result[$key] = [$result[$key]];
}
$result[$key][] = $value;
}
return $result;
}
}
home/lmsyaran/public_html/j3/libraries/src/Uri/Uri.php000064400000022165151160072730016722
0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Uri;
defined('JPATH_PLATFORM') or die;
/**
* JUri Class
*
* This class serves two purposes. First it parses a URI and provides a
common interface
* for the Joomla Platform to access and manipulate a URI. Second it
obtains the URI of
* the current executing script from the server regardless of server.
*
* @since 1.7.0
*/
class Uri extends \Joomla\Uri\Uri
{
/**
* @var Uri[] An array of JUri instances.
* @since 1.7.0
*/
protected static $instances = array();
/**
* @var array The current calculated base url segments.
* @since 1.7.0
*/
protected static $base = array();
/**
* @var array The current calculated root url segments.
* @since 1.7.0
*/
protected static $root = array();
/**
* @var string The current url.
* @since 1.7.0
*/
protected static $current;
/**
* Returns the global JUri object, only creating it if it doesn't
already exist.
*
* @param string $uri The URI to parse. [optional: if null uses
script URI]
*
* @return Uri The URI object.
*
* @since 1.7.0
*/
public static function getInstance($uri = 'SERVER')
{
if (empty(static::$instances[$uri]))
{
// Are we obtaining the URI from the server?
if ($uri == 'SERVER')
{
// Determine if the request was over SSL (HTTPS).
if (isset($_SERVER['HTTPS']) &&
!empty($_SERVER['HTTPS']) &&
(strtolower($_SERVER['HTTPS']) != 'off'))
{
$https = 's://';
}
elseif ((isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
(strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) !==
'http')))
{
$https = 's://';
}
else
{
$https = '://';
}
/*
* Since we are assigning the URI from the server variables, we first
need
* to determine if we are running on apache or IIS. If PHP_SELF and
REQUEST_URI
* are present, we will assume we are running on apache.
*/
if (!empty($_SERVER['PHP_SELF']) &&
!empty($_SERVER['REQUEST_URI']))
{
// To build the entire URI we need to prepend the protocol, and the
http host
// to the URI string.
$theURI = 'http' . $https . $_SERVER['HTTP_HOST']
. $_SERVER['REQUEST_URI'];
}
else
{
/*
* Since we do not have REQUEST_URI to work with, we will assume we
are
* running on IIS and will therefore need to work some magic with the
SCRIPT_NAME and
* QUERY_STRING environment variables.
*
* IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI
variable... thanks, MS
*/
$theURI = 'http' . $https . $_SERVER['HTTP_HOST']
. $_SERVER['SCRIPT_NAME'];
// If the query string exists append it to the URI string
if (isset($_SERVER['QUERY_STRING']) &&
!empty($_SERVER['QUERY_STRING']))
{
$theURI .= '?' . $_SERVER['QUERY_STRING'];
}
}
// Extra cleanup to remove invalid chars in the URL to prevent
injections through the Host header
$theURI = str_replace(array("'", '"',
'<', '>'), array('%27',
'%22', '%3C', '%3E'), $theURI);
}
else
{
// We were given a URI
$theURI = $uri;
}
static::$instances[$uri] = new static($theURI);
}
return static::$instances[$uri];
}
/**
* Returns the base URI for the request.
*
* @param boolean $pathonly If false, prepend the scheme, host and
port information. Default is false.
*
* @return string The base URI string
*
* @since 1.7.0
*/
public static function base($pathonly = false)
{
// Get the base request path.
if (empty(static::$base))
{
$config = \JFactory::getConfig();
$uri = static::getInstance();
$live_site = ($uri->isSsl()) ? str_replace('http://',
'https://', $config->get('live_site')) :
$config->get('live_site');
if (trim($live_site) != '')
{
$uri = static::getInstance($live_site);
static::$base['prefix'] =
$uri->toString(array('scheme', 'host',
'port'));
static::$base['path'] =
rtrim($uri->toString(array('path')), '/\\');
if (defined('JPATH_BASE') &&
defined('JPATH_ADMINISTRATOR'))
{
if (JPATH_BASE == JPATH_ADMINISTRATOR)
{
static::$base['path'] .= '/administrator';
}
}
}
else
{
static::$base['prefix'] =
$uri->toString(array('scheme', 'host',
'port'));
if (strpos(php_sapi_name(), 'cgi') !== false &&
!ini_get('cgi.fix_pathinfo') &&
!empty($_SERVER['REQUEST_URI']))
{
// PHP-CGI on Apache with "cgi.fix_pathinfo = 0"
// We shouldn't have user-supplied PATH_INFO in PHP_SELF in this
case
// because PHP will not work with PATH_INFO at all.
$script_name = $_SERVER['PHP_SELF'];
}
else
{
// Others
$script_name = $_SERVER['SCRIPT_NAME'];
}
// Extra cleanup to remove invalid chars in the URL to prevent
injections through broken server implementation
$script_name = str_replace(array("'",
'"', '<', '>'),
array('%27', '%22', '%3C', '%3E'),
$script_name);
static::$base['path'] = rtrim(dirname($script_name),
'/\\');
}
}
return $pathonly === false ? static::$base['prefix'] .
static::$base['path'] . '/' :
static::$base['path'];
}
/**
* Returns the root URI for the request.
*
* @param boolean $pathonly If false, prepend the scheme, host and
port information. Default is false.
* @param string $path The path
*
* @return string The root URI string.
*
* @since 1.7.0
*/
public static function root($pathonly = false, $path = null)
{
// Get the scheme
if (empty(static::$root))
{
$uri = static::getInstance(static::base());
static::$root['prefix'] =
$uri->toString(array('scheme', 'host',
'port'));
static::$root['path'] =
rtrim($uri->toString(array('path')), '/\\');
}
// Get the scheme
if (isset($path))
{
static::$root['path'] = $path;
}
return $pathonly === false ? static::$root['prefix'] .
static::$root['path'] . '/' :
static::$root['path'];
}
/**
* Returns the URL for the request, minus the query.
*
* @return string
*
* @since 1.7.0
*/
public static function current()
{
// Get the current URL.
if (empty(static::$current))
{
$uri = static::getInstance();
static::$current = $uri->toString(array('scheme',
'host', 'port', 'path'));
}
return static::$current;
}
/**
* Method to reset class static members for testing and other various
issues.
*
* @return void
*
* @since 1.7.0
*/
public static function reset()
{
static::$instances = array();
static::$base = array();
static::$root = array();
static::$current = '';
}
/**
* Set the URI path string. Note we keep this method here so it uses the
old _cleanPath function
*
* @param string $path The URI path string.
*
* @return void
*
* @since 1.7.0
* @deprecated 4.0 Use {@link \Joomla\Uri\Uri::setPath()}
* @note Present to proxy calls to the deprecated {@link
JUri::_cleanPath()} method.
*/
public function setPath($path)
{
$this->path = $this->_cleanPath($path);
}
/**
* Checks if the supplied URL is internal
*
* @param string $url The URL to check.
*
* @return boolean True if Internal.
*
* @since 1.7.0
*/
public static function isInternal($url)
{
$uri = static::getInstance($url);
$base = $uri->toString(array('scheme', 'host',
'port', 'path'));
$host = $uri->toString(array('scheme', 'host',
'port'));
// @see JUriTest
if (empty($host) && strpos($uri->path, 'index.php')
=== 0
|| !empty($host) && preg_match('#' .
preg_quote(static::base(), '#') . '#', $base)
|| !empty($host) && $host ===
static::getInstance(static::base())->host &&
strpos($uri->path, 'index.php') !== false
|| !empty($host) && $base === $host &&
preg_match('#' . preg_quote($base, '#') .
'#', static::base()))
{
return true;
}
return 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.7.0
* @note The parent method is protected, this exposes it as public for
B/C
*/
public static function buildQuery(array $params)
{
return parent::buildQuery($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.7.0
* @note The parent method is protected, this exposes it as public for
B/C
*/
public function parse($uri)
{
return parent::parse($uri);
}
/**
* 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.7.0
* @deprecated 4.0 Use {@link \Joomla\Uri\Uri::cleanPath()} instead
*/
protected function _cleanPath($path)
{
return parent::cleanPath($path);
}
}
home/lmsyaran/public_html/j3/htaccess.back/src/Uri/Uri.php000064400000022165151160146140017437
0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Uri;
defined('JPATH_PLATFORM') or die;
/**
* JUri Class
*
* This class serves two purposes. First it parses a URI and provides a
common interface
* for the Joomla Platform to access and manipulate a URI. Second it
obtains the URI of
* the current executing script from the server regardless of server.
*
* @since 1.7.0
*/
class Uri extends \Joomla\Uri\Uri
{
/**
* @var Uri[] An array of JUri instances.
* @since 1.7.0
*/
protected static $instances = array();
/**
* @var array The current calculated base url segments.
* @since 1.7.0
*/
protected static $base = array();
/**
* @var array The current calculated root url segments.
* @since 1.7.0
*/
protected static $root = array();
/**
* @var string The current url.
* @since 1.7.0
*/
protected static $current;
/**
* Returns the global JUri object, only creating it if it doesn't
already exist.
*
* @param string $uri The URI to parse. [optional: if null uses
script URI]
*
* @return Uri The URI object.
*
* @since 1.7.0
*/
public static function getInstance($uri = 'SERVER')
{
if (empty(static::$instances[$uri]))
{
// Are we obtaining the URI from the server?
if ($uri == 'SERVER')
{
// Determine if the request was over SSL (HTTPS).
if (isset($_SERVER['HTTPS']) &&
!empty($_SERVER['HTTPS']) &&
(strtolower($_SERVER['HTTPS']) != 'off'))
{
$https = 's://';
}
elseif ((isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
(strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) !==
'http')))
{
$https = 's://';
}
else
{
$https = '://';
}
/*
* Since we are assigning the URI from the server variables, we first
need
* to determine if we are running on apache or IIS. If PHP_SELF and
REQUEST_URI
* are present, we will assume we are running on apache.
*/
if (!empty($_SERVER['PHP_SELF']) &&
!empty($_SERVER['REQUEST_URI']))
{
// To build the entire URI we need to prepend the protocol, and the
http host
// to the URI string.
$theURI = 'http' . $https . $_SERVER['HTTP_HOST']
. $_SERVER['REQUEST_URI'];
}
else
{
/*
* Since we do not have REQUEST_URI to work with, we will assume we
are
* running on IIS and will therefore need to work some magic with the
SCRIPT_NAME and
* QUERY_STRING environment variables.
*
* IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI
variable... thanks, MS
*/
$theURI = 'http' . $https . $_SERVER['HTTP_HOST']
. $_SERVER['SCRIPT_NAME'];
// If the query string exists append it to the URI string
if (isset($_SERVER['QUERY_STRING']) &&
!empty($_SERVER['QUERY_STRING']))
{
$theURI .= '?' . $_SERVER['QUERY_STRING'];
}
}
// Extra cleanup to remove invalid chars in the URL to prevent
injections through the Host header
$theURI = str_replace(array("'", '"',
'<', '>'), array('%27',
'%22', '%3C', '%3E'), $theURI);
}
else
{
// We were given a URI
$theURI = $uri;
}
static::$instances[$uri] = new static($theURI);
}
return static::$instances[$uri];
}
/**
* Returns the base URI for the request.
*
* @param boolean $pathonly If false, prepend the scheme, host and
port information. Default is false.
*
* @return string The base URI string
*
* @since 1.7.0
*/
public static function base($pathonly = false)
{
// Get the base request path.
if (empty(static::$base))
{
$config = \JFactory::getConfig();
$uri = static::getInstance();
$live_site = ($uri->isSsl()) ? str_replace('http://',
'https://', $config->get('live_site')) :
$config->get('live_site');
if (trim($live_site) != '')
{
$uri = static::getInstance($live_site);
static::$base['prefix'] =
$uri->toString(array('scheme', 'host',
'port'));
static::$base['path'] =
rtrim($uri->toString(array('path')), '/\\');
if (defined('JPATH_BASE') &&
defined('JPATH_ADMINISTRATOR'))
{
if (JPATH_BASE == JPATH_ADMINISTRATOR)
{
static::$base['path'] .= '/administrator';
}
}
}
else
{
static::$base['prefix'] =
$uri->toString(array('scheme', 'host',
'port'));
if (strpos(php_sapi_name(), 'cgi') !== false &&
!ini_get('cgi.fix_pathinfo') &&
!empty($_SERVER['REQUEST_URI']))
{
// PHP-CGI on Apache with "cgi.fix_pathinfo = 0"
// We shouldn't have user-supplied PATH_INFO in PHP_SELF in this
case
// because PHP will not work with PATH_INFO at all.
$script_name = $_SERVER['PHP_SELF'];
}
else
{
// Others
$script_name = $_SERVER['SCRIPT_NAME'];
}
// Extra cleanup to remove invalid chars in the URL to prevent
injections through broken server implementation
$script_name = str_replace(array("'",
'"', '<', '>'),
array('%27', '%22', '%3C', '%3E'),
$script_name);
static::$base['path'] = rtrim(dirname($script_name),
'/\\');
}
}
return $pathonly === false ? static::$base['prefix'] .
static::$base['path'] . '/' :
static::$base['path'];
}
/**
* Returns the root URI for the request.
*
* @param boolean $pathonly If false, prepend the scheme, host and
port information. Default is false.
* @param string $path The path
*
* @return string The root URI string.
*
* @since 1.7.0
*/
public static function root($pathonly = false, $path = null)
{
// Get the scheme
if (empty(static::$root))
{
$uri = static::getInstance(static::base());
static::$root['prefix'] =
$uri->toString(array('scheme', 'host',
'port'));
static::$root['path'] =
rtrim($uri->toString(array('path')), '/\\');
}
// Get the scheme
if (isset($path))
{
static::$root['path'] = $path;
}
return $pathonly === false ? static::$root['prefix'] .
static::$root['path'] . '/' :
static::$root['path'];
}
/**
* Returns the URL for the request, minus the query.
*
* @return string
*
* @since 1.7.0
*/
public static function current()
{
// Get the current URL.
if (empty(static::$current))
{
$uri = static::getInstance();
static::$current = $uri->toString(array('scheme',
'host', 'port', 'path'));
}
return static::$current;
}
/**
* Method to reset class static members for testing and other various
issues.
*
* @return void
*
* @since 1.7.0
*/
public static function reset()
{
static::$instances = array();
static::$base = array();
static::$root = array();
static::$current = '';
}
/**
* Set the URI path string. Note we keep this method here so it uses the
old _cleanPath function
*
* @param string $path The URI path string.
*
* @return void
*
* @since 1.7.0
* @deprecated 4.0 Use {@link \Joomla\Uri\Uri::setPath()}
* @note Present to proxy calls to the deprecated {@link
JUri::_cleanPath()} method.
*/
public function setPath($path)
{
$this->path = $this->_cleanPath($path);
}
/**
* Checks if the supplied URL is internal
*
* @param string $url The URL to check.
*
* @return boolean True if Internal.
*
* @since 1.7.0
*/
public static function isInternal($url)
{
$uri = static::getInstance($url);
$base = $uri->toString(array('scheme', 'host',
'port', 'path'));
$host = $uri->toString(array('scheme', 'host',
'port'));
// @see JUriTest
if (empty($host) && strpos($uri->path, 'index.php')
=== 0
|| !empty($host) && preg_match('#' .
preg_quote(static::base(), '#') . '#', $base)
|| !empty($host) && $host ===
static::getInstance(static::base())->host &&
strpos($uri->path, 'index.php') !== false
|| !empty($host) && $base === $host &&
preg_match('#' . preg_quote($base, '#') .
'#', static::base()))
{
return true;
}
return 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.7.0
* @note The parent method is protected, this exposes it as public for
B/C
*/
public static function buildQuery(array $params)
{
return parent::buildQuery($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.7.0
* @note The parent method is protected, this exposes it as public for
B/C
*/
public function parse($uri)
{
return parent::parse($uri);
}
/**
* 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.7.0
* @deprecated 4.0 Use {@link \Joomla\Uri\Uri::cleanPath()} instead
*/
protected function _cleanPath($path)
{
return parent::cleanPath($path);
}
}
home/lmsyaran/public_html/libraries/src/Uri/Uri.php000064400000022165151160361150016403
0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Uri;
defined('JPATH_PLATFORM') or die;
/**
* JUri Class
*
* This class serves two purposes. First it parses a URI and provides a
common interface
* for the Joomla Platform to access and manipulate a URI. Second it
obtains the URI of
* the current executing script from the server regardless of server.
*
* @since 1.7.0
*/
class Uri extends \Joomla\Uri\Uri
{
/**
* @var Uri[] An array of JUri instances.
* @since 1.7.0
*/
protected static $instances = array();
/**
* @var array The current calculated base url segments.
* @since 1.7.0
*/
protected static $base = array();
/**
* @var array The current calculated root url segments.
* @since 1.7.0
*/
protected static $root = array();
/**
* @var string The current url.
* @since 1.7.0
*/
protected static $current;
/**
* Returns the global JUri object, only creating it if it doesn't
already exist.
*
* @param string $uri The URI to parse. [optional: if null uses
script URI]
*
* @return Uri The URI object.
*
* @since 1.7.0
*/
public static function getInstance($uri = 'SERVER')
{
if (empty(static::$instances[$uri]))
{
// Are we obtaining the URI from the server?
if ($uri == 'SERVER')
{
// Determine if the request was over SSL (HTTPS).
if (isset($_SERVER['HTTPS']) &&
!empty($_SERVER['HTTPS']) &&
(strtolower($_SERVER['HTTPS']) != 'off'))
{
$https = 's://';
}
elseif ((isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
(strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) !==
'http')))
{
$https = 's://';
}
else
{
$https = '://';
}
/*
* Since we are assigning the URI from the server variables, we first
need
* to determine if we are running on apache or IIS. If PHP_SELF and
REQUEST_URI
* are present, we will assume we are running on apache.
*/
if (!empty($_SERVER['PHP_SELF']) &&
!empty($_SERVER['REQUEST_URI']))
{
// To build the entire URI we need to prepend the protocol, and the
http host
// to the URI string.
$theURI = 'http' . $https . $_SERVER['HTTP_HOST']
. $_SERVER['REQUEST_URI'];
}
else
{
/*
* Since we do not have REQUEST_URI to work with, we will assume we
are
* running on IIS and will therefore need to work some magic with the
SCRIPT_NAME and
* QUERY_STRING environment variables.
*
* IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI
variable... thanks, MS
*/
$theURI = 'http' . $https . $_SERVER['HTTP_HOST']
. $_SERVER['SCRIPT_NAME'];
// If the query string exists append it to the URI string
if (isset($_SERVER['QUERY_STRING']) &&
!empty($_SERVER['QUERY_STRING']))
{
$theURI .= '?' . $_SERVER['QUERY_STRING'];
}
}
// Extra cleanup to remove invalid chars in the URL to prevent
injections through the Host header
$theURI = str_replace(array("'", '"',
'<', '>'), array('%27',
'%22', '%3C', '%3E'), $theURI);
}
else
{
// We were given a URI
$theURI = $uri;
}
static::$instances[$uri] = new static($theURI);
}
return static::$instances[$uri];
}
/**
* Returns the base URI for the request.
*
* @param boolean $pathonly If false, prepend the scheme, host and
port information. Default is false.
*
* @return string The base URI string
*
* @since 1.7.0
*/
public static function base($pathonly = false)
{
// Get the base request path.
if (empty(static::$base))
{
$config = \JFactory::getConfig();
$uri = static::getInstance();
$live_site = ($uri->isSsl()) ? str_replace('http://',
'https://', $config->get('live_site')) :
$config->get('live_site');
if (trim($live_site) != '')
{
$uri = static::getInstance($live_site);
static::$base['prefix'] =
$uri->toString(array('scheme', 'host',
'port'));
static::$base['path'] =
rtrim($uri->toString(array('path')), '/\\');
if (defined('JPATH_BASE') &&
defined('JPATH_ADMINISTRATOR'))
{
if (JPATH_BASE == JPATH_ADMINISTRATOR)
{
static::$base['path'] .= '/administrator';
}
}
}
else
{
static::$base['prefix'] =
$uri->toString(array('scheme', 'host',
'port'));
if (strpos(php_sapi_name(), 'cgi') !== false &&
!ini_get('cgi.fix_pathinfo') &&
!empty($_SERVER['REQUEST_URI']))
{
// PHP-CGI on Apache with "cgi.fix_pathinfo = 0"
// We shouldn't have user-supplied PATH_INFO in PHP_SELF in this
case
// because PHP will not work with PATH_INFO at all.
$script_name = $_SERVER['PHP_SELF'];
}
else
{
// Others
$script_name = $_SERVER['SCRIPT_NAME'];
}
// Extra cleanup to remove invalid chars in the URL to prevent
injections through broken server implementation
$script_name = str_replace(array("'",
'"', '<', '>'),
array('%27', '%22', '%3C', '%3E'),
$script_name);
static::$base['path'] = rtrim(dirname($script_name),
'/\\');
}
}
return $pathonly === false ? static::$base['prefix'] .
static::$base['path'] . '/' :
static::$base['path'];
}
/**
* Returns the root URI for the request.
*
* @param boolean $pathonly If false, prepend the scheme, host and
port information. Default is false.
* @param string $path The path
*
* @return string The root URI string.
*
* @since 1.7.0
*/
public static function root($pathonly = false, $path = null)
{
// Get the scheme
if (empty(static::$root))
{
$uri = static::getInstance(static::base());
static::$root['prefix'] =
$uri->toString(array('scheme', 'host',
'port'));
static::$root['path'] =
rtrim($uri->toString(array('path')), '/\\');
}
// Get the scheme
if (isset($path))
{
static::$root['path'] = $path;
}
return $pathonly === false ? static::$root['prefix'] .
static::$root['path'] . '/' :
static::$root['path'];
}
/**
* Returns the URL for the request, minus the query.
*
* @return string
*
* @since 1.7.0
*/
public static function current()
{
// Get the current URL.
if (empty(static::$current))
{
$uri = static::getInstance();
static::$current = $uri->toString(array('scheme',
'host', 'port', 'path'));
}
return static::$current;
}
/**
* Method to reset class static members for testing and other various
issues.
*
* @return void
*
* @since 1.7.0
*/
public static function reset()
{
static::$instances = array();
static::$base = array();
static::$root = array();
static::$current = '';
}
/**
* Set the URI path string. Note we keep this method here so it uses the
old _cleanPath function
*
* @param string $path The URI path string.
*
* @return void
*
* @since 1.7.0
* @deprecated 4.0 Use {@link \Joomla\Uri\Uri::setPath()}
* @note Present to proxy calls to the deprecated {@link
JUri::_cleanPath()} method.
*/
public function setPath($path)
{
$this->path = $this->_cleanPath($path);
}
/**
* Checks if the supplied URL is internal
*
* @param string $url The URL to check.
*
* @return boolean True if Internal.
*
* @since 1.7.0
*/
public static function isInternal($url)
{
$uri = static::getInstance($url);
$base = $uri->toString(array('scheme', 'host',
'port', 'path'));
$host = $uri->toString(array('scheme', 'host',
'port'));
// @see JUriTest
if (empty($host) && strpos($uri->path, 'index.php')
=== 0
|| !empty($host) && preg_match('#' .
preg_quote(static::base(), '#') . '#', $base)
|| !empty($host) && $host ===
static::getInstance(static::base())->host &&
strpos($uri->path, 'index.php') !== false
|| !empty($host) && $base === $host &&
preg_match('#' . preg_quote($base, '#') .
'#', static::base()))
{
return true;
}
return 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.7.0
* @note The parent method is protected, this exposes it as public for
B/C
*/
public static function buildQuery(array $params)
{
return parent::buildQuery($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.7.0
* @note The parent method is protected, this exposes it as public for
B/C
*/
public function parse($uri)
{
return parent::parse($uri);
}
/**
* 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.7.0
* @deprecated 4.0 Use {@link \Joomla\Uri\Uri::cleanPath()} instead
*/
protected function _cleanPath($path)
{
return parent::cleanPath($path);
}
}
home/lmsyaran/public_html/libraries/vendor/joomla/uri/src/Uri.php000064400000006237151160404740021226
0ustar00<?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;
}
}
home/lmsyaran/public_html/j3/libraries/vendor/joomla/uri/src/Uri.php000064400000006237151162301200021527
0ustar00<?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;
}
}