AAAAuri.php000066600000042101151372637270006073 0ustar00parse($uri); } } /** * Magic method to get the string representation of the URI object. * * @return string * * @since 11.1 */ public function __toString() { return $this->toString(); } /** * 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 JURI The URI object. * * @since 11.1 */ public static function getInstance($uri = 'SERVER') { if (empty(self::$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://'; } 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; } // Create the new JURI instance self::$instances[$uri] = new JURI($theURI); } return self::$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 11.1 */ public static function base($pathonly = false) { // Get the base request path. if (empty(self::$base)) { $config = JFactory::getConfig(); $live_site = $config->get('live_site'); if (trim($live_site) != '') { $uri = self::getInstance($live_site); self::$base['prefix'] = $uri->toString(array('scheme', 'host', 'port')); self::$base['path'] = rtrim($uri->toString(array('path')), '/\\'); if (JPATH_BASE == JPATH_ADMINISTRATOR) { self::$base['path'] .= '/administrator'; } } else { $uri = self::getInstance(); self::$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']; } self::$base['path'] = rtrim(dirname($script_name), '/\\'); } } return $pathonly === false ? self::$base['prefix'] . self::$base['path'] . '/' : self::$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 11.1 */ public static function root($pathonly = false, $path = null) { // Get the scheme if (empty(self::$root)) { $uri = self::getInstance(self::base()); self::$root['prefix'] = $uri->toString(array('scheme', 'host', 'port')); self::$root['path'] = rtrim($uri->toString(array('path')), '/\\'); } // Get the scheme if (isset($path)) { self::$root['path'] = $path; } return $pathonly === false ? self::$root['prefix'] . self::$root['path'] . '/' : self::$root['path']; } /** * Returns the URL for the request, minus the query. * * @return string * * @since 11.1 */ public static function current() { // Get the current URL. if (empty(self::$current)) { $uri = self::getInstance(); self::$current = $uri->toString(array('scheme', 'host', 'port', 'path')); } return self::$current; } /** * Method to reset class static members for testing and other various issues. * * @return void * * @since 11.1 */ public static function reset() { self::$instances = array(); self::$base = array(); self::$root = array(); self::$current = ''; } /** * Parse a given URI and populate the class fields. * * @param string $uri The URI string to parse. * * @return boolean True on success. * * @since 11.1 */ public function parse($uri) { // Initialise variables $retval = false; // 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. if ($_parts = JString::parse_url($uri)) { $retval = true; } // 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; } /** * Returns full uri string. * * @param array $parts An array specifying the parts to render. * * @return string The rendered URI string. * * @since 11.1 */ public function toString($parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment')) { // Make sure the query is created $query = $this->getQuery(); $uri = ''; $uri .= in_array('scheme', $parts) ? (!empty($this->_scheme) ? $this->_scheme . '://' : '') : ''; $uri .= in_array('user', $parts) ? $this->_user : ''; $uri .= in_array('pass', $parts) ? (!empty($this->_pass) ? ':' : '') . $this->_pass . (!empty($this->_user) ? '@' : '') : ''; $uri .= in_array('host', $parts) ? $this->_host : ''; $uri .= in_array('port', $parts) ? (!empty($this->_port) ? ':' : '') . $this->_port : ''; $uri .= in_array('path', $parts) ? $this->_path : ''; $uri .= in_array('query', $parts) ? (!empty($query) ? '?' . $query : '') : ''; $uri .= in_array('fragment', $parts) ? (!empty($this->_fragment) ? '#' . $this->_fragment : '') : ''; return $uri; } /** * 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 11.1 */ public function setVar($name, $value) { $tmp = @$this->_vars[$name]; $this->_vars[$name] = $value; // Empty the query $this->_query = null; return $tmp; } /** * Checks if variable exists. * * @param string $name Name of the query variable to check. * * @return boolean True if the variable exists. * * @since 11.1 */ 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 array Query variables. * * @since 11.1 */ public function getVar($name, $default = null) { if (array_key_exists($name, $this->_vars)) { return $this->_vars[$name]; } return $default; } /** * Removes an item from the query string variables if it exists. * * @param string $name Name of variable to remove. * * @return void * * @since 11.1 */ 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 11.1 */ 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; } /** * Returns flat query string. * * @param boolean $toArray True to return the query as a key => value pair array. * * @return string Query string. * * @since 11.1 */ 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; } /** * Build a query from a 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 11.1 */ public static function buildQuery($params) { if (!is_array($params) || count($params) == 0) { return false; } return urldecode(http_build_query($params, '', '&')); } /** * Get URI scheme (protocol) * ie. http, https, ftp, etc... * * @return string The URI scheme. * * @since 11.1 */ public function getScheme() { return $this->_scheme; } /** * Set URI scheme (protocol) * ie. http, https, ftp, etc... * * @param string $scheme The URI scheme. * * @return void * * @since 11.1 */ public function setScheme($scheme) { $this->_scheme = $scheme; } /** * Get URI username * Returns the username, or null if no username was specified. * * @return string The URI username. * * @since 11.1 */ public function getUser() { return $this->_user; } /** * Set URI username. * * @param string $user The URI username. * * @return void * * @since 11.1 */ public function setUser($user) { $this->_user = $user; } /** * Get URI password * Returns the password, or null if no password was specified. * * @return string The URI password. * * @since 11.1 */ public function getPass() { return $this->_pass; } /** * Set URI password. * * @param string $pass The URI password. * * @return void * * @since 11.1 */ public function setPass($pass) { $this->_pass = $pass; } /** * Get URI host * Returns the hostname/ip or null if no hostname/ip was specified. * * @return string The URI host. * * @since 11.1 */ public function getHost() { return $this->_host; } /** * Set URI host. * * @param string $host The URI host. * * @return void * * @since 11.1 */ public function setHost($host) { $this->_host = $host; } /** * Get URI port * Returns the port number, or null if no port was specified. * * @return integer The URI port number. * * @since 11.1 */ public function getPort() { return (isset($this->_port)) ? $this->_port : null; } /** * Set URI port. * * @param integer $port The URI port number. * * @return void * * @since 11.1 */ public function setPort($port) { $this->_port = $port; } /** * Gets the URI path string. * * @return string The URI path string. * * @since 11.1 */ public function getPath() { return $this->_path; } /** * Set the URI path string. * * @param string $path The URI path string. * * @return void * * @since 11.1 */ public function setPath($path) { $this->_path = $this->_cleanPath($path); } /** * Get the URI archor string * Everything after the "#". * * @return string The URI anchor string. * * @since 11.1 */ public function getFragment() { return $this->_fragment; } /** * Set the URI anchor string * everything after the "#". * * @param string $anchor The URI anchor string. * * @return void * * @since 11.1 */ public function setFragment($anchor) { $this->_fragment = $anchor; } /** * Checks whether the current URI is using HTTPS. * * @return boolean True if using SSL via HTTPS. * * @since 11.1 */ public function isSSL() { return $this->getScheme() == 'https' ? true : false; } /** * Checks if the supplied URL is internal * * @param string $url The URL to check. * * @return boolean True if Internal. * * @since 11.1 */ public static function isInternal($url) { $uri = self::getInstance($url); $base = $uri->toString(array('scheme', 'host', 'port', 'path')); $host = $uri->toString(array('scheme', 'host', 'port')); if (stripos($base, self::base()) !== 0 && !empty($host)) { return false; } return true; } /** * 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 11.1 */ protected function _cleanPath($path) { $path = explode('/', preg_replace('#(/+)#', '/', $path)); for ($i = 0, $n = count($path); $i < $n; $i++) { if ($path[$i] == '.' or $path[$i] == '..') { if (($path[$i] == '.') or ($path[$i] == '..' and $i == 1 and $path[0] == '')) { unset($path[$i]); $path = array_values($path); $i--; $n--; } elseif ($path[$i] == '..' and ($i > 1 or ($i == 1 and $path[0] != ''))) { unset($path[$i]); unset($path[$i - 1]); $path = array_values($path); $i -= 2; $n -= 2; } } } return implode('/', $path); } } request.php000066600000041223151372637270006770 0ustar00toString(array('path', 'query')); } /** * Gets the request method. * * @return string * * @since 11.1 * * @deprecated 12.1 */ public static function getMethod() { $method = strtoupper($_SERVER['REQUEST_METHOD']); return $method; } /** * Fetches and returns a given variable. * * The default behaviour is fetching variables depending on the * current request method: GET and HEAD will result in returning * an entry from $_GET, POST and PUT will result in returning an * entry from $_POST. * * You can force the source by setting the $hash parameter: * * post $_POST * get $_GET * files $_FILES * cookie $_COOKIE * env $_ENV * server $_SERVER * method via current $_SERVER['REQUEST_METHOD'] * default $_REQUEST * * @param string $name Variable name. * @param string $default Default value if the variable does not exist. * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD). * @param string $type Return type for the variable, for valid values see {@link JFilterInput::clean()}. * @param integer $mask Filter mask for the variable. * * @return mixed Requested variable. * * @since 11.1 * * @deprecated 12.1 Use JInput::Get */ public static function getVar($name, $default = null, $hash = 'default', $type = 'none', $mask = 0) { // Ensure hash and type are uppercase $hash = strtoupper($hash); if ($hash === 'METHOD') { $hash = strtoupper($_SERVER['REQUEST_METHOD']); } $type = strtoupper($type); $sig = $hash . $type . $mask; // Get the input hash switch ($hash) { case 'GET': $input = &$_GET; break; case 'POST': $input = &$_POST; break; case 'FILES': $input = &$_FILES; break; case 'COOKIE': $input = &$_COOKIE; break; case 'ENV': $input = &$_ENV; break; case 'SERVER': $input = &$_SERVER; break; default: $input = &$_REQUEST; $hash = 'REQUEST'; break; } if (isset($GLOBALS['_JREQUEST'][$name]['SET.' . $hash]) && ($GLOBALS['_JREQUEST'][$name]['SET.' . $hash] === true)) { // Get the variable from the input hash $var = (isset($input[$name]) && $input[$name] !== null) ? $input[$name] : $default; $var = self::_cleanVar($var, $mask, $type); } elseif (!isset($GLOBALS['_JREQUEST'][$name][$sig])) { if (isset($input[$name]) && $input[$name] !== null) { // Get the variable from the input hash and clean it $var = self::_cleanVar($input[$name], $mask, $type); // Handle magic quotes compatibility if (get_magic_quotes_gpc() && ($var != $default) && ($hash != 'FILES')) { $var = self::_stripSlashesRecursive($var); } $GLOBALS['_JREQUEST'][$name][$sig] = $var; } elseif ($default !== null) { // Clean the default value $var = self::_cleanVar($default, $mask, $type); } else { $var = $default; } } else { $var = $GLOBALS['_JREQUEST'][$name][$sig]; } return $var; } /** * Fetches and returns a given filtered variable. The integer * filter will allow only digits and the - sign to be returned. This is currently * only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @param string $name Variable name. * @param string $default Default value if the variable does not exist. * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD). * * @return integer Requested variable. * * @since 11.1 * * @deprecated 12.1 */ public static function getInt($name, $default = 0, $hash = 'default') { return self::getVar($name, $default, $hash, 'int'); } /** * Fetches and returns a given filtered variable. The unsigned integer * filter will allow only digits to be returned. This is currently * only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @param string $name Variable name. * @param string $default Default value if the variable does not exist. * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD). * * @return integer Requested variable. * * @deprecated 12.1 * @since 11.1 */ public static function getUInt($name, $default = 0, $hash = 'default') { return self::getVar($name, $default, $hash, 'uint'); } /** * Fetches and returns a given filtered variable. The float * filter only allows digits and periods. This is currently * only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @param string $name Variable name. * @param string $default Default value if the variable does not exist. * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD). * * @return float Requested variable. * * @since 11.1 * * @deprecated 12.1 */ public static function getFloat($name, $default = 0.0, $hash = 'default') { return self::getVar($name, $default, $hash, 'float'); } /** * Fetches and returns a given filtered variable. The bool * filter will only return true/false bool values. This is * currently only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @param string $name Variable name. * @param string $default Default value if the variable does not exist. * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD). * * @return boolean Requested variable. * * @deprecated 12.1 * @since 11.1 */ public static function getBool($name, $default = false, $hash = 'default') { return self::getVar($name, $default, $hash, 'bool'); } /** * Fetches and returns a given filtered variable. The word * filter only allows the characters [A-Za-z_]. This is currently * only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @param string $name Variable name. * @param string $default Default value if the variable does not exist. * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD). * * @return string Requested variable. * * @since 11.1 * * @deprecated 12.1 */ public static function getWord($name, $default = '', $hash = 'default') { return self::getVar($name, $default, $hash, 'word'); } /** * Cmd (Word and Integer0 filter * * Fetches and returns a given filtered variable. The cmd * filter only allows the characters [A-Za-z0-9.-_]. This is * currently only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @param string $name Variable name * @param string $default Default value if the variable does not exist * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD) * * @return string Requested variable * * @deprecated 12.1 * @since 11.1 */ public static function getCmd($name, $default = '', $hash = 'default') { return self::getVar($name, $default, $hash, 'cmd'); } /** * Fetches and returns a given filtered variable. The string * filter deletes 'bad' HTML code, if not overridden by the mask. * This is currently only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @param string $name Variable name * @param string $default Default value if the variable does not exist * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD) * @param integer $mask Filter mask for the variable * * @return string Requested variable * * @since 11.1 * * @deprecated 12.1 */ public static function getString($name, $default = '', $hash = 'default', $mask = 0) { // Cast to string, in case JREQUEST_ALLOWRAW was specified for mask return (string) self::getVar($name, $default, $hash, 'string', $mask); } /** * Set a variable in one of the request variables. * * @param string $name Name * @param string $value Value * @param string $hash Hash * @param boolean $overwrite Boolean * * @return string Previous value * * @since 11.1 * * @deprecated 12.1 */ public static function setVar($name, $value = null, $hash = 'method', $overwrite = true) { // If overwrite is true, makes sure the variable hasn't been set yet if (!$overwrite && array_key_exists($name, $_REQUEST)) { return $_REQUEST[$name]; } // Clean global request var $GLOBALS['_JREQUEST'][$name] = array(); // Get the request hash value $hash = strtoupper($hash); if ($hash === 'METHOD') { $hash = strtoupper($_SERVER['REQUEST_METHOD']); } $previous = array_key_exists($name, $_REQUEST) ? $_REQUEST[$name] : null; switch ($hash) { case 'GET': $_GET[$name] = $value; $_REQUEST[$name] = $value; break; case 'POST': $_POST[$name] = $value; $_REQUEST[$name] = $value; break; case 'COOKIE': $_COOKIE[$name] = $value; $_REQUEST[$name] = $value; break; case 'FILES': $_FILES[$name] = $value; break; case 'ENV': $_ENV['name'] = $value; break; case 'SERVER': $_SERVER['name'] = $value; break; } // Mark this variable as 'SET' $GLOBALS['_JREQUEST'][$name]['SET.' . $hash] = true; $GLOBALS['_JREQUEST'][$name]['SET.REQUEST'] = true; return $previous; } /** * Fetches and returns a request array. * * The default behaviour is fetching variables depending on the * current request method: GET and HEAD will result in returning * $_GET, POST and PUT will result in returning $_POST. * * You can force the source by setting the $hash parameter: * * post $_POST * get $_GET * files $_FILES * cookie $_COOKIE * env $_ENV * server $_SERVER * method via current $_SERVER['REQUEST_METHOD'] * default $_REQUEST * * @param string $hash to get (POST, GET, FILES, METHOD). * @param integer $mask Filter mask for the variable. * * @return mixed Request hash. * * @deprecated 12.1 User JInput::get * @see JInput * @since 11.1 */ public static function get($hash = 'default', $mask = 0) { $hash = strtoupper($hash); if ($hash === 'METHOD') { $hash = strtoupper($_SERVER['REQUEST_METHOD']); } switch ($hash) { case 'GET': $input = $_GET; break; case 'POST': $input = $_POST; break; case 'FILES': $input = $_FILES; break; case 'COOKIE': $input = $_COOKIE; break; case 'ENV': $input = &$_ENV; break; case 'SERVER': $input = &$_SERVER; break; default: $input = $_REQUEST; break; } $result = self::_cleanVar($input, $mask); // Handle magic quotes compatibility if (get_magic_quotes_gpc() && ($hash != 'FILES')) { $result = self::_stripSlashesRecursive($result); } return $result; } /** * Sets a request variable. * * @param array $array An associative array of key-value pairs. * @param string $hash The request variable to set (POST, GET, FILES, METHOD). * @param boolean $overwrite If true and an existing key is found, the value is overwritten, otherwise it is ignored. * * @return void * * @deprecated 12.1 Use JInput::Set * @see JInput::Set * @since 11.1 */ public static function set($array, $hash = 'default', $overwrite = true) { foreach ($array as $key => $value) { self::setVar($key, $value, $hash, $overwrite); } } /** * Checks for a form token in the request. * * Use in conjunction with JHtml::_('form.token'). * * @param string $method The request method in which to look for the token key. * * @return boolean True if found and valid, false otherwise. * * @deprecated 12.1 Use JSession::checkToken() instead. * @since 11.1 */ public static function checkToken($method = 'post') { $token = JSession::getFormToken(); if (!self::getVar($token, '', $method, 'alnum')) { $session = JFactory::getSession(); if ($session->isNew()) { // Redirect to login screen. $app = JFactory::getApplication(); $return = JRoute::_('index.php'); $app->redirect($return, JText::_('JLIB_ENVIRONMENT_SESSION_EXPIRED')); $app->close(); } else { return false; } } else { return true; } } /** * Cleans the request from script injection. * * @return void * * @since 11.1 * * @deprecated 12.1 */ public static function clean() { // Only run this if register globals is on. // Remove this code when PHP 5.4 becomes the minimum requirement. if (!(bool) ini_get('register_globals')) { return; } $REQUEST = $_REQUEST; $GET = $_GET; $POST = $_POST; $COOKIE = $_COOKIE; $FILES = $_FILES; $ENV = $_ENV; $SERVER = $_SERVER; if (isset($_SESSION)) { $SESSION = $_SESSION; } foreach ($GLOBALS as $key => $value) { if ($key != 'GLOBALS') { unset($GLOBALS[$key]); } } $_REQUEST = $REQUEST; $_GET = $GET; $_POST = $POST; $_COOKIE = $COOKIE; $_FILES = $FILES; $_ENV = $ENV; $_SERVER = $SERVER; if (isset($SESSION)) { $_SESSION = $SESSION; } // Make sure the request hash is clean on file inclusion $GLOBALS['_JREQUEST'] = array(); } /** * Clean up an input variable. * * @param mixed $var The input variable. * @param integer $mask Filter bit mask. * 1 = no trim: If this flag is cleared and the input is a string, the string will have leading and trailing * whitespace trimmed. * 2 = allow_raw: If set, no more filtering is performed, higher bits are ignored. * 4 = allow_html: HTML is allowed, but passed through a safe HTML filter first. If set, no more filtering * is performed. If no bits other than the 1 bit is set, a strict filter is applied. * @param string $type The variable type {@see JFilterInput::clean()}. * * @return mixed Same as $var * * @deprecated 12.1 * @since 11.1 */ static function _cleanVar($var, $mask = 0, $type = null) { // If the no trim flag is not set, trim the variable if (!($mask & 1) && is_string($var)) { $var = trim($var); } // Now we handle input filtering if ($mask & 2) { // If the allow raw flag is set, do not modify the variable $var = $var; } elseif ($mask & 4) { // If the allow HTML flag is set, apply a safe HTML filter to the variable $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1); $var = $safeHtmlFilter->clean($var, $type); } else { // Since no allow flags were set, we will apply the most strict filter to the variable // $tags, $attr, $tag_method, $attr_method, $xss_auto use defaults. $noHtmlFilter = JFilterInput::getInstance(); $var = $noHtmlFilter->clean($var, $type); } return $var; } /** * Strips slashes recursively on an array. * * @param array $value Array or (nested arrays) of strings. * * @return array The input array with stripslashes applied to it. * * @deprecated 12.1 * @since 11.1 */ protected static function _stripSlashesRecursive($value) { $value = is_array($value) ? array_map(array('JRequest', '_stripSlashesRecursive'), $value) : stripslashes($value); return $value; } } index.html000066600000000037151372637270006562 0ustar00 response.php000066600000014505151372637270007141 0ustar00 $header) { if ($name == $header['name']) { unset(self::$headers[$key]); } } } self::$headers[] = array('name' => $name, 'value' => $value); } /** * Return array of headers. * * @return array * * @since 11.1 */ public static function getHeaders() { return self::$headers; } /** * Clear headers. * * @return void * * @since 11.1 */ public static function clearHeaders() { self::$headers = array(); } /** * Send all headers. * * @return void * * @since 11.1 */ public static function sendHeaders() { if (!headers_sent()) { foreach (self::$headers as $header) { if ('status' == strtolower($header['name'])) { // 'status' headers indicate an HTTP status, and need to be handled slightly differently header(ucfirst(strtolower($header['name'])) . ': ' . $header['value'], null, (int) $header['value']); } else { header($header['name'] . ': ' . $header['value'], false); } } } } /** * Set body content. * * If body content already defined, this will replace it. * * @param string $content The content to set to the response body. * * @return void * * @since 11.1 */ public static function setBody($content) { self::$body = array((string) $content); } /** * Prepend content to the body content * * @param string $content The content to prepend to the response body. * * @return void * * @since 11.1 */ public static function prependBody($content) { array_unshift(self::$body, (string) $content); } /** * Append content to the body content * * @param string $content The content to append to the response body. * * @return void * * @since 11.1 */ public static function appendBody($content) { array_push(self::$body, (string) $content); } /** * Return the body content * * @param boolean $toArray Whether or not to return the body content as an array of strings or as a single string; defaults to false. * * @return string array * * @since 11.1 */ public static function getBody($toArray = false) { if ($toArray) { return self::$body; } ob_start(); foreach (self::$body as $content) { echo $content; } return ob_get_clean(); } /** * Sends all headers prior to returning the string * * @param boolean $compress If true, compress the data * * @return string * * @since 11.1 */ public static function toString($compress = false) { $data = self::getBody(); // Don't compress something if the server is going to do it anyway. Waste of time. if ($compress && !ini_get('zlib.output_compression') && ini_get('output_handler') != 'ob_gzhandler') { $data = self::compress($data); } if (self::allowCache() === false) { self::setHeader('Cache-Control', 'no-cache', false); // HTTP 1.0 self::setHeader('Pragma', 'no-cache'); } self::sendHeaders(); return $data; } /** * Compress the data * * Checks the accept encoding of the browser and compresses the data before * sending it to the client. * * @param string $data Content to compress for output. * * @return string compressed data * * @note Replaces _compress method in 11.1 * @since 11.1 */ protected static function compress($data) { $encoding = self::clientEncoding(); if (!$encoding) { return $data; } if (!extension_loaded('zlib') || ini_get('zlib.output_compression')) { return $data; } if (headers_sent()) { return $data; } if (connection_status() !== 0) { return $data; } // Ideal level $level = 4; /* $size = strlen($data); $crc = crc32($data); $gzdata = "\x1f\x8b\x08\x00\x00\x00\x00\x00"; $gzdata .= gzcompress($data, $level); $gzdata = substr($gzdata, 0, strlen($gzdata) - 4); $gzdata .= pack("V",$crc) . pack("V", $size); */ $gzdata = gzencode($data, $level); self::setHeader('Content-Encoding', $encoding); self::setHeader('X-Content-Encoded-By', 'Joomla! 2.5'); return $gzdata; } /** * Check, whether client supports compressed data * * @return boolean * * @since 11.1 * @note Replaces _clientEncoding method from 11.1 */ protected static function clientEncoding() { if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { return false; } $encoding = false; if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) { $encoding = 'gzip'; } if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) { $encoding = 'x-gzip'; } return $encoding; } } browser.php000066600000067275151372637270007002 0ustar00 true, 'wml' => false, 'images' => true, 'iframes' => false, 'frames' => true, 'tables' => true, 'java' => true, 'javascript' => true, 'dom' => false, 'utf' => false, 'rte' => false, 'homepage' => false, 'accesskey' => false, 'xmlhttpreq' => false, 'xhtml+xml' => false, 'mathml' => false, 'svg' => false ); /** * @var array Quirks. * @since 11.1 * @deprecated 12.1 This variable will be dropped without replacement */ protected $_quirks = array( 'avoid_popup_windows' => false, 'break_disposition_header' => false, 'break_disposition_filename' => false, 'broken_multipart_form' => false, 'cache_same_url' => false, 'cache_ssl_downloads' => false, 'double_linebreak_textarea' => false, 'empty_file_input_value' => false, 'must_cache_forms' => false, 'no_filename_spaces' => false, 'no_hidden_overflow_tables' => false, 'ow_gui_1.3' => false, 'png_transparency' => false, 'scrollbar_in_way' => false, 'scroll_tds' => false, 'windowed_controls' => false); /** * List of viewable image MIME subtypes. * This list of viewable images works for IE and Netscape/Mozilla. * * @var array * @since 11.1 */ protected $_images = array('jpeg', 'gif', 'png', 'pjpeg', 'x-png', 'bmp'); /** * @var array JBrowser instances container. * @since 11.3 */ protected static $instances = array(); /** * Create a browser instance (constructor). * * @param string $userAgent The browser string to parse. * @param string $accept The HTTP_ACCEPT settings to use. * * @since 11.1 */ public function __construct($userAgent = null, $accept = null) { $this->match($userAgent, $accept); } /** * Returns the global Browser object, only creating it * if it doesn't already exist. * * @param string $userAgent The browser string to parse. * @param string $accept The HTTP_ACCEPT settings to use. * * @return JBrowser The Browser object. * * @since 11.1 */ static public function getInstance($userAgent = null, $accept = null) { $signature = serialize(array($userAgent, $accept)); if (empty(self::$instances[$signature])) { self::$instances[$signature] = new JBrowser($userAgent, $accept); } return self::$instances[$signature]; } /** * Identify which of two types is preferred * * @param string $a The first item in the comparision * @param string $b The second item in the comparison * * @return void * * @since 11.1 */ public static function _sortMime($a, $b) { if ($a[1] > $b[1]) { return -1; } elseif ($a[1] < $b[1]) { return 1; } else { return 0; } } /** * Parses the user agent string and inititializes the object with * all the known features and quirks for the given browser. * * @param string $userAgent The browser string to parse. * @param string $accept The HTTP_ACCEPT settings to use. * * @return void * * @since 11.1 */ public function match($userAgent = null, $accept = null) { // Set our agent string. if (is_null($userAgent)) { if (isset($_SERVER['HTTP_USER_AGENT'])) { $this->_agent = trim($_SERVER['HTTP_USER_AGENT']); } } else { $this->_agent = $userAgent; } $this->_lowerAgent = strtolower($this->_agent); // Set our accept string. if (is_null($accept)) { if (isset($_SERVER['HTTP_ACCEPT'])) { $this->_accept = strtolower(trim($_SERVER['HTTP_ACCEPT'])); } } else { $this->_accept = strtolower($accept); } // Parse the HTTP Accept Header $accept_mime = explode(",", $this->_accept); for ($i = 0, $count = count($accept_mime); $i < $count; $i++) { $parts = explode(';q=', trim($accept_mime[$i])); if (count($parts) === 1) { $parts[1] = 1; } $accept_mime[$i] = $parts; } // Sort so the preferred value is the first usort($accept_mime, array(__CLASS__, '_sortMime')); $this->_accept_parsed = $accept_mime; // Check if browser accepts content type application/xhtml+xml. */* doesn't count ;) foreach ($this->_accept_parsed as $mime) { if (($mime[0] == 'application/xhtml+xml')) { $this->_setFeature('xhtml+xml'); } } // Check for a mathplayer plugin is installed, so we can use MathML on several browsers. if (strpos($this->_lowerAgent, 'mathplayer') !== false) { $this->_setFeature('mathml'); } // Check for UTF support. if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) { $this->_setFeature('utf', strpos(strtolower($_SERVER['HTTP_ACCEPT_CHARSET']), 'utf') !== false); } if (!empty($this->_agent)) { $this->_setPlatform(); if (strpos($this->_lowerAgent, 'mobileexplorer') !== false || strpos($this->_lowerAgent, 'openwave') !== false || strpos($this->_lowerAgent, 'opera mini') !== false || strpos($this->_lowerAgent, 'opera mobi') !== false || strpos($this->_lowerAgent, 'operamini') !== false) { $this->_setFeature('frames', false); $this->_setFeature('javascript', false); $this->_setQuirk('avoid_popup_windows'); $this->_mobile = true; } elseif (preg_match('|Opera[/ ]([0-9.]+)|', $this->_agent, $version)) { $this->setBrowser('opera'); list ($this->_majorVersion, $this->_minorVersion) = explode('.', $version[1]); $this->_setFeature('javascript', true); $this->_setQuirk('no_filename_spaces'); if ($this->_majorVersion >= 7) { $this->_setFeature('dom'); $this->_setFeature('iframes'); $this->_setFeature('accesskey'); $this->_setQuirk('double_linebreak_textarea'); } /* Due to changes in Opera UA, we need to check Version/xx.yy, * but only if version is > 9.80. See: http://dev.opera.com/articles/view/opera-ua-string-changes/ */ if ($this->_majorVersion == 9 && $this->_minorVersion >= 80) { $this->identifyBrowserVersion(); } } elseif (preg_match('|Chrome[/ ]([0-9.]+)|', $this->_agent, $version)) { $this->setBrowser('chrome'); list ($this->_majorVersion, $this->_minorVersion) = explode('.', $version[1]); $this->_setFeature('javascript', true); } elseif (preg_match('|CrMo[/ ]([0-9.]+)|', $this->_agent, $version)) { $this->setBrowser('chrome'); list ($this->_majorVersion, $this->_minorVersion) = explode('.', $version[1]); } elseif (preg_match('|CriOS[/ ]([0-9.]+)|', $this->_agent, $version)) { $this->setBrowser('chrome'); list ($this->_majorVersion, $this->_minorVersion) = explode('.', $version[1]); $this->_mobile = true; } elseif (strpos($this->_lowerAgent, 'elaine/') !== false || strpos($this->_lowerAgent, 'palmsource') !== false || strpos($this->_lowerAgent, 'digital paths') !== false) { $this->setBrowser('palm'); $this->_setFeature('images', false); $this->_setFeature('frames', false); $this->_setFeature('javascript', false); $this->_setQuirk('avoid_popup_windows'); $this->_mobile = true; } elseif ((preg_match('|MSIE ([0-9.]+)|', $this->_agent, $version)) || (preg_match('|Internet Explorer/([0-9.]+)|', $this->_agent, $version))) { $this->setBrowser('msie'); $this->_setQuirk('cache_ssl_downloads'); $this->_setQuirk('cache_same_url'); $this->_setQuirk('break_disposition_filename'); if (strpos($version[1], '.') !== false) { list ($this->_majorVersion, $this->_minorVersion) = explode('.', $version[1]); } else { $this->_majorVersion = $version[1]; $this->_minorVersion = 0; } /* IE (< 7) on Windows does not support alpha transparency in * PNG images. */ if (($this->_majorVersion < 7) && preg_match('/windows/i', $this->_agent)) { $this->_setQuirk('png_transparency'); } /* Some Handhelds have their screen resolution in the * user agent string, which we can use to look for * mobile agents. */ if (preg_match('/; (120x160|240x280|240x320|320x320)\)/', $this->_agent)) { $this->_mobile = true; } switch ($this->_majorVersion) { case 7: $this->_setFeature('javascript', 1.4); $this->_setFeature('dom'); $this->_setFeature('iframes'); $this->_setFeature('utf'); $this->_setFeature('rte'); $this->_setFeature('homepage'); $this->_setFeature('accesskey'); $this->_setFeature('xmlhttpreq'); $this->_setQuirk('scrollbar_in_way'); break; case 6: $this->_setFeature('javascript', 1.4); $this->_setFeature('dom'); $this->_setFeature('iframes'); $this->_setFeature('utf'); $this->_setFeature('rte'); $this->_setFeature('homepage'); $this->_setFeature('accesskey'); $this->_setFeature('xmlhttpreq'); $this->_setQuirk('scrollbar_in_way'); $this->_setQuirk('broken_multipart_form'); $this->_setQuirk('windowed_controls'); break; case 5: if ($this->getPlatform() == 'mac') { $this->_setFeature('javascript', 1.2); } else { // MSIE 5 for Windows. $this->_setFeature('javascript', 1.4); $this->_setFeature('dom'); $this->_setFeature('xmlhttpreq'); if ($this->_minorVersion >= 5) { $this->_setFeature('rte'); $this->_setQuirk('windowed_controls'); } } $this->_setFeature('iframes'); $this->_setFeature('utf'); $this->_setFeature('homepage'); $this->_setFeature('accesskey'); if ($this->_minorVersion == 5) { $this->_setQuirk('break_disposition_header'); $this->_setQuirk('broken_multipart_form'); } break; case 4: $this->_setFeature('javascript', 1.2); $this->_setFeature('accesskey'); if ($this->_minorVersion > 0) { $this->_setFeature('utf'); } break; case 3: $this->_setFeature('javascript', 1.5); $this->_setQuirk('avoid_popup_windows'); break; } } elseif (preg_match('|amaya/([0-9.]+)|', $this->_agent, $version)) { $this->setBrowser('amaya'); $this->_majorVersion = $version[1]; if (isset($version[2])) { $this->_minorVersion = $version[2]; } if ($this->_majorVersion > 1) { $this->_setFeature('mathml'); $this->_setFeature('svg'); } $this->_setFeature('xhtml+xml'); } elseif (preg_match('|W3C_Validator/([0-9.]+)|', $this->_agent, $version)) { $this->_setFeature('mathml'); $this->_setFeature('svg'); $this->_setFeature('xhtml+xml'); } elseif (preg_match('|ANTFresco/([0-9]+)|', $this->_agent, $version)) { $this->setBrowser('fresco'); $this->_setFeature('javascript', 1.5); $this->_setQuirk('avoid_popup_windows'); } elseif (strpos($this->_lowerAgent, 'avantgo') !== false) { $this->setBrowser('avantgo'); $this->_mobile = true; } elseif (preg_match('|Konqueror/([0-9]+)|', $this->_agent, $version) || preg_match('|Safari/([0-9]+)\.?([0-9]+)?|', $this->_agent, $version)) { // Konqueror and Apple's Safari both use the KHTML // rendering engine. $this->setBrowser('konqueror'); $this->_setQuirk('empty_file_input_value'); $this->_setQuirk('no_hidden_overflow_tables'); $this->_majorVersion = $version[1]; if (isset($version[2])) { $this->_minorVersion = $version[2]; } if (strpos($this->_agent, 'Safari') !== false && $this->_majorVersion >= 60) { // Safari. $this->setBrowser('safari'); $this->_setFeature('utf'); $this->_setFeature('javascript', 1.4); $this->_setFeature('dom'); $this->_setFeature('iframes'); if ($this->_majorVersion > 125 || ($this->_majorVersion == 125 && $this->_minorVersion >= 1)) { $this->_setFeature('accesskey'); $this->_setFeature('xmlhttpreq'); } if ($this->_majorVersion > 522) { $this->_setFeature('svg'); $this->_setFeature('xhtml+xml'); } // Set browser version, not engine version $this->identifyBrowserVersion(); } else { // Konqueror. $this->_setFeature('javascript', 1.5); switch ($this->_majorVersion) { case 3: $this->_setFeature('dom'); $this->_setFeature('iframes'); $this->_setFeature('xhtml+xml'); break; } } } elseif (preg_match('|Mozilla/([0-9.]+)|', $this->_agent, $version)) { $this->setBrowser('mozilla'); $this->_setQuirk('must_cache_forms'); list ($this->_majorVersion, $this->_minorVersion) = explode('.', $version[1]); switch ($this->_majorVersion) { case 5: if ($this->getPlatform() == 'win') { $this->_setQuirk('break_disposition_filename'); } $this->_setFeature('javascript', 1.4); $this->_setFeature('dom'); $this->_setFeature('accesskey'); $this->_setFeature('xmlhttpreq'); if (preg_match('|rv:(.*)\)|', $this->_agent, $revision)) { if ($revision[1] >= 1) { $this->_setFeature('iframes'); } if ($revision[1] >= 1.3) { $this->_setFeature('rte'); } if ($revision[1] >= 1.5) { $this->_setFeature('svg'); $this->_setFeature('mathml'); $this->_setFeature('xhtml+xml'); } } break; case 4: $this->_setFeature('javascript', 1.3); $this->_setQuirk('buggy_compression'); break; case 3: default: $this->_setFeature('javascript', 1); $this->_setQuirk('buggy_compression'); break; } } elseif (preg_match('|Lynx/([0-9]+)|', $this->_agent, $version)) { $this->setBrowser('lynx'); $this->_setFeature('images', false); $this->_setFeature('frames', false); $this->_setFeature('javascript', false); $this->_setQuirk('avoid_popup_windows'); } elseif (preg_match('|Links \(([0-9]+)|', $this->_agent, $version)) { $this->setBrowser('links'); $this->_setFeature('images', false); $this->_setFeature('frames', false); $this->_setFeature('javascript', false); $this->_setQuirk('avoid_popup_windows'); } elseif (preg_match('|HotJava/([0-9]+)|', $this->_agent, $version)) { $this->setBrowser('hotjava'); $this->_setFeature('javascript', false); } elseif (strpos($this->_agent, 'UP/') !== false || strpos($this->_agent, 'UP.B') !== false || strpos($this->_agent, 'UP.L') !== false) { $this->setBrowser('up'); $this->_setFeature('html', false); $this->_setFeature('javascript', false); $this->_setFeature('wml'); if (strpos($this->_agent, 'GUI') !== false && strpos($this->_agent, 'UP.Link') !== false) { /* The device accepts Openwave GUI extensions for * WML 1.3. Non-UP.Link gateways sometimes have * problems, so exclude them. */ $this->_setQuirk('ow_gui_1.3'); } $this->_mobile = true; } elseif (strpos($this->_agent, 'Xiino/') !== false) { $this->setBrowser('xiino'); $this->_setFeature('wml'); $this->_mobile = true; } elseif (strpos($this->_agent, 'Palmscape/') !== false) { $this->setBrowser('palmscape'); $this->_setFeature('javascript', false); $this->_setFeature('wml'); $this->_mobile = true; } elseif (strpos($this->_agent, 'Nokia') !== false) { $this->setBrowser('nokia'); $this->_setFeature('html', false); $this->_setFeature('wml'); $this->_setFeature('xhtml'); $this->_mobile = true; } elseif (strpos($this->_agent, 'Ericsson') !== false) { $this->setBrowser('ericsson'); $this->_setFeature('html', false); $this->_setFeature('wml'); $this->_mobile = true; } elseif (strpos($this->_lowerAgent, 'wap') !== false) { $this->setBrowser('wap'); $this->_setFeature('html', false); $this->_setFeature('javascript', false); $this->_setFeature('wml'); $this->_mobile = true; } elseif (strpos($this->_lowerAgent, 'docomo') !== false || strpos($this->_lowerAgent, 'portalmmm') !== false) { $this->setBrowser('imode'); $this->_setFeature('images', false); $this->_mobile = true; } elseif (strpos($this->_agent, 'BlackBerry') !== false) { $this->setBrowser('blackberry'); $this->_setFeature('html', false); $this->_setFeature('javascript', false); $this->_setFeature('wml'); $this->_mobile = true; } elseif (strpos($this->_agent, 'MOT-') !== false) { $this->setBrowser('motorola'); $this->_setFeature('html', false); $this->_setFeature('javascript', false); $this->_setFeature('wml'); $this->_mobile = true; } elseif (strpos($this->_lowerAgent, 'j-') !== false) { $this->setBrowser('mml'); $this->_mobile = true; } } } /** * Match the platform of the browser. * * This is a pretty simplistic implementation, but it's intended * to let us tell what line breaks to send, so it's good enough * for its purpose. * * @return void * * @since 11.1 */ protected function _setPlatform() { if (strpos($this->_lowerAgent, 'wind') !== false) { $this->_platform = 'win'; } elseif (strpos($this->_lowerAgent, 'mac') !== false) { $this->_platform = 'mac'; } else { $this->_platform = 'unix'; } } /** * Return the currently matched platform. * * @return string The user's platform. * * @since 11.1 */ public function getPlatform() { return $this->_platform; } /** * Set browser version, not by engine version * Fallback to use when no other method identify the engine version * * @return void */ protected function identifyBrowserVersion() { if (preg_match('|Version[/ ]([0-9.]+)|', $this->_agent, $version)) { list ($this->_majorVersion, $this->_minorVersion) = explode('.', $version[1]); return; } // Can't identify browser version $this->_majorVersion = 0; $this->_minorVersion = 0; JLog::add("Can't identify browser version. Agent: " . $this->_agent, JLog::NOTICE); } /** * Sets the current browser. * * @param string $browser The browser to set as current. * * @return void * * @since 11.1 */ public function setBrowser($browser) { $this->_browser = $browser; } /** * Retrieve the current browser. * * @return string The current browser. * * @since 11.1 */ public function getBrowser() { return $this->_browser; } /** * Retrieve the current browser's major version. * * @return integer The current browser's major version * * @since 11.1. */ public function getMajor() { return $this->_majorVersion; } /** * Retrieve the current browser's minor version. * * @return integer The current browser's minor version. * * @since 11.1 */ public function getMinor() { return $this->_minorVersion; } /** * Retrieve the current browser's version. * * @return string The current browser's version. * * @since 11.1 */ public function getVersion() { return $this->_majorVersion . '.' . $this->_minorVersion; } /** * Return the full browser agent string. * * @return string The browser agent string * * @since 11.1 */ public function getAgentString() { return $this->_agent; } /** * Returns the server protocol in use on the current server. * * @return string The HTTP server protocol version. * * @since 11.1 */ public function getHTTPProtocol() { if (isset($_SERVER['SERVER_PROTOCOL'])) { if (($pos = strrpos($_SERVER['SERVER_PROTOCOL'], '/'))) { return substr($_SERVER['SERVER_PROTOCOL'], $pos + 1); } } return null; } /** * Set unique behavior for the current browser. * * @param string $quirk The behavior to set. * @param string $value Special behavior parameter. * * @return void * * @since 11.1 * @deprecated 12.1 This function will be dropped without replacement */ private function _setQuirk($quirk, $value = true) { $this->_quirks[$quirk] = $value; } /** * Internal copy of JBrowser::setQuirk() to prevent deprecation warning. * * @param string $quirk The behavior to set. * @param string $value Special behavior parameter. * * @return void * * @since 11.1 * @deprecated 12.1 This function will be dropped without replacement */ public function setQuirk($quirk, $value = true) { JLog::add('JBrowser::setQuirk() is deprecated.', JLog::WARNING, 'deprecated'); $this->_quirks[$quirk] = $value; } /** * Check unique behavior for the current browser. * * @param string $quirk The behavior to check. * * @return boolean Does the browser have the behavior set? * * @since 11.1 * @deprecated 12.1 This function will be dropped without replacement */ public function hasQuirk($quirk) { JLog::add('JBrowser::hasQuirk() is deprecated.', JLog::WARNING, 'deprecated'); return !empty($this->_quirks[$quirk]); } /** * Retrieve unique behavior for the current browser. * * @param string $quirk The behavior to retrieve. * * @return string The value for the requested behavior. * * @since 11.1 * @deprecated 12.1 This function will be dropped without replacement */ public function getQuirk($quirk) { JLog::add('JBrowser::getQuirk() is deprecated.', JLog::WARNING, 'deprecated'); return isset($this->_quirks[$quirk]) ? $this->_quirks[$quirk] : null; } /** * Internal copy of JBrowser::setFeature() to prevent deprecation warning. * * @param string $feature The capability to set. * @param string $value Special capability parameter. * * @return void * * @since 11.4 * @deprecated 12.1 This function will be dropped without replacement */ private function _setFeature($feature, $value = true) { $this->_features[$feature] = $value; } /** * Set capabilities for the current browser. * * @param string $feature The capability to set. * @param string $value Special capability parameter. * * @return void * * @since 11.1 * @deprecated 12.1 This function will be dropped without replacement */ public function setFeature($feature, $value = true) { JLog::add('JBrowser::setFeature() is deprecated.', JLog::WARNING, 'deprecated'); $this->_features[$feature] = $value; } /** * Check the current browser capabilities. * * @param string $feature The capability to check. * * @return boolean Does the browser have the capability set? * * @since 11.1 * @deprecated 12.1 This function will be dropped without replacement */ public function hasFeature($feature) { JLog::add('JBrowser::hasFeature() is deprecated.', JLog::WARNING, 'deprecated'); return !empty($this->_features[$feature]); } /** * Retrieve the current browser capability. * * @param string $feature The capability to retrieve. * * @return string The value of the requested capability. * * @since 11.1 * @deprecated 12.1 This function will be dropped without replacement */ public function getFeature($feature) { JLog::add('JBrowser::getFeature() is deprecated.', JLog::WARNING, 'deprecated'); return isset($this->_features[$feature]) ? $this->_features[$feature] : null; } /** * Determines if a browser can display a given MIME type. * * Note that image/jpeg and image/pjpeg *appear* to be the same * entity, but Mozilla doesn't seem to want to accept the latter. * For our purposes, we will treat them the same. * * @param string $mimetype The MIME type to check. * * @return boolean True if the browser can display the MIME type. * * @since 11.1 */ public function isViewable($mimetype) { $mimetype = strtolower($mimetype); list ($type, $subtype) = explode('/', $mimetype); if (!empty($this->_accept)) { $wildcard_match = false; if (strpos($this->_accept, $mimetype) !== false) { return true; } if (strpos($this->_accept, '*/*') !== false) { $wildcard_match = true; if ($type != 'image') { return true; } } // Deal with Mozilla pjpeg/jpeg issue if ($this->isBrowser('mozilla') && ($mimetype == 'image/pjpeg') && (strpos($this->_accept, 'image/jpeg') !== false)) { return true; } if (!$wildcard_match) { return false; } } if (!$this->hasFeature('images') || ($type != 'image')) { return false; } return (in_array($subtype, $this->_images)); } /** * Determine if the given browser is the same as the current. * * @param string $browser The browser to check. * * @return boolean Is the given browser the same as the current? * * @since 11.1 */ public function isBrowser($browser) { return ($this->_browser === $browser); } /** * Determines if the browser is a robot or not. * * @return boolean True if browser is a known robot. * * @since 11.1 */ public function isRobot() { foreach ($this->_robots as $robot) { if (strpos($this->_agent, $robot) !== false) { return true; } } return false; } /** * Determines if the browser is mobile version or not. * * @return boolean True if browser is a known mobile version. * * @since 11.1 */ public function isMobile() { return $this->_mobile; } /** * Determine if we are using a secure (SSL) connection. * * @return boolean True if using SSL, false if not. * * @since 11.1 */ public function isSSLConnection() { return ((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) || getenv('SSL_PROTOCOL_VERSION')); } } .htaccess000066600000000177151372637270006370 0ustar00 Order allow,deny Deny from all