Your IP : 216.73.217.68


Current Path : /home/w/u/e/wuectly/www/03cbe/
Upload File :
Current File : /home/w/u/e/wuectly/www/03cbe/filter.tar

LICENSE000060400000042630152456111010005546 0ustar00GNU 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.
src/InputFilter.php000060400000073420152456111010010307 0ustar00<?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  Use the `InputFilter::ONLY_ALLOW_DEFINED_TAGS` constant instead
	 */
	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  Use the `InputFilter::ONLY_BLOCK_DEFINED_TAGS` constant instead
	 */
	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  Use the `InputFilter::ONLY_ALLOW_DEFINED_ATTRIBUTES` constant instead
	 */
	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  Use the `InputFilter::ONLY_BLOCK_DEFINED_ATTRIBUTES` constant instead
	 */
	const ATTR_BLACKLIST = 1;

	/**
	 * Defines the InputFilter instance should only allow the supplied list of HTML tags.
	 *
	 * @var    integer
	 * @since  1.4.0
	 */
	const ONLY_ALLOW_DEFINED_TAGS = 0;

	/**
	 * Defines the InputFilter instance should block the defined list of HTML tags and allow all others.
	 *
	 * @var    integer
	 * @since  1.4.0
	 */
	const ONLY_BLOCK_DEFINED_TAGS = 1;

	/**
	 * Defines the InputFilter instance should only allow the supplied list of attributes.
	 *
	 * @var    integer
	 * @since  1.4.0
	 */
	const ONLY_ALLOW_DEFINED_ATTRIBUTES = 0;

	/**
	 * Defines the InputFilter instance should block the defined list of attributes and allow all others.
	 *
	 * @var    integer
	 * @since  1.4.0
	 */
	const ONLY_BLOCK_DEFINED_ATTRIBUTES = 1;

	/**
	 * A container for InputFilter instances.
	 *
	 * @var    InputFilter[]
	 * @since  1.0
	 * @deprecated  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 the blocked tags for the instance.
	 *
	 * @var    string[]
	 * @since  1.0
	 * @note   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 blocked tag attributes for the instance.
	 *
	 * @var    string[]
	 * @since  1.0
	 * @note   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 characters.
	 *
	 * @var    string[]
	 * @since  1.3.3
	 */
	private $blockedChars = array(
		'&tab;',
		'&space;',
		'&colon;',
		'&column;',
	);

	/**
	 * Constructor for InputFilter class.
	 *
	 * @param   array    $tagsArray   List of permitted HTML tags
	 * @param   array    $attrArray   List of permitted HTML tag attributes
	 * @param   integer  $tagsMethod  Method for filtering tags, should be one of the `ONLY_*_DEFINED_TAGS` constants
	 * @param   integer  $attrMethod  Method for filtering attributes, should be one of the `ONLY_*_DEFINED_ATTRIBUTES` constants
	 * @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::ONLY_ALLOW_DEFINED_TAGS,
		$attrMethod = self::ONLY_ALLOW_DEFINED_ATTRIBUTES, $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;
	}

	/**
	 * Cleans the given input source based on the instance configuration and specified data type
	 *
	 * @param   string|string[]|object  $source  Input string/array-of-string/object to be 'cleaned'
	 * @param   string                  $type    The return type for the variable:
	 *                                           INT:       An integer
	 *                                           UINT:      An unsigned integer
	 *                                           FLOAT:     A floating point number
	 *                                           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
	 *                                           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 the `$source` parameter
	 *
	 * @since   1.0
	 */
	public function clean($source, $type = 'string')
	{
		$type = ucfirst(strtolower($type));

		if ($type === 'Array')
		{
			return (array) $source;
		}

		if ($type === 'Raw')
		{
			return $source;
		}

		if (\is_array($source))
		{
			$result = array();

			foreach ($source as $key => $value)
			{
				$result[$key] = $this->clean($value, $type);
			}

			return $result;
		}

		if (\is_object($source))
		{
			foreach (get_object_vars($source) as $key => $value)
			{
				$source->$key = $this->clean($value, $type);
			}

			return $source;
		}

		$method = 'clean' . $type;

		if (method_exists($this, $method))
		{
			return $this->$method((string) $source);
		}

		// Unknown filter method
		if (\is_string($source) && !empty($source))
		{
			// Filter source for XSS and other 'bad' code etc.
			return $this->cleanString($source);
		}

		// Not an array or string... return the passed parameter
		return $source;
	}

	/**
	 * 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)(?::|&colon;|&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 disallowed 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, 1, $tagOpenNested);
				$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 disallowed 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('&lt;', '&quot;', '&gt;');

		// 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;
	}

	/**
	 * Integer filter
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  integer  The filtered value
	 */
	private function cleanInt($source)
	{
		$pattern = '/[-+]?[0-9]+/';

		preg_match($pattern, $source, $matches);

		return isset($matches[0]) ? (int) $matches[0] : 0;
	}

	/**
	 * Alias for cleanInt()
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  integer  The filtered value
	 */
	private function cleanInteger($source)
	{
		return $this->cleanInt($source);
	}

	/**
	 * Unsigned integer filter
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  integer  The filtered value
	 */
	private function cleanUint($source)
	{
		$pattern = '/[-+]?[0-9]+/';

		preg_match($pattern, $source, $matches);

		return isset($matches[0]) ? abs((int) $matches[0]) : 0;
	}

	/**
	 * Float filter
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  float  The filtered value
	 */
	private function cleanFloat($source)
	{
		$pattern = '/[-+]?[0-9]+(\.[0-9]+)?([eE][-+]?[0-9]+)?/';

		preg_match($pattern, $source, $matches);

		return isset($matches[0]) ? (float) $matches[0] : 0.0;
	}

	/**
	 * Alias for cleanFloat()
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  float  The filtered value
	 */
	private function cleanDouble($source)
	{
		return $this->cleanFloat($source);
	}

	/**
	 * Boolean filter
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  boolean  The filtered value
	 */
	private function cleanBool($source)
	{
		return (bool) $source;
	}

	/**
	 * Alias for cleanBool()
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  boolean  The filtered value
	 */
	private function cleanBoolean($source)
	{
		return $this->cleanBool($source);
	}

	/**
	 * Word filter
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  string  The filtered string
	 */
	private function cleanWord($source)
	{
		$pattern = '/[^A-Z_]/i';

		return preg_replace($pattern, '', $source);
	}

	/**
	 * Alphanumerical filter
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  string  The filtered string
	 */
	private function cleanAlnum($source)
	{
		$pattern = '/[^A-Z0-9]/i';

		return preg_replace($pattern, '', $source);
	}

	/**
	 * Command filter
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  string  The filtered string
	 */
	private function cleanCmd($source)
	{
		$pattern = '/[^A-Z0-9_\.-]/i';

		$result = preg_replace($pattern, '', $source);
		$result = ltrim($result, '.');

		return $result;
	}

	/**
	 * Base64 filter
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  string  The filtered string
	 */
	private function cleanBase64($source)
	{
		$pattern = '/[^A-Z0-9\/+=]/i';

		return preg_replace($pattern, '', $source);
	}

	/**
	 * String filter
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  string  The filtered string
	 */
	private function cleanString($source)
	{
		return $this->remove($this->decode($source));
	}

	/**
	 * HTML filter
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  string  The filtered string
	 */
	private function cleanHtml($source)
	{
		return $this->remove($source);
	}

	/**
	 * Path filter
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  string  The filtered string
	 */
	private function cleanPath($source)
	{
		// Linux and other Unixoids
		$filePattern          = '(?:[^\x00\/:*?]{1,255})';
		$pathSeparatorPattern = '(?:\/+)';
		$rootPattern          = '(?:\/)';

		if ($this->pathMatches($source, $rootPattern, $pathSeparatorPattern, $filePattern, '/'))
		{
			return $source;
		}

		// Windows
		$filePattern          = '(?:[^\x00\\\\\/:*"?<>|]{1,255})';
		$pathSeparatorPattern = '(?:[\\\\\/])';
		$rootPattern          = '(?:[A-Za-z]:(\\\\|\/))';

		if ($this->pathMatches($source, $rootPattern, $pathSeparatorPattern, $filePattern, '\\'))
		{
			return $source;
		}

		return '';
	}

	/**
	 * Fix a path, if and only if it matches the provided patterns.
	 *
	 * If a path matches but is longer than 4095 bytes, it is cleared.
	 *
	 * @param   string  $source                The path as provided; it gets cleaned in place, if possible.
	 * @param   string  $rootPattern           The pattern to identify an absolute path (e.g., '/' on Linux, 'C:\' on Windows),
	 * @param   string  $pathSeparatorPattern  The pattern for valid path separators
	 * @param   string  $filePattern           The pattern for valid file and directory names
	 * @param   string  $pathSeparator         The native path separator
	 *
	 * @return boolean
	 */
	private function pathMatches(&$source, $rootPattern, $pathSeparatorPattern, $filePattern, $pathSeparator)
	{
		$pathPattern = "/^{$rootPattern}?(?:{$filePattern}{$pathSeparatorPattern})*{$filePattern}?$/u";

		if (preg_match($pathPattern, $source))
		{
			$source = preg_replace("/{$pathSeparatorPattern}/", $pathSeparator, $source);

			if (strlen($source) > 4095)
			{
				// Path is too long
				$source = '';
			}

			return true;
		}

		return false;
	}

	/**
	 * Trim filter
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  string  The filtered string
	 */
	private function cleanTrim($source)
	{
		$result = trim($source);
		$result = StringHelper::trim($result, \chr(0xE3) . \chr(0x80) . \chr(0x80));
		$result = StringHelper::trim($result, \chr(0xC2) . \chr(0xA0));

		return $result;
	}

	/**
	 * Username filter
	 *
	 * @param   string  $source  The string to be filtered
	 *
	 * @return  string  The filtered string
	 */
	private function cleanUsername($source)
	{
		$pattern = '/[\x00-\x1F\x7F<>"\'%&]/';

		return preg_replace($pattern, '', $source);
	}
}
src/OutputFilter.php000060400000013211152456111010010500 0ustar00<?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 is a class for processing an output string for "safe" display
 *
 * @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');
			}
		}
	}

	/**
	 * Makes a string safe for XHTML output by escaping ampersands in links.
	 *
	 * @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;)#', '&amp;', $m[0]);
			},
			$input
		);
	}

	/**
	 * Generates a URL safe version of the specified string with language transliteration.
	 *
	 * 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 lowercased.
	 *
	 * @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;
	}

	/**
	 * Generates a URL safe version of the specified string with unicode character replacement.
	 *
	 * @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;
	}

	/**
	 * Makes a string safe for XHTML output by escaping ampersands.
	 *
	 * @param   string  $text  Text to process
	 *
	 * @return  string  Processed string.
	 *
	 * @since   1.0
	 */
	public static function ampReplace($text)
	{
		return preg_replace('/(?<!&)&(?!&|#|[\w]+;)/', '&amp;', $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('/&nbsp;/', ' ', $text);
		$text = preg_replace('/&amp;/', ' ', $text);
		$text = preg_replace('/&quot;/', ' ', $text);
		$text = strip_tags($text);
		$text = htmlspecialchars($text, \ENT_COMPAT, 'UTF-8');

		return $text;
	}

	/**
	 * Strips `<img>` tags from a 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);
	}

	/**
	 * Strips `<iframe>` tags from a 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);
	}
}
output.php000060400000007543152456113460006631 0ustar00<?php
/**
 *------------------------------------------------------------------------------
 *  iC Library - Library by Jooml!C, for Joomla!
 *------------------------------------------------------------------------------
 * @package     iC Library
 * @subpackage  filter
 * @copyright   Copyright (c)2014-2015 Cyril Rezé, Jooml!C - All rights reserved
 *
 * @license     GNU General Public License version 3 or later; see LICENSE.txt
 * @author      Cyril Rezé (Lyr!C)
 * @link        http://www.joomlic.com
 *
 * @version     1.0.0 2014-06-13
 * @since       1.0.0
 *------------------------------------------------------------------------------
*/

// No direct access to this file
defined('_JEXEC') or die();

/**
 * class iCUrl
 */
class iCFilterOutput
{
	/**
	 * Process a string in a JOOMLA_TRANSLATION_STRING standard.
	 * This method processes a string and replaces all accented UTF-8 characters by unaccented
	 * ASCII-7 "equivalents" and the string is uppercase. Spaces replaced by underscore.
	 *
	 * @param   string  $string  String to process
	 *
	 * @return  string  Processed string
	 *
	 * @since   1.0.0
	 */
	public static function stringToJText($string)
	{
		// Remove any '_' from the string since they will be used as concatenaters
		$str = str_replace('_', ' ', $string);

		$lang = JFactory::getLanguage();
		$str = $lang->transliterate($str);

		// Trim white spaces at beginning and end of translation string and make uppercase
		$str = trim(JString::strtoupper($str));

		// Remove any duplicate whitespace, and ensure all characters are alphanumeric
		$str = preg_replace('/(\s|[^A-Za-z0-9\-])+/', '_', $str);

		// Trim underscores at beginning and end of translation string
		$str = trim($str, '_');

		return $str;
	}

	/**
	 * Process a string in slug format.
	 * This method processes a string and replaces all accented UTF-8 characters by unaccented
	 * ASCII-7 "equivalents" and the string is lowercase. Spaces replaced by underscore.
	 *
	 * @param   string  $string  String to process
	 *
	 * @return  string  Processed string
	 *
	 * @since   1.0.0
	 */
	public static function stringToSlug($string)
	{
		// Remove any '_' from the string since they will be used as concatenaters
		$replace = array('-', '_');
		$str = str_replace($replace, ' ', $string);

		//replaces all accented UTF-8 characters by unaccented ASCII-7 "equivalents"
		$lang = JFactory::getLanguage();
		$str = $lang->transliterate($str);

		// Trim white spaces at beginning and end of translation string and make uppercase
		$str = trim(JString::strtolower($str));

		// Remove any duplicate whitespace, and ensure all characters are alphanumeric
		$str = preg_replace('/(\s|[^A-Za-z0-9\-])+/', '_', $str);

		// Trim underscores at beginning and end of translation string
		$str = trim($str, '_');

		return $str;
	}

	/**
	 * Convert a HTML string in a text single line.
	 * This method processes a string, cleans all HTML tags and converts special characters to HTML entities.
	 * The string is lowercase. Spaces replaced by underscore.
	 *
	 * @param   string  $string  String to process
	 *
	 * @return  string  Processed string
	 *
	 * @since   1.0.0
	 */
	static public function fullCleanHTML($string)
	{
		// Clean text of all formatting and scripting code
		$str = preg_replace("'<script[^>]*>.*?</script>'si", '', $string);
		$str = preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is', '\2 (\1)', $str);
		$str = preg_replace('/<!--.+?-->/', '', $str);
		$str = preg_replace('/{.+?}/', '', $str);

		// Strip HTML and PHP tags
		$str	= strip_tags($str);

		// Replace all sequences of two or more spaces, tabs, and/or line breaks with a single space
		$str	= preg_replace('/[\p{Z}\s]{2,}/u', ' ', $str);

		// Convert special characters to HTML entities
		$str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8');

		// Trim spaces at beginning and end of translation string
		$str	= trim($str);

		return $str;
	}
}
index.html000060400000000054152456113460006543 0ustar00<html><body bgcolor="#FFFFFF"></body></html>tmpl/edit.php000060400000006727152456531450007200 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_finder
 *
 * @copyright   (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

JHtml::_('behavior.formvalidator');
JHtml::_('behavior.keepalive');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.tabstate');

JFactory::getDocument()->addScriptDeclaration('
	Joomla.submitbutton = function(task)
	{
		if (task == "filter.cancel" || document.formvalidator.isValid(document.getElementById("adminForm")))
		{
			Joomla.submitform(task, document.getElementById("adminForm"));
		}
	};

	jQuery(document).ready(function($) {
		$("#rightbtn").on("click", function() {
			if($(this).text() == "' . JText::_('COM_FINDER_FILTER_SHOW_ALL') . '") {
				$(".collapse:not(.in)").each(function (index) {
					$(this).collapse("toggle");
				});
				$(this).text("' . JText::_('COM_FINDER_FILTER_HIDE_ALL') . '");
			} else {
				$(this).text("' . JText::_('COM_FINDER_FILTER_SHOW_ALL') . '");
				$(".collapse.in").each(function (index) {
				$(this).collapse("toggle");
			});
		}
		return false;
		});

		$(".filter-node").change(function() {
			$(\'input[id="jform_map_count"]\').val(document.querySelectorAll(\'input[type="checkbox"]:checked\').length);
		});


	});
');

JFactory::getDocument()->addStyleDeclaration('
	.accordion-inner .control-group .controls {
		margin-left: 10px;
	}
	.accordion-inner > .control-group {
		margin-bottom: 0;
	}
	');
?>

<form action="<?php echo JRoute::_('index.php?option=com_finder&view=filter&layout=edit&filter_id=' . (int) $this->item->filter_id); ?>" method="post" name="adminForm" id="adminForm" class="form-validate">

	<?php echo JLayoutHelper::render('joomla.edit.title_alias', $this); ?>

	<div class="form-horizontal">
		<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?>

		<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', JText::_('COM_FINDER_EDIT_FILTER')); ?>
		<div class="row-fluid">
			<div class="span9">
				<?php if ($this->total > 0) : ?>
					<div class="well">
						<?php echo $this->form->renderField('map_count'); ?>
					</div>
					<button class="btn jform-rightbtn" type="button" onclick="jQuery('.filter-node').each(function () { this.click(); });">
						<span class="icon-checkbox-partial" aria-hidden="true"></span> <?php echo JText::_('JGLOBAL_SELECTION_INVERT'); ?></button>

					<button class="btn pull-right" type="button" id="rightbtn" ><?php echo JText::_('COM_FINDER_FILTER_SHOW_ALL'); ?></button>
					<hr>
				<?php endif; ?>

				<?php echo JHtml::_('filter.slider', array('selected_nodes' => $this->filter->data)); ?>
			</div>
			<div class="span3">
				<?php echo JLayoutHelper::render('joomla.edit.global', $this); ?>
			</div>
		</div>
		<?php echo JHtml::_('bootstrap.endTab'); ?>

		<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'publishing', JText::_('JGLOBAL_FIELDSET_PUBLISHING')); ?>
		<div class="row-fluid form-horizontal-desktop">
			<?php echo JLayoutHelper::render('joomla.edit.publishingdata', $this); ?>
		</div>
		<?php echo JHtml::_('bootstrap.endTab'); ?>

		<?php echo JLayoutHelper::render('joomla.edit.params', $this); ?>

		<?php echo JHtml::_('bootstrap.endTabSet'); ?>
	</div>

	<input type="hidden" name="task" value="" />
	<input type="hidden" name="return" value="<?php echo JFactory::getApplication()->input->get('return', '', 'BASE64'); ?>" />
	<?php echo JHtml::_('form.token'); ?>
</form>
view.html.php000060400000031521152456531450007202 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><?php

class FilterViewFilter extends acymailingView{

	var $chosen = false;

	function display($tpl = null){
		$function = $this->getLayout();
		if(method_exists($this, $function)) $this->$function();

		parent::display($tpl);
	}

	function form(){

		$config = acymailing_config();
		$pageInfo = new stdClass();
		$pageInfo->filter = new stdClass();
		$pageInfo->filter->order = new stdClass();
		$pageInfo->limit = new stdClass();
		$pageInfo->elements = new stdClass();

		$paramBase = ACYMAILING_COMPONENT.'.'.$this->getName();

		$pageInfo->filter->order->value = acymailing_getUserVar($paramBase.".filter_order", 'filter_order', 'name', 'cmd');
		$pageInfo->filter->order->dir = acymailing_getUserVar($paramBase.".filter_order_Dir", 'filter_order_Dir', 'asc', 'word');
		if(strtolower($pageInfo->filter->order->dir) !== 'desc') $pageInfo->filter->order->dir = 'asc';
		$pageInfo->search = acymailing_getUserVar($paramBase.".search", 'search', '', 'string');
		$pageInfo->search = strtolower(trim($pageInfo->search));


		$pageInfo->limit->value = acymailing_getUserVar($paramBase.'.list_limit', 'limit', acymailing_getCMSConfig('list_limit'), 'int');
		$pageInfo->limit->start = acymailing_getUserVar($paramBase.'.limitstart', 'limitstart', 0, 'int');

		if(acymailing_getVar('none', 'task') == 'filterDisplayUsers'){
			$action = array();
			$action['type'] = array(0 => array('displayUsers'));
			$action[] = array('displayUsers' => array());

			$filterClass = acymailing_get('class.filter');
			$filterClass->subid = acymailing_getVar('string', 'subid');
			$filterClass->execute(acymailing_getVar('none', 'filter'), $action, 200000);

			if(!empty($filterClass->report)){
				$this->filteredUsers = $filterClass->report[0];
			}
		}

		$filid = acymailing_getCID('filid');

		$filterClass = acymailing_get('class.filter');
		if(!empty($filid) && acymailing_getVar('cmd', 'task', '') != 'filterDisplayUsers'){
			$filter = $filterClass->get($filid);
		}else{
			$filter = new stdClass();
			$filter->action = acymailing_getVar('none', 'action');
			$filter->filter = acymailing_getVar('none', 'filter');
			$filter->published = 1;
		}

		acymailing_importPlugin('acymailing');

		$typesFilters = array();
		$typesActions = array();

		$outputFilters = implode('', acymailing_trigger('onAcyDisplayFilters', array(&$typesFilters, 'massactions')));
		$outputActions = implode('', acymailing_trigger('onAcyDisplayActions', array(&$typesActions)));

		$typevaluesFilters = array();
		$typevaluesActions = array();
		$typevaluesFilters[] = acymailing_selectOption('', acymailing_translation('FILTER_SELECT'));
		$typevaluesActions[] = acymailing_selectOption('', acymailing_translation('ACTION_SELECT'));
		foreach($typesFilters as $oneType => $oneName){
			$typevaluesFilters[] = acymailing_selectOption($oneType, $oneName);
		}
		foreach($typesActions as $oneType => $oneName){
			$typevaluesActions[] = acymailing_selectOption($oneType, $oneName);
		}

		$js = "function updateAction(actionNum){
				var actiontype = window.document.getElementById('actiontype'+actionNum);
				if(actiontype == 'undefined' || actiontype == null) return;
				currentActionType = actiontype.value;
				if(!currentActionType){
					window.document.getElementById('actionarea_'+actionNum).innerHTML = '';
					return;
				}
				actionArea = 'action__num__'+currentActionType;
				window.document.getElementById('actionarea_'+actionNum).innerHTML = window.document.getElementById(actionArea).innerHTML.replace(/__num__/g,actionNum);
				if(typeof(window['onAcyDisplayAction_'+currentActionType]) == 'function') {
					try{ window['onAcyDisplayAction_'+currentActionType](actionNum); }catch(e){alert('Error in the onAcyDisplayAction_'+currentActionType+' function : '+e); }
				}

			}";

		$js .= "var numActions = 0;
				function addAction(){
					var newdiv = document.createElement('div');
					newdiv.id = 'action'+numActions;
					newdiv.className = 'plugarea';
					newdiv.innerHTML = document.getElementById('actions_original').innerHTML.replace(/__num__/g, numActions);
					var allactions = document.getElementById('allactions');
					if(allactions != 'undefined' && allactions != null){
						allactions.appendChild(newdiv);
						updateAction(numActions);
						numActions++;
						
						if(numActions > 1){
							var del = document.createElement('i');
							del.setAttribute('class', 'acyicon-cancel deleteFilter');
							del.onclick = function(){
								this.parentNode.remove(); 
								return false;
							}
							var num = numActions - 1;
							var sp2 = document.getElementById('actiontype' + num.toString());
							var parentDiv = sp2.parentNode;
							parentDiv.insertBefore(del, sp2.nextSibling);
						}
					}
				}
				";

		$js .= "document.addEventListener(\"DOMContentLoaded\", function(){ addAction(); });";

		$js .= '
			document.addEventListener("DOMContentLoaded", function(){
				acymailing.submitbutton = function(pressbutton) {
					if (pressbutton != \'save\') {
						acymailing.submitform(pressbutton,document.adminForm);
						return;
					}';
		if(ACYMAILING_J30){
			$js .= "if(window.document.getElementById('filterinfo').style.display == 'none'){
						window.document.getElementById('filterinfo').style.display = 'block';
						return false;}
					if(window.document.getElementById('title').value.length < 2){alert('".acymailing_translation('ENTER_TITLE', true)."'); return false;}";
		}else{
			$js .= "if(window.document.getElementById('filterinfo').style.display == 'none'){
						window.document.getElementById('filterinfo').style.display = 'block';
						return false;}
					if(window.document.getElementById('title').value.length < 2){alert('".acymailing_translation('ENTER_TITLE', true)."'); return false;}";
		}
		
		$js .= "
					acymailing.submitform(pressbutton,document.adminForm);
				};
			 }); ";

		acymailing_addScript(true, $js);

		$filterClass->addJSFilterFunctions();

		$js = '';
		$data = array('action', 'filter');

		foreach($data as $datatype){
			if(empty($filter->$datatype)) continue;
			$blockNum = 0;
			$dataNum = 0;
			foreach($filter->{$datatype}['type'] as $block => $oneFilter){
				if($datatype == 'action'){
					$jsFunction = 'addAction();';
				}else{
					$jsFunction = '
						if(!document.getElementById(\'addButton_'.$blockNum.'\')) addOrBlock();
						document.getElementById(\'addButton_'.$blockNum.'\').click();';
				}

				foreach($oneFilter as $num => $oneType) {
					if(empty($oneType)) continue;

					$js .= "
						
						if(!document.getElementById('" . $datatype . "type$dataNum')){
							" . $jsFunction . "
						}
						
						document.getElementById('" . $datatype . "type$dataNum').value = '$oneType';
						update" . ucfirst($datatype) . "($dataNum);";
					if(empty($filter->{$datatype}[$num][$oneType])) continue;

					foreach($filter->{$datatype}[$num][$oneType] as $key => $value) {
						if (is_array($value)) {
							$js .= "try{\r\n";
							foreach ($value as $subkey => $subval) {
								$js .= "document.adminForm.elements['" . $datatype . "[$dataNum][$oneType][$key][$subkey]'].value = '" . addslashes(str_replace(array("\n", "\r"), ' ', $subval)) . "';\r\n";
								$js .= "if(document.adminForm.elements['" . $datatype . "[$dataNum][$oneType][$key][$subkey]'].type && document.adminForm.elements['" . $datatype . "[$dataNum][$oneType][$key][$subkey]'].type == 'checkbox'){
									document.adminForm.elements['" . $datatype . "[$dataNum][$oneType][$key][$subkey]'].checked = 'checked';
								}\r\n";
							}
							$js .= "}catch(e){}";
						}
						$myVal = is_array($value) ? implode(',', $value) : $value;
						$js .= "
						try{
							document.adminForm.elements['" . $datatype . "[$dataNum][$oneType][$key]'].value = '" . addslashes(str_replace(array("\n", "\r"), ' ', $myVal)) . "';
							if(document.adminForm.elements['" . $datatype . "[$dataNum][$oneType][$key]'].type && document.adminForm.elements['" . $datatype . "[$dataNum][$oneType][$key]'].type == 'checkbox'){
								document.adminForm.elements['" . $datatype . "[$dataNum][$oneType][$key]'].checked = 'checked';
							}
						}catch(e){}";
					}

					$js .= "
						if(typeof(onAcyDisplay" . ucfirst($datatype) . "_" . $oneType . ") == 'function'){
							try{
								onAcyDisplay" . ucfirst($datatype) . "_" . $oneType . "($dataNum);
							}catch(e){
								alert('Error in the onAcyDisplay" . ucfirst($datatype) . "_" . $oneType . " function : '+e);
							}
						}";

					if($datatype == 'filter') $js .= " countresults($dataNum);";
					$dataNum++;
				}
				$blockNum++;
			}
		}

		$listid = acymailing_getVar('int', 'listid');
		if(!empty($listid)){
			$js .= "
				document.getElementById('actiontype0').value = 'list';
				updateAction(0);
				document.adminForm.elements['action[0][list][selectedlist]'].value = '".$listid."';";
		}

		acymailing_addScript(true, "document.addEventListener(\"DOMContentLoaded\", function(){ $js });");

		$triggers = array();
		$triggers['daycron'] = acymailing_translation('AUTO_CRON_FILTER');

		if(empty($filter->daycron)){
			$nextDate = $config->get('cron_plugins_next', time());
		}else{
			$nextDate = $filter->daycron;
		}

		$listHours = array();
		$listMinutess = array();
		for($i = 0; $i < 24; $i++){              
			$value = $i < 10 ? '0'.$i : $i;
			$listHours[] = acymailing_selectOption($value, $value);
		}
		$hours = acymailing_select($listHours, 'triggerhours', 'class="inputbox" size="1" style="width:60px;"', 'value', 'text', acymailing_getDate($nextDate, 'H'));
		for($i = 0; $i < 60; $i += 5){          
			$value = $i < 10 ? '0'.$i : $i;
			$listMinutess[] = acymailing_selectOption($value, $value);
		}
		$defaultMin = floor(acymailing_getDate($nextDate, 'i') / 5) * 5;
		$minutes = acymailing_select($listMinutess, 'triggerminutes', 'class="inputbox" size="1" style="width:60px;"', 'value', 'text', $defaultMin);
		$this->hours = $hours;
		$this->minutes = $minutes;

		$this->nextDate = !empty($nextDate) ? ' ('.acymailing_translation('NEXT_RUN').' : '.acymailing_getDate($nextDate, '%d %B %Y  %H:%M').')' : '';

		$triggers['allcron'] = acymailing_translation('ACY_EACH_TIME');
		$triggers['subcreate'] = acymailing_translation('ON_USER_CREATE');
		$triggers['subchange'] = acymailing_translation('ON_USER_CHANGE');
		acymailing_trigger('onAcyDisplayTriggers', array(&$triggers));

		$name = empty($filter->name) ? '' : ' : '.$filter->name;

		if(!acymailing_isNoTemplate()){
			$acyToolbar = acymailing_get('helper.toolbar');
			$acyToolbar->custom('filterDisplayUsers', acymailing_translation('FILTER_VIEW_USERS'), 'user', false, '');
			$acyToolbar->custom('process', acymailing_translation('PROCESS'), 'process', false, '');
			$acyToolbar->divider();
			if(acymailing_level(3)){
				$acyToolbar->save();
				if(!empty($filter->filid)) $acyToolbar->link(acymailing_completeLink('filter&task=edit&filid=0'), acymailing_translation('ACY_NEW'), 'new');
			}
			$acyToolbar->link(acymailing_completeLink('dashboard'), acymailing_translation('ACY_CLOSE'), 'cancel');
			$acyToolbar->divider();
			$acyToolbar->help('filter');
			$acyToolbar->setTitle(acymailing_translation('ACY_MASS_ACTIONS').$name, 'filter&task=edit&filid='.$filid);
			$acyToolbar->display();
		}else{
			acymailing_setPageTitle(acymailing_translation('ACY_MASS_ACTIONS').$name);
		}

		$subid = acymailing_getVar('string', 'subid');
		if(!empty($subid)){
			$subArray = explode(',', trim($subid, ','));
			acymailing_arrayToInteger($subArray);

			$users = acymailing_loadObjectList('SELECT `name`,`email` FROM `#__acymailing_subscriber` WHERE `subid` IN ('.implode(',', $subArray).')');
			if(!empty($users)){
				$this->users = $users;
				$this->subid = $subid;
			}
		}

		$this->typevaluesFilters = $typevaluesFilters;
		$this->typevaluesActions = $typevaluesActions;
		$this->outputFilters = $outputFilters;
		$this->outputActions = $outputActions;
		$this->filter = $filter;
		$this->pageInfo = $pageInfo;

		$this->triggers = $triggers;
		if(acymailing_isNoTemplate()){
			acymailing_addStyle(false, ACYMAILING_CSS.'frontendedition.css?v='.filemtime(ACYMAILING_MEDIA.'css'.DS.'frontendedition.css'));
		}

		if(acymailing_level(3) && !acymailing_isNoTemplate()){
			$query = 'SELECT * FROM '.acymailing_table('filter');

			if(!empty($pageInfo->search)){
				$searchVal = '\'%'.acymailing_getEscaped($pageInfo->search, true).'%\'';
				$query .= ' WHERE LOWER(name) LIKE'.$searchVal;
			}

			if(!empty($pageInfo->filter->order->value) && (($pageInfo->filter->order->value === "name") || ($pageInfo->filter->order->value === "filid"))){
				$query .= ' ORDER BY '.$pageInfo->filter->order->value.' '.$pageInfo->filter->order->dir;
			}

			$filters = acymailing_loadObjectList($query);

			$toggleClass = acymailing_get('helper.toggle');
			$this->toggleClass = $toggleClass;
			$this->filters = $filters;
		}
	}
}
tmpl/index.html000060400000000054152456533140007520 0ustar00<html><body bgcolor="#FFFFFF"></body></html>tmpl/form.php000060400000022745152456533140007212 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><style type="text/css">
	div.plugarea{
		padding: 5px;
	}
</style>
<div id="acy_content">
	<div id="iframedoc"></div>
	<div id="acybase_filters" style="display:none">
		<div id="filters_original">
			<?php echo acymailing_select($this->typevaluesFilters, "filter[type][__block__][__num__]", 'class="inputbox chzn-done" size="1" onchange="updateFilter(__num__);countresults(__num__);"', 'value', 'text', '', 'filtertype__num__'); ?>
			<span id="countresult___num__"></span>

			<div class="acyfilterarea" id="filterarea___num__"></div>
		</div>
		<?php echo $this->outputFilters; ?>
		<div id="actions_original">
			<?php echo acymailing_select($this->typevaluesActions, "action[type][0][__num__]", 'class="inputbox chzn-done" size="1" onchange="updateAction(__num__);"', 'value', 'text', '', 'actiontype__num__'); ?>
			<div class="acyfilterarea" id="actionarea___num__"></div>
		</div>
		<?php echo $this->outputActions; ?>
	</div>
	<?php if(!empty($this->filteredUsers)){ ?>
		<div class="acyblockoptions" id="filteredUsers">
			<span class="acyblocktitle"><?php
				$usersCount = $this->filteredUsers['countTotal'];
				echo acymailing_translation_sprintf('ACY_FILTEREDUSERS', count($this->filteredUsers['users']), $usersCount); ?>
			</span>

			<div id="acyFilteredUsers">
				<table class="acymailing_table" id="filteredUsersTable">
					<thead>
					<tr>
						<th class="title titlenum"><?php echo acymailing_translation('ACY_ID'); ?></th>
						<th class="title titlenum"><?php echo acymailing_translation('JOOMEXT_NAME'); ?></th>
						<th class="title titlenum"><?php echo acymailing_translation('JOOMEXT_EMAIL'); ?></th>
					</tr>
					</thead>
					<tbody>
					<?php
					$k = 0;
					foreach($this->filteredUsers['users'] as $user){
						?>
						<tr class="row<?php echo $k; ?>">
							<td align="center" style="text-align:center"><?php echo $user->subid; ?></td>
							<td align="center" style="text-align:center"><?php echo $user->name; ?></td>
							<td align="center" style="text-align:center"><?php echo '<a href="'.acymailing_completeLink('subscriber&task=edit&subid='.$user->subid).'" target="_blank">'.$user->email.'</a>'; ?></td>
						</tr>
						<?php
						$k = 1 - $k;
					} ?>
					</tbody>
				</table>
			</div>
		</div>
	<?php } ?>
	<form action="<?php echo acymailing_completeLink('filter', acymailing_isNoTemplate()); ?>" method="post" name="adminForm" id="adminForm" autocomplete="off">
		<?php if(acymailing_isNoTemplate()){
			if(empty($this->subid)){
				acymailing_display(acymailing_translation('PLEASE_SELECT_USERS'), 'warning');
				return;
			}
			$acyToolbar = acymailing_get('helper.toolbar');
			$acyToolbar->custom('process', acymailing_translation('PROCESS'), 'process', false);
			$acyToolbar->setTitle(acymailing_translation('ACTIONS'), '');
			$acyToolbar->topfixed = false;
			$acyToolbar->display();

			$subIds = explode(',', $this->subid);
			acymailing_arrayToInteger($subIds);
			$this->subid = implode(',', $subIds);
			?>

			<input type="hidden" name="subid" value="<?php echo $this->subid; ?>"/>
		<?php } ?>
		<div class="acyblockoptions" id="filterinfo" <?php if(empty($this->filter->filid)) echo 'style="display:none"'; ?> >
			<span class="acyblocktitle"><?php echo acymailing_translation('ACY_FILTER'); ?></span>
			<table width="100%" class="paramlist admintable">
				<tr>
					<td class="paramlist_key">
						<label for="title"><?php echo acymailing_translation('ACY_TITLE'); ?></label>
					</td>
					<td class="paramlist_value">
						<input class="inputbox" id="title" type="text" name="data[filter][name]" style="width:250px" value="<?php echo $this->escape(@$this->filter->name); ?>"/>
					</td>
					<td width="50%" rowspan="3" class="acyfiltertriggertitle">
						<span class="acyblocktitle"><?php echo acymailing_translation('AUTO_TRIGGER_FILTER'); ?></span>
						<?php foreach($this->triggers as $key => $triggerName){ ?>
							<?php if(is_object($triggerName)){
								echo $triggerName->name;
								foreach($triggerName->triggers as $subkey => $subTriggerName){ ?>
									<div class="acyautofiltertriggers">
										<input id="trigger_<?php echo $subkey; ?>" type="checkbox" name="trigger[<?php echo $subkey; ?>]" value="1" <?php if(isset($this->filter->trigger[$subkey])) echo 'checked="checked"'; ?> />
										<label for="trigger_<?php echo $subkey; ?>"><?php echo $subTriggerName; ?></label>
									</div>
								<?php }
							}else{ ?>
								<div class="acyautofiltertriggers">
									<input id="trigger_<?php echo $key; ?>" type="checkbox" name="trigger[<?php echo $key; ?>]" value="1" <?php if(isset($this->filter->trigger[$key])) echo 'checked="checked"'; ?> />
									<label for="trigger_<?php echo $key; ?>"><?php echo $triggerName; ?></label><?php echo ($key == 'daycron') ? ' '.$this->hours.' : '.$this->minutes.' '.$this->nextDate : ''; ?>
								</div>
							<?php } ?>
						<?php } ?>
					</td>
				</tr>
				<tr>
					<td class="paramlist_key" valign="top">
						<label for="description"><?php echo acymailing_translation('ACY_DESCRIPTION'); ?></label>
					</td>
					<td class="paramlist_value" valign="top">
						<textarea id="description" style="width:300px;" rows="5" name="data[filter][description]"><?php echo @$this->filter->description; ?></textarea>
					</td>
				</tr>
				<tr>
					<td class="paramlist_key">
						<label for="published"><?php echo acymailing_translation('ACY_PUBLISHED'); ?></label>
					</td>
					<td class="paramlist_value">
						<?php echo acymailing_boolean("data[filter][published]", '', @$this->filter->published); ?>
					</td>
				</tr>
			</table>
		</div>
		<?php if(empty($this->subid)){ ?>
			<div class="acyblockoptions" id="filters_block">
				<span class="acyblocktitle"><?php echo acymailing_translation('ACY_FILTERS'); ?></span>
				<button id="acyorbutton" class="acymailing_button" onclick="addOrBlock();return false;"><?php echo ucfirst(acymailing_translation('ACY_OR')); ?></button>
			</div>
		<?php } ?>
		<div class="acyblockoptions" id="actions_block">
			<span class="acyblocktitle"><?php echo acymailing_translation('ACTIONS'); ?></span>

			<div id="allactions"></div>
			<button class="acymailing_button" onclick="addAction();return false;"><?php echo acymailing_translation('ADD_ACTION'); ?></button>
		</div>

		<div class="clr"></div>

		<input type="hidden" name="filid" value="<?php echo @$this->filter->filid; ?>"/>
		<input type="hidden" name="limitstart" value="0">

		<?php acymailing_formOptions($this->pageInfo->filter->order); ?>
		<!--</form>-->
		<?php if(!empty($this->subid)){ ?>
			<div class="acyblockoptions" id="selectedUsers">
				<span class="acyblocktitle"><?php echo acymailing_translation('USERS'); ?></span>

				<div style="display:none"></div>
				<table class="acymailing_table" cellpadding="1">
					<?php
					$k = 0;
					foreach($this->users as $row){
						?>
						<tr class="<?php echo "row$k"; ?>">
							<td><?php echo $row->name; ?></td>
							<td><?php echo $row->email; ?></td>
						</tr>
						<?php $k = 1 - $k;
					}

					if(count($this->users) >= 10){
						?>
						<tr class="<?php echo "row$k"; ?>">
							<td>...</td>
							<td>...</td>
						</tr>
					<?php } ?>
				</table>
			</div>
		<?php } ?>
		<?php if(!(empty($this->filters) && $this->pageInfo->search == "")){ ?>
			<br/><br/>
			<div class="acyblockoptions" id="existing_filters">
				<span class="acyblocktitle"><?php echo acymailing_translation('EXISTING_FILTERS'); ?></span>
				<table class="acymailing_table_options">
					<tr>
						<td width="100%">
							<?php acymailing_listingsearch($this->pageInfo->search); ?>
						</td>
					</tr>
				</table>
				<table class="acymailing_table" cellpadding="1">
					<thead>
					<tr>
						<th class="title">
							<?php echo acymailing_gridSort(acymailing_translation('ACY_FILTER'), 'name', $this->pageInfo->filter->order->dir, $this->pageInfo->filter->order->value); ?>
						</th>
						<th class="title titletoggle">
							<?php echo acymailing_translation('ACY_PUBLISHED'); ?>
						</th>
						<th class="title titletoggle">
							<?php echo acymailing_translation('ACY_DELETE'); ?>
						</th>
						<th class="title titleid">
							<?php echo acymailing_gridSort(acymailing_translation('ACY_ID'), 'filid', $this->pageInfo->filter->order->dir, $this->pageInfo->filter->order->value); ?>
						</th>
					</tr>
					</thead>
					<tbody>
					<?php
					$k = 0;
					foreach($this->filters as $row){
						$publishedid = 'published_'.$row->filid;
						$id = 'filter_'.$row->filid;
						?>
						<tr class="<?php echo "row$k"; ?>" id="<?php echo $id; ?>">
							<td>
								<?php echo acymailing_tooltip($row->description, $row->name, '', $row->name, acymailing_completeLink('filter&task=edit&filid='.$row->filid)); ?>
							</td>
							<td align="center" style="text-align:center">
								<span id="<?php echo $publishedid ?>" class="loading"><?php echo $this->toggleClass->toggle($publishedid, (int)$row->published, 'filter') ?></span>
							</td>
							<td align="center" style="text-align:center">
								<?php echo $this->toggleClass->delete($id, $row->filid.'_'.$row->filid, 'filter', true); ?>
							</td>
							<td width="1%" align="center">
								<?php echo $row->filid; ?>
							</td>
						</tr>
						<?php
						$k = 1 - $k;
					}
					?>
					</tbody>
				</table>
			</div>
		<?php } ?>
		<div class="clr"></div>
	</form>
</div>
tmpl/load.php000060400000003552152456533140007161 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><?php
acymailing_cmsLoaded();
?>
<table class="adminlist table table-striped table-hover" cellpadding="1">
	<thead>
		<tr>
			<th class="title">
				<?php echo acymailing_translation('ACY_FILTER'); ?>
			</th>
			<th class="title titletoggle">
				<?php echo acymailing_translation('PUBLISHED'); ?>
			</th>
			<th class="title titletoggle" >
				<?php echo acymailing_translation( 'DELETE' ); ?>
			</th>
			<th class="title titleid">
				<?php echo acymailing_translation( 'ACY_ID' ); ?>
			</th>
		</tr>
	</thead>
	<tbody>
		<?php
			$k = 0;
			foreach($this->filters as $row){
				$publishedid = 'published_'.$row->filid;
				$id = 'filter_'.$row->filid;
		?>
			<tr class="<?php echo "row$k"; ?>" id="<?php echo $id; ?>">
				<td style="cursor:pointer" onclick="window.top.location.href = '<?php echo acymailing_completeLink('filter&task=edit&filid='.$row->filid); ?>';">
					<?php
						echo acymailing_tooltip($row->description, $row->name, '', $row->name);
					?>
				</td>
				<td align="center" style="text-align:center" >
						<span id="<?php echo $publishedid ?>" class="loading"><?php echo $this->toggleClass->toggle($publishedid,(int) $row->published,'filter') ?></span>
				</td>
				<td align="center" style="text-align:center" >
					<?php echo $this->toggleClass->delete($id,$row->filid.'_'.$row->filid,'filter',true); ?>
				</td>
				<td width="1%" align="center" style="cursor:pointer" onclick="window.top.location.href = '<?php echo acymailing_completeLink('filter&task=edit&filid='.$row->filid); ?>';">
					<?php echo $row->filid; ?>
				</td>
			</tr>
		<?php
				$k = 1-$k;
			}
		?>
	</tbody>
</table>