Spade

Mini Shell

Directory:~$ /proc/self/root/home/lmsyaran/www/pusher/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ //proc/self/root/home/lmsyaran/www/pusher/models.zip

PKbV�[9S��ooforms/filter_items.xmlnu�[���<?xml
version="1.0" encoding="utf-8"?>
<form>
	<fieldset
addfieldpath="/administrator/components/com_menus/models/fields"
/>
		<field
			name="menutype"
			type="menu"
			label="COM_MENUS_SELECT_MENU_FILTER"
			accesstype="manage"
			clientid=""
			showAll="false"
			filtermode="selector"
			onchange="this.form.submit();"
			>
			<option value="">COM_MENUS_SELECT_MENU</option>
		</field>
		<fields name="filter">
			<field
				name="search"
				type="text"
				inputmode="search"
				label="COM_MENUS_ITEMS_SEARCH_FILTER_LABEL"
				description="COM_MENUS_ITEMS_SEARCH_FILTER"
				hint="JSEARCH_FILTER"
			/>
			<field
				name="published"
				type="status"
				label="COM_MENUS_FILTER_PUBLISHED"
				description="COM_MENUS_FILTER_PUBLISHED_DESC"
				filter="*,0,1,-2"
				onchange="this.form.submit();"
				>
				<option
value="">JOPTION_SELECT_PUBLISHED</option>
			</field>
			<field
				name="access"
				type="accesslevel"
				label="JOPTION_FILTER_ACCESS"
				description="JOPTION_FILTER_ACCESS_DESC"
				onchange="this.form.submit();"
				>
				<option value="">JOPTION_SELECT_ACCESS</option>
			</field>
			<field
				name="language"
				type="contentlanguage"
				label="JOPTION_FILTER_LANGUAGE"
				description="JOPTION_FILTER_LANGUAGE_DESC"
				onchange="this.form.submit();"
				>
				<option value="">JOPTION_SELECT_LANGUAGE</option>
				<option value="*">JALL</option>
			</field>
			<field
				name="level"
				type="integer"
				label="JOPTION_FILTER_LEVEL"
				description="JOPTION_FILTER_LEVEL_DESC"
				first="1"
				last="10"
				step="1"
				languages="*"
				onchange="this.form.submit();"
				>
				<option
value="">JOPTION_SELECT_MAX_LEVELS</option>
			</field>
			<field
				name="parent_id"
				type="MenuItemByType"
				label="COM_MENUS_FILTER_PARENT_MENU_ITEM_LABEL"
				onchange="this.form.submit();"
				>
				<option
value="">COM_MENUS_FILTER_SELECT_PARENT_MENU_ITEM</option>
			</field>
		</fields>
		<fields name="list">
			<field
				name="fullordering"
				type="list"
				label="JGLOBAL_SORT_BY"
				description="JGLOBAL_SORT_BY"
				statuses="*,0,1,2,-2"
				onchange="this.form.submit();"
				default="a.lft ASC"
				validate="options"
				>
				<option value="">JGLOBAL_SORT_BY</option>
				<option value="a.lft
ASC">JGRID_HEADING_ORDERING_ASC</option>
				<option value="a.lft
DESC">JGRID_HEADING_ORDERING_DESC</option>
				<option value="a.published
ASC">JSTATUS_ASC</option>
				<option value="a.published
DESC">JSTATUS_DESC</option>
				<option value="a.title
ASC">JGLOBAL_TITLE_ASC</option>
				<option value="a.title
DESC">JGLOBAL_TITLE_DESC</option>
				<option value="menutype_title
ASC">COM_MENUS_HEADING_MENU_ASC</option>
				<option value="menutype_title
DESC">COM_MENUS_HEADING_MENU_DESC</option>
				<option value="a.home
ASC">COM_MENUS_HEADING_HOME_ASC</option>
				<option value="a.home
DESC">COM_MENUS_HEADING_HOME_DESC</option>
				<option value="a.access
ASC">JGRID_HEADING_ACCESS_ASC</option>
				<option value="a.access
DESC">JGRID_HEADING_ACCESS_DESC</option>
				<option value="association ASC"
requires="associations">JASSOCIATIONS_ASC</option>
				<option value="association DESC"
requires="associations">JASSOCIATIONS_DESC</option>
				<option value="language
ASC">JGRID_HEADING_LANGUAGE_ASC</option>
				<option value="language
DESC">JGRID_HEADING_LANGUAGE_DESC</option>
				<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
				<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
			</field>
			<field
				name="limit"
				type="limitbox"
				label="COM_MENUS_LIST_LIMIT"
				description="COM_MENUS_LIST_LIMIT_DESC"
				class="input-mini"
				default="25"
				onchange="this.form.submit();"
			/>
		</fields>
</form>
PKj��[��~

categories.phpnu�[���<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_contact
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\Registry\Registry;

/**
 * This models supports retrieving lists of contact categories.
 *
 * @since  1.6
 */
class ContactModelCategories extends JModelList
{
	/**
	 * Model context string.
	 *
	 * @var		string
	 */
	public $_context = 'com_contact.categories';

	/**
	 * The category context (allows other extensions to derived from this
model).
	 *
	 * @var		string
	 */
	protected $_extension = 'com_contact';

	private $_parent = null;

	private $_items = null;

	/**
	 * Method to auto-populate the model state.
	 *
	 * Note. Calling getState in this method will result in recursion.
	 *
	 * @param   string  $ordering   An optional ordering field.
	 * @param   string  $direction  An optional direction (asc|desc).
	 *
	 * @return  void
	 *
	 * @since   1.6
	 */
	protected function populateState($ordering = null, $direction = null)
	{
		$app = JFactory::getApplication();
		$this->setState('filter.extension', $this->_extension);

		// Get the parent id if defined.
		$parentId = $app->input->getInt('id');
		$this->setState('filter.parentId', $parentId);

		$params = $app->getParams();
		$this->setState('params', $params);

		$this->setState('filter.published',	1);
		$this->setState('filter.access',	true);
	}

	/**
	 * Method to get a store id based on model configuration state.
	 *
	 * This is necessary because the model is used by the component and
	 * different modules that might need different sets of data or different
	 * ordering requirements.
	 *
	 * @param   string  $id  A prefix for the store id.
	 *
	 * @return  string  A store id.
	 */
	protected function getStoreId($id = '')
	{
		// Compile the store id.
		$id	.= ':' . $this->getState('filter.extension');
		$id	.= ':' . $this->getState('filter.published');
		$id	.= ':' . $this->getState('filter.access');
		$id	.= ':' . $this->getState('filter.parentId');

		return parent::getStoreId($id);
	}

	/**
	 * Redefine the function an add some properties to make the styling more
easy
	 *
	 * @return  mixed  An array of data items on success, false on failure.
	 */
	public function getItems()
	{
		if ($this->_items === null)
		{
			$app = JFactory::getApplication();
			$menu = $app->getMenu();
			$active = $menu->getActive();
			$params = new Registry;

			if ($active)
			{
				$params->loadString($active->params);
			}

			$options = array();
			$options['countItems'] =
$params->get('show_cat_items_cat', 1) ||
!$params->get('show_empty_categories_cat', 0);
			$categories = JCategories::getInstance('Contact', $options);
			$this->_parent =
$categories->get($this->getState('filter.parentId',
'root'));

			if (is_object($this->_parent))
			{
				$this->_items = $this->_parent->getChildren();
			}
			else
			{
				$this->_items = false;
			}
		}

		return $this->_items;
	}

	/**
	 * Gets the id of the parent category for the selected list of categories
	 *
	 * @return   integer  The id of the parent category
	 *
	 * @since    1.6.0
	 */
	public function getParent()
	{
		if (!is_object($this->_parent))
		{
			$this->getItems();
		}

		return $this->_parent;
	}
}
PKj��[���66
extras.phpnu�[���<?php
/**
 * @package	RSMembership!
 * @copyright	(c) 2009 - 2016 RSJoomla!
 * @link		https://www.rsjoomla.com
 * @license	GNU General Public License
http://www.gnu.org/licenses/gpl-3.0.en.html
 */

defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');

class RSMembershipModelExtras extends JModelList
{
	public $_context = 'extras';

	public function getTable($type = 'Extra', $prefix =
'RSMembershipTable', $config = array()) 
	{
		return JTable::getInstance($type, $prefix, $config);
	}

	protected function getListQuery() 
	{
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);
		
		$membership_id =
JFactory::getApplication()->input->get('cid', 0,
'int');

		if ( $membership_id ) 
		{
			$query
				->select('*')
				->from($db->qn('#__rsmembership_membership_extras',
'me'))
				->join('left',
$db->qn('#__rsmembership_extras', 'e').' ON
'.$db->qn('me.extra_id').' =
'.$db->qn('e.id'))
				->where($db->qn('me.membership_id').' =
'.$db->q($membership_id))
				->where($db->qn('e.published').' =
'.$db->q('1'))
				->order($db->qn('e.ordering').' ASC');
		}

		return $query;
	}

	public function getExtraValues($extra_id)
	{
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);

		$query
			->select('*')
			->from($db->qn('#__rsmembership_extra_values'))
			->where($db->qn('published').' =
'.$db->q('1'))
			->where($db->qn('extra_id').' =
'.$db->q($extra_id))
			->order($db->qn('ordering').' ASC');
		$db->setQuery($query);

		return $this->_getList($query);
	}
}PKj��[�#o,,
index.htmlnu�[���<html><body
bgcolor="#FFFFFF"></body></html>PKj��[�m�ש�membership.phpnu�[���<?php
/**
 * @package	RSMembership!
 * @copyright	(c) 2009 - 2016 RSJoomla!
 * @link		https://www.rsjoomla.com
 * @license	GNU General Public License
http://www.gnu.org/licenses/gpl-3.0.en.html
 */

defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');

class RSMembershipModelMembership extends JModelItem
{
	public function __construct()
	{
		parent::__construct();
	}

	public function getItem($pk = null)
	{
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);
		$cid	= JFactory::getApplication()->input->get('cid', 0,
'int');

		$item 	= $this->getTable('Membership',
'RSMembershipTable');
		$item->load($cid);

		$query->select($db->qn('name'))->from($db->qn('#__rsmembership_categories'))->where($db->qn('id').'
= '.$db->q($item->category_id));
		$db->setQuery($query);
		$item->category_name = $db->loadResult();

		if ( $item->use_trial_period ) 
			$item->price = $item->trial_price;

		// disable buy button and out of stock warning
		if ($item->stock == -1) 
		{
			JFactory::getApplication()->enqueueMessage(JText::_('COM_RSMEMBERSHIP_OUT_OF_STOCK'),
'warning');
		}

		return $item;
	}
}PKj��[P��e�e�mymembership.phpnu�[���<?php
/**
 * @package	RSMembership!
 * @copyright	(c) 2009 - 2016 RSJoomla!
 * @link		https://www.rsjoomla.com
 * @license	GNU General Public License
http://www.gnu.org/licenses/gpl-3.0.en.html
 */

defined('_JEXEC') or die('Restricted access');

class RSMembershipModelMymembership extends JModelItem
{
	public 		$_html = '';
	protected 	$_data = null;
	protected 	$_folder = null;
	protected 	$_parents = array();
	protected 	$_extra_parents = array();
	protected 	$_parent = 0;
	protected 	$transaction_id = 0;

	protected 	$context = 'com_rsmembership.mymembership';

	public		$terms;
	
	protected 	$user;
	protected 	$isWindows;
	
	public function __construct()
	{
		parent::__construct();
		jimport('joomla.filesystem.folder');

		// Some workarounds are needed for Windows
		$this->isWindows = DIRECTORY_SEPARATOR == '\\';
		
		// Get logged in user
		$this->user = JFactory::getUser();
		
		$app 	= JFactory::getApplication();
		$jinput = $app->input;
		
		$db 	= JFactory::getDbo();
		$query	= $db->getQuery(true);

		// Not logged in - must redirect to login.
		if ($this->user->guest) {
			$link = base64_encode((string) JUri::getInstance());
			$app->redirect(JRoute::_('index.php?option=com_users&view=login&return='.$link,
false));
		}
		
		// Membership doesn't match - redirect back to My Memberships page.
		if (!$this->_getMembership()) {
			$app = JFactory::getApplication();
			$app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(),
false));
		}

		
		$this->getParentFolders();
		$this->getExtraParentFolders();
		
		// Let's see if the membership is active
		if ($this->_data->status > 0) {
			return;
		}
		
		// let's get the path
		$path = $jinput->get('path', '',
'string');
		if (!empty($path)) 
		{
			$path = explode("|", $path);
			// extract the parent folder's id
			$parent_id = (int) $path[0];

			if (empty($parent_id)) 
				$app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(),
false));

			// extract the path within the parent
			$path = !empty($path[1]) ? $path[1] : '';

			// check where are we looking
			$from = $this->getFrom();
			if ( $from == 'membership' ) 
				$parent = $this->_parents[$parent_id];
			elseif ( $from == 'extra' ) 
				$parent = $this->_extra_parents[$parent_id];

			// check if the parent is within the allowed parents list
			if (empty($parent)) 
				$app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(),
false));

			$this->_parent = $parent_id;

			// compute the full path: parent + path
			$path 	= realpath($parent.'/'.$path);
			$parent = realpath($parent);

			// check if we are trying to access a path that's not within the
parent
			if (strpos($path, $parent) !== 0)
				$app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(),
false));
			
			// let's see if we've requested a download
			$task = $jinput->get('task', '',
'cmd');

			if ($task == 'download')
			{
				// check if path exists and is a file
				if ( is_file($path) ) 
				{
					// check if we need to agree to terms first
					$query
						->select($db->qn('term_id'))
						->from($db->qn('#__rsmembership_files'))
						->where($db->qn('path').' =
'.$db->q($path));
					$db->setQuery($query);
					$term_id = $db->loadResult();

					if ( !empty($term_id) ) 
					{
						$row =
JTable::getInstance('Term','RSMembershipTable');
						$row->load($term_id);
						if (!$row->published)
							$term_id = 0;
					}

					$agree = $jinput->get('agree', '',
'string');
					if (!empty($term_id) && empty($agree))
					{
						$this->terms = $row->description;
					}
					else
					{
						@ob_end_clean();
						$filename = basename($path);
						header("Cache-Control: public, must-revalidate");
						header('Cache-Control: pre-check=0, post-check=0,
max-age=0');
						header("Pragma: no-cache");
						header("Expires: 0"); 
						header("Content-Description: File Transfer");
						header("Expires: Sat, 01 Jan 2000 01:00:00 GMT");
						if (preg_match('#Opera#',
$_SERVER['HTTP_USER_AGENT']))
							header("Content-Type: application/octetstream");
						else
							header("Content-Type: application/octet-stream");

						header("Content-Length: ".(string) filesize($path));
						header('Content-Disposition: attachment;
filename="'.$filename.'"');
						header("Content-Transfer-Encoding: binary\n");
						@readfile($path);
						$row 			=
JTable::getInstance('Log','RSMembershipTable');
						$row->date 		= JFactory::getDate()->toSql();
						$row->user_id 	= $this->user->id;
						$row->path 		= '[DWN] '.$path;
						$row->ip 		= RSMembershipHelper::getIP();
						$row->store();
						exit();
					}
				}
				else
					$app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(),
false));
			}
			else 
			{
				// check if the path exists and is a folder
				if ( is_dir($path) ) 
				{
					$this->_folder = $path;
					if ( substr($this->_folder, -1) == '/' ) 
						$this->_folder = substr($this->_folder, 0, -1);
				}
				else 
					$app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(),
false));
			}
		}
	}

	protected function setNiceName($path, &$element) {
		static $cache;
		if (!is_array($cache)) {
			$db 	= JFactory::getDbo();
			$query 	= $db->getQuery(true);
			
			$query->select('*')
			  ->from($db->qn('#__rsmembership_files'));
			$db->setQuery($query);
			$cache = $db->loadObjectList('path');
		}
		
		if (!empty($cache[$path])) {
			$found					= &$cache[$path];
			$element->name 			= $found->name;
			$element->description 	= $found->description;
			$element->thumb 		= $found->thumb;
			$element->thumb_w 		= $found->thumb_w;
		}
	}

	protected function _getMembership() {
		$id 	= $this->user->id;
		$cid 	= $this->getCid();
		$db 	= JFactory::getDbo();
		$query	= $db->getQuery(true);
		
		$query
			->select('ms.*')
			->select($db->qn('m.name'))
			->select($db->qn('m.term_id'))
			->select($db->qn('m.no_renew'))
			->select($db->qn('m.use_renewal_price'))
			->select($db->qn('m.renewal_price'))
			->select($db->qn('m.price'))
			->from($db->qn('#__rsmembership_membership_subscribers',
'ms'))
			->join('left',
$db->qn('#__rsmembership_memberships', 'm').'
ON '.$db->qn('ms.membership_id').' =
'.$db->qn('m.id'))
			->where($db->qn('ms.id').' =
'.$db->q($cid))
			->where($db->qn('ms.user_id').' =
'.$db->q($id))
			->where($db->qn('m.published').' =
'.$db->q(1));
		$db->setQuery($query);
		$this->_data = $db->loadObject();
		
		if (!$this->_data) {
			return false;
		}
		
		// Filter values
		$this->_data->extras = explode(',',
$this->_data->extras);
		$this->_data->extras = array_filter($this->_data->extras);
		$this->_data->extras = implode(',',
$this->_data->extras);
		
		return true;
	}


	public function getMembershipSubscriber($action_type =
'addextra')
	{
		$app = JFactory::getApplication();
		$user = JFactory::getUser();
		$db = JFactory::getDBO();
		$query = $db->getQuery(true);

		$ids = $this->_getIds($action_type);

		$query
			->select($db->qn('membership_id'))
			->select($db->qn('status'))
			->select($db->qn('extras'))
			->select($db->qn('last_transaction_id'))
			->from($db->qn('#__rsmembership_membership_subscribers'))
			->where($db->qn('user_id') . ' = ' .
$db->q($user->get('id')))
			->where($db->qn('id') . ' = ' .
$db->q($ids->cid));
		$db->setQuery($query);
		$membership = $db->loadObject();

		if (empty($membership)) {
			$app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(),
false));
		}

		if ($check_addextra_upgrade = ($membership->status > 0 &&
($action_type == 'addextra' || $action_type ==
'upgrade')) || $check_renew = ($membership->status == 1
&& $action_type == 'renew'))
		{
			JFactory::getApplication()->enqueueMessage(JText::_('COM_RSMEMBERSHIP_MEMBERSHIP_NOT_'.(isset($check_renew)
? 'EXPIRED' : 'ACTIVE')), 'warning');
			$app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(),
false));
		}

		if ($action_type == 'upgrade') {
			$query->clear();
			$query
				->select('u.*')
				->select($db->qn('mfrom.name', 'fromname'))
				->select($db->qn('mto.name', 'toname'))
				->select($db->qn('mto.term_id'))
				->from($db->qn('#__rsmembership_membership_upgrades',
'u'))
				->join('left',
$db->qn('#__rsmembership_memberships',
'mfrom').' ON '.$db->qn('mfrom.id').'
= '.$db->qn('u.membership_from_id'))
				->join('left',
$db->qn('#__rsmembership_memberships', 'mto').'
ON '.$db->qn('mto.id').' =
'.$db->qn('u.membership_to_id'))
				->where($db->qn('u.membership_from_id').' =
'.$db->q($membership->membership_id))
				->where($db->qn('u.membership_to_id').' =
'.$db->q($ids->to_id))
				->where($db->qn('u.published').' =
'.$db->q(1));
			$db->setQuery($query);
			$return = $db->loadObject();

			if ( empty($return) )
			{
				$app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(),
false));
			} else {
				$this->_data->term_id = $return->term_id;
			}

			return $return;
		}

		$last_transaction_id = $membership->last_transaction_id;

		$query->clear();
		$query
			->select('*')
			->from($db->qn('#__rsmembership_memberships'))
			->where($db->qn('id').' =
'.$db->q($membership->membership_id));

		if ($action_type == 'addextra') {
			$query->where($db->qn('published').' =
'.$db->q(1));
		}

		$db->setQuery($query);
		$membership = $db->loadObject();

		if ($action_type == 'renew') {
			if ( $membership->use_renewal_price )
				$membership->price = $membership->renewal_price;

			if ( $membership->no_renew )
			{
				JFactory::getApplication()->enqueueMessage(JText::_('COM_RSMEMBERSHIP_MEMBERSHIP_CANNOT_RENEW'),
'warning');

				$app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(),
false));
			}
		}

		$membership->last_transaction_id = $last_transaction_id ;
		return $membership;
	}

	public function getSubscriberData()
	{
		$user 	= JFactory::getUser();
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);

		$query
			->select('*')
			->from($db->qn('#__rsmembership_subscribers'))
			->where($db->qn('user_id').' =
'.$db->q($user->get('id')));
		$db->setQuery($query);

		return $db->loadObject();
	}


	public function getBoughtExtras()
	{
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);
		$return = array();

		if (!empty($this->_data->extras))
		{
			$query
				->select($db->qn('id'))
				->select($db->qn('extra_id'))
				->select($db->qn('name'))
				->from($db->qn('#__rsmembership_extra_values'))
				->where($db->qn('id').' IN
('.RSMembershipHelper::quoteImplode($this->_data->extras).')')
				->where($db->qn('published') .' = '.
$db->q('1'))
				->order($db->qn('extra_id').' ASC,
'.$db->qn('ordering').' ASC');
			$db->setQuery($query);
			$extravalues = $db->loadObjectList();

			foreach ( $extravalues as $extravalue ) 
				$return[$extravalue->extra_id][$extravalue->id] =
$extravalue->name;
		}

		return $return;
	}

	public function getExtras($extras_values = false)
	{
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);
		$return = array();

		$query
			->select('e.*')
			->from($db->qn('#__rsmembership_membership_extras',
'me'))
			->join('left',
$db->qn('#__rsmembership_extras', 'e').' ON
'.$db->qn('me.extra_id') .' =
'.$db->qn('e.id'))
			->where($db->qn('me.membership_id').' =
'.$db->q($this->_data->membership_id))
			->where($db->qn('e.published').' =
'.$db->q('1'));

		$db->setQuery($query);
		$extras = $db->loadObjectList();

		foreach ( $extras as $extra )
		{
			$query->clear();
			$query
				->select('*')
				->from($db->qn('#__rsmembership_extra_values'))
				->where($db->qn('extra_id').' =
'.$db->q($extra->id))
				->where($db->qn('published').' =
'.$db->q('1'))
				->order($db->qn('ordering').' ASC');

			if ( !$extras_values  && !empty($this->_data->extras) ) {
				$query->where($db->qn('id') . ' NOT IN (' .
RSMembershipHelper::quoteImplode($this->_data->extras) .
')');
			} else if ($extras_values && !empty($extras_values)) {
				// condition used for the renew process
				$query->where($db->qn('id') . ' IN (' .
RSMembershipHelper::quoteImplode($extras_values) . ')');
			}

			$db->setQuery($query);
			$values = $db->loadObjectList();

			if ( !empty($values) ) {
				foreach ($values as $value) {
					$value->type = $extra->type;
				}
			}
			$return = array_merge($return, $values);
		}

		return $return;
	}

	public function getBoughtExtrasRenew() {
		$extras_purchased = $this->getBoughtExtras();

		if (!empty($extras_purchased)) {
			$extras_values = array();
			foreach ($extras_purchased as $extras_p) {
				$extras_p = array_keys($extras_p);
				foreach ($extras_p as $extra_value_id) {

					$extras_values[] = $extra_value_id;
				}
			}

			return $this->getExtras($extras_values);
		}

		return array();
	}

	public function getSelectedExtra($extra_id)
	{
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);

		$extra_value_id = (int) $extra_id;
		$extra_value 	=
JTable::getInstance('ExtraValue','RSMembershipTable');
		$extra_value->load($extra_value_id);

		$query
			->select('type')
			->from($db->qn('#__rsmembership_extras'))
			->where($db->qn('published').' =
'.$db->q(1))
			->where($db->qn('id').' =
'.$db->q($extra_value->extra_id));
		$db->setQuery($query);
		$extra_value->type = $db->loadResult();

		return $extra_value;
	}

	public function getUpgrades()
	{
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);

		$query
			->select('u.*')
			->select($db->qn('m.name'))
			->from($db->qn('#__rsmembership_membership_upgrades',
'u'))
			->join('left',
$db->qn('#__rsmembership_memberships', 'm').'
ON '.$db->qn('u.membership_to_id').' =
'.$db->qn('m.id'))
			->where($db->qn('u.membership_from_id').' =
'.$db->q($this->_data->membership_id))
			->where($db->qn('m.published').' =
'.$db->q('1'))
			->where($db->qn('u.published').' =
'.$db->q('1'));
		$db->setQuery($query);

		return $db->loadObjectList();
	}

	public function getTerms()
	{
		return $this->terms;
	}

	public function getMembership()
	{
		return $this->_data;
	}

	public function getMembershipTerms()
	{
		if (!empty($this->_data->term_id))
		{
			$row =
JTable::getInstance('Term','RSMembershipTable');
			$row->load($this->_data->term_id);
			if (!$row->published)
				return false;

			return $row;
		}

		return false;
	}

	public function getCid()
	{
		$input = JFactory::getApplication()->input;
		$payment = $input->getCmd('payment', '');
		if (!empty($payment) && $input->getCmd('layout',
'') == 'payment') {
			$action_type = $input->getCmd('action_type',
'');
			$ids = $this->_getIds($action_type);
			$cid = $ids->cid;
		} else {
			$cid = JFactory::getApplication()->input->get('cid', 0,
'int');
		}

		return $cid;
	}

	public function getExtraId(){
		return JFactory::getApplication()->input->get('extra_id',
0, 'int');
	}

	public function getToId()
	{
		return JFactory::getApplication()->input->get('to_id', 0,
'int');
	}

	public function getFrom()
	{
		return JFactory::getApplication()->input->get('from',
'membership', 'word');
	}

	public function getParentFolders()
	{
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);

		// let's see if the membership is active
		if ($this->_data->status > 0)
			return $this->_parents;

		$query
			->select($db->qn('id'))
			->select($db->qn('params', 'path'))
			->from($db->qn('#__rsmembership_membership_shared'))
			->where($db->qn('membership_id').' =
'.$db->q($this->_data->membership_id))
			->where($db->qn('type').' =
'.$db->q('folder'))
			->where($db->qn('published').' =
'.$db->q('1'))
			->order($db->qn('ordering').' ASC');
		$db->setQuery($query);

		$parents = $db->loadObjectList();
		foreach ($parents as $parent) {
			$this->_parents[$parent->id] =
$this->cleanPath($parent->path);
		}
		
		return $this->_parents;
	}

	public function getExtraParentFolders()
	{
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);

		// let's see if the membership is active
		if ($this->_data->status > 0)
			return $this->_extra_parents;

		if (empty($this->_data->extras)) 
			return $this->_extra_parents;

		$query
			->select($db->qn('id'))
			->select($db->qn('params'))
			->from($db->qn('#__rsmembership_extra_value_shared'))
			->where($db->qn('extra_value_id').' IN
('.RSMembershipHelper::quoteImplode($this->_data->extras).')')
			->where($db->qn('type').' =
'.$db->q('folder'))
			->where($db->qn('published').' =
'.$db->q('1'))
			->order($db->qn('ordering').' ASC');
		$db->setQuery($query);

		$parents = $db->loadObjectList();

		foreach ( $parents as $parent ) 
			$this->_extra_parents[$parent->id] =
$this->cleanPath($parent->params);

		return $this->_extra_parents;
	}

	protected function cleanPath($path) {
		$path = realpath($path);
		$path = rtrim($path, '\\/');
		
		if ($this->isWindows) {
			$path = str_replace('\\', '/', $path);
		}
		
		return $path;
	}
	
	public function getFolders()
	{
		$folders 		= array();
		$all_folders 	= array();
		
		// let's see if the membership is active
		if ($this->_data->status > 0)
			return $folders;
		
		// Check if we are not browsing a folder
		if (is_null($this->_folder)) {
			// Show all the folders associated with this membership
			foreach ($this->_parents as $folder) {
				$all_folders[] = (object) array(
					'name' => $folder,
					'from' => 'membership'
				);
			}
			
			// Show all the folders associated with the extra values of this
membership
			foreach ($this->_extra_parents as $folder) {
				$all_folders[] = (object) array(
					'name' => $folder,
					'from' => 'extra'
				);
			}
				
			// We don't need a parent since we have the full path in the
database
			$parent = '';
		} else {
			// Show the folders in the current folder
			$subfolders = JFolder::folders($this->_folder);
			$from		= $this->getFrom();
			foreach ($subfolders as $folder) {
				$all_folders[] = (object) array(
					'name' => $folder,
					'from' => $from
				);
			}
			
			// We need the parent to be set as the current folder
			$parent = $this->_folder.'/';
		}
		
		// prepare our folders
		foreach ($all_folders as $folder) {
			// Membership or extra ?
			$from 	= $folder->from;
			// Get the folder's name
			$folder = $parent.$folder->name;
			// Clean it
			$folder = $this->cleanPath($folder);
			// Set folder name as default
			$name = strrchr($folder, '/');
			if ($name) {
				$name = ltrim($name, '/');
			} else {
				$name = $folder;
			}
			
			$element = (object) array(
				'from' => $from,
				'name' => $name,
				'description',
				'thumb',
				'thumb_w',
				'fullpath'
			);
			
			// Try to find the element name from the db
			// It's a folder so we need to append a slash
			$this->setNiceName($folder.'/', $element);
			
			// Select the array, defaults to memberships.
			$parents = $from == 'extra' ? $this->_extra_parents :
$this->_parents;

			// Let's see if we are browsing the parent
			$pos = array_search($folder, $parents);
			if ($pos !== false) {
				// We are listing the available shared folders so we need the id of the
parent as the path
				$element->fullpath = $pos;
			} else {
				// We are browsing through the parent so we need the subpath along with
the id of the parent
				$element->fullpath =
$this->_parent.'|'.substr_replace($folder, '', 0,
strlen($parents[$this->_parent]) + 1);
			}
			
			$folders[] = $element;
		}
		
		return $folders;
	}
	
	public function getFiles()
	{
		$files = array();
		
		// let's see if the membership is active
		if ($this->_data->status > 0) 
			return $files;

		if (!is_null($this->_folder)) {
			$all_files = JFolder::files($this->_folder);
			$folder	   = $this->cleanPath($this->_folder);
			$from	   = $this->getFrom();
			
			foreach ($all_files as $file) {
				$element = (object) array(
					'from' => $from,
					'name' => $file,
					'description',
					'thumb',
					'thumb_w',
					'fullpath',
					'published' => 1
				);
				
				// Try to find the element name from the db
				$this->setNiceName($folder.'/'.$file, $element);
				
				// Select the array, defaults to memberships.
				$parents = $from == 'extra' ? $this->_extra_parents :
$this->_parents;

				$element->fullpath =
$this->_parent.'|'.substr_replace($folder.'/'.$file,
'', 0, strlen($parents[$this->_parent]) + 1);
				
				$files[] = $element;
			}
		}
		
		return $files;
	}
	
	public function getCurrent() {
		return $this->_folder;
	}

	public function getPrevious() 
	{
		$from 		= $this->getFrom();
		$parents 	= $from == 'extra' ? $this->_extra_parents :
$this->_parents;
		
		if (in_array($this->cleanPath($this->_folder), $parents)) { 
			return '';
		}

		if (!empty($this->_parent)) {
			$parts = explode('/',
$this->cleanPath($this->_folder));
			if (count($parts) > 1) {
				array_pop($parts);
			}
			
			$folder = implode('/', $parts);
			$folder = substr_replace($folder, '', 0,
strlen($parents[$this->_parent]) + 1);

			return $this->_parent.'|'.$folder;
		}

		return false;
	}

	public function cancel() {
		$db 	= JFactory::getDbo();
		$query	= $db->getQuery(true);
		$id  	= $this->user->id;
		$cid 	= $this->getCid();

		$transaction = JTable::getInstance('Transaction',
'RSMembershiptable');
		$transaction->load($this->_data->from_transaction_id);
		
		$membership  = JTable::getInstance('Membership',
'RSMembershiptable');
		$membership->load($this->_data->membership_id);

		$plugins = RSMembership::getPlugins();
		
		// Keep a legacy mode for Authorize.net
		if (in_array($transaction->gateway, $plugins) ||
$transaction->gateway == 'Authorize.Net') {
			$plugin = array_search($transaction->gateway, $plugins);
			if ($plugin === false) {
				$plugin = 'rsmembershipauthorize';
			}
			
			$args = array(
				'plugin' 		=> $plugin,
				'data' 			=> &$this->_data,
				'membership' 	=> $membership,
				'transaction' 	=> &$transaction
			);
			JFactory::getApplication()->triggerEvent('onMembershipCancelPayment',
$args);
		}

		$query->clear();
		$query
			->update($db->qn('#__rsmembership_membership_subscribers'))
			->set($db->qn('status').' =
'.$db->q('3'))
			->where($db->qn('id').' = '.$db->q($cid));
		$db->setQuery($query);
		$db->execute();

		if (!is_array($membership->gid_expire)) 
			$membership->gid_expire = explode(',',
$membership->gid_expire);

		if ( $membership->gid_enable ) {
			RSMembership::updateGid($id, $membership->gid_expire, false,
'remove');
		}

		if ($membership->disable_expired_account)
		{
			list($memberships, $extras) =
RSMembershipHelper::getUserSubscriptions($id);
				if (!$memberships) {
					RSMembership::disableUser($id);
					$app = JFactory::getApplication();
					$app->logout();
				}
		}
	}

	public function getExtra()
	{
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);

		$ids = $this->_getIds();

		$extra_value 	=
JTable::getInstance('ExtraValue','RSMembershipTable');
		$extra_value->load($ids->extra_id);

		$query
			->select('type')
			->from($db->qn('#__rsmembership_extras'))
			->where($db->qn('published').' =
'.$db->q(1))
			->where($db->qn('id').' =
'.$db->q($extra_value->extra_id));
		$db->setQuery($query);
		$extra_value->type = $db->loadResult();

		return $extra_value;
	}

	public function checkBoughtExtra() {
		$ids = $this->_getIds();

		$membership_id 	= $ids->cid;
		$bought_extras 	= $this->getBoughtExtras();
		$current_extra 	= $this->getSelectedExtra($ids->extra_id);

		$app = JFactory::getApplication();

		// check if extra is already purchased
		if (empty($current_extra) || ( $current_extra->type !=
'checkbox' &&
isset($bought_extras[$current_extra->extra_id]) ) ) {
			$app->enqueueMessage(JText::_('COM_RSMEMBERSHIP_ALREADY_BOUGHT_EXTRA'),
'warning');
			// if the error is displayed we need to empty the session
			$this->_emptySession();

			$app->redirect(JRoute::_(RSMembershipRoute::MyMembership($membership_id),
false));
		}
	}

	public function getHtml()
	{
		return $this->_html;
	}

	public function bindId($cid, $extra_id = null, $type =
'addextra')
	{
		$session = JFactory::getSession();
		$session->set($this->context.'.'.$type.'.cid',
$cid);
		if ($extra_id != null && $type == 'addextra') {
			$session->set($this->context . '.' . $type .
'.extra_id', $extra_id);
		} else if ($extra_id != null && $type == 'upgrade') {
			$session->set($this->context . '.' . $type .
'.to_id', $extra_id);
		}
	}

	protected function _getIds($type = 'addextra')
	{
		static $ids;
		if (is_null($ids))
		{
			$session = JFactory::getSession();
			$ids = array();
			$ids['cid'] = (int)$session->get($this->context .
'.'.$type.'.cid', 0);

			if ($type == 'addextra') {
				$ids['extra_id'] = (int)$session->get($this->context .
'.'.$type.'.extra_id', 0);
			}

			if ($type == 'upgrade') {
				$ids['to_id'] = (int)$session->get($this->context .
'.'.$type.'.to_id', 0);
			}

			$ids = (object) $ids;
		}

		return $ids;
	}

	protected function _emptySession($type = 'addextra')
	{
		$session = JFactory::getSession();
		if ($type == 'addextra') {
			$session->set($this->context . '.addextra.extra_id',
null);
		}
		if ($type == 'upgrade') {
			$session->set($this->context . '.upgrade.to_id', null);
		}

		$session->set($this->context .
'.'.$type.'.cid', null);
	}

	// renew/upgrade Specific
	public function storeData($params) {
		$session = JFactory::getSession();
		if (isset($params['id'])) {
			$context = $this->context.'.upgrade.';
			$session->set($context.'id', $params['id']);

			$newcontext = $context.$params['id'].'.';
			$session->set($newcontext.'membership_fields',
$params['membership_fields']);
			$session->set($context.'custom_fields',
$params['custom_fields']);
		} else {
			$session->set($this->context .
'.renew.membership_fields',
$params['membership_fields']);
			$session->set($this->context . '.renew.custom_fields',
$params['custom_fields']);
		}
	}

	public function getSentData($action_type = 'renew') {
		$session = JFactory::getSession();
		$params	 = array();

		if ($action_type == 'upgrade') {
			$params['to_id'] = 0;

			$context = $this->context.'.upgrade.';
			if ($id = $session->get($context.'id')) {
				$params['to_id'] = $id;
			}
			if ($params['to_id']) {
				$newcontext = $context.$params['to_id'].'.';

				if ($membership_fields =
$session->get($newcontext.'membership_fields')) {
					$params['membership_fields'] = $membership_fields;
				}
			}
			if ($custom_fields =
$session->get($context.'custom_fields')) {
				$params['custom_fields'] = $custom_fields;
			}

		} else {
			if ($membership_fields = $session->get($this->context .
'.renew.membership_fields')) {
				$params['membership_fields'] = $membership_fields;
			}
			if ($custom_fields = $session->get($this->context .
'.renew.custom_fields')) {
				$params['custom_fields'] = $custom_fields;
			}
		}
		return $params;
	}

	public function addExtraPayment() {
		$ids = $this->_getIds();

		$this->_emptySession();

		$membership 	= $this->getMembershipSubscriber();
		$extra 			= $this->getExtra();
		$app = JFactory::getApplication();
		$paymentplugin 	= $app->input->get('payment',
'none', 'cmd');

		// check if extra is already purchased (redirects if it is) - we need to
check it here two because it can be accessed by link directly
		$this->checkBoughtExtra();

		// calculate the total price
		$total = $extra->price;

		$user 		= JFactory::getUser();
		$user_id 	= $user->get('id');

		$row 			 =
JTable::getInstance('Transaction','RSMembershipTable');
		$row->user_id 	 = $user_id;
		$row->user_email = $user->get('email');

		$this->_data = new stdClass();
		$this->_data->username 	= $user->get('username');
		$this->_data->name 		= $user->get('name');
		$this->_data->email 	= $user->get('email');
		$this->_data->fields 	=
RSMembershipHelper::getUserFields($user->get('id'));
		$membership_fields 				=
RSMembershipHelper::getTransactionMembershipFields($user->get('id'),
$membership->last_transaction_id);
		if (count($membership_fields)) {
			$this->_data->membership_fields = $membership_fields;
		}

		$row->user_data = serialize($this->_data);

		$row->type = 'addextra';
		$params = array();
		$params[] = 'id='.$ids->cid;
		$params[] = 'membership_id='.$membership->id;
		$params[] = 'extras='.$extra->id;


		$transaction_data = array(
			'extras' => array()
		);

		$transaction_data['extras'][] = (object) array('name'
=> $extra->name, 'price' => $extra->price);
		$transaction_data = json_encode($transaction_data);


		$row->params 			= implode(';', $params); // params,
membership, extras etc
		$row->date 				= JFactory::getDate()->toSql();
		$row->ip 				= RSMembershipHelper::getIP();
		$row->price 			= $total;
		$row->currency 			=
RSMembershipHelper::getConfig('currency');
		$row->hash 				= '';
		$row->gateway 			= $paymentplugin == 'none' ? 'No
Gateway' : RSMembership::getPlugin($paymentplugin);
		$row->status 			= 'pending';
		$row->transaction_data 	= $transaction_data;

		$this->_html = '';

		// trigger the payment plugin
		$delay = false;
		$args  = array(
			'plugin' => $paymentplugin,
			'data' => &$this->_data,
			'extras' => array(),
			'membership' => $membership,
			'transaction' => &$row,
			'html' => &$this->_html
		);

		$returns = $app->triggerEvent('onMembershipPayment',
$args);

		// PHP 5.4 fix...
		if (version_compare(PHP_VERSION, '5.4.0', '>='))
{
			foreach ($returns as $value) {
				if ($value) {
					$this->_html = $value;
				}
			}
		}

		$properties = $row->getProperties();
		$returns = $app->triggerEvent('delayTransactionStoring',
array(array('plugin' => $paymentplugin, 'properties'
=> &$properties, 'delay' => &$delay)));

		// PHP 5.4 fix...
		if (version_compare(PHP_VERSION, '5.4.0', '>='))
{
			foreach ($returns as $value) {
				if ($value) {
					$delay = true;
				}
			}
		}

		// plugin can delay the transaction storing
		if ( !$delay )
		{
			// store the transaction
			$row->store();

			// store the transaction id
			$this->transaction_id = $row->id;

			// finalize the transaction (send emails)
			RSMembership::finalize($this->transaction_id);

			// approve the transaction
			if ( $row->status == 'completed' || ($row->price == 0
&& $membership->activation != 0) )
				RSMembership::approve($this->transaction_id, true);

			if ( $row->price == 0 )
				$app->redirect(JRoute::_(RSMembershipRoute::ThankYou(), false));
		}
	}

	public function renewPayment() {
		$ids = $this->_getIds('renew');

		$this->_emptySession('renew');

		$membership 	= $this->getMembershipSubscriber('renew');
		$extras 		= $this->getBoughtExtrasRenew();
		$app = JFactory::getApplication();
		$paymentplugin 	= $app->input->get('payment',
'none', 'cmd');

		// calculate the total price
		$total 		= 0;
		$total 	   += $membership->price;
		$extras_ids = array();
		foreach ( $extras as $extra ) {
			$total 		 += $extra->price;
			$extras_ids[] = $extra->id;
		}

		$user 		= JFactory::getUser();
		$user_id 	= $user->get('id');

		$row 			 =
JTable::getInstance('Transaction','RSMembershipTable');
		$row->user_id 	 = $user_id;
		$row->user_email = $user->get('email');

		$this->_data = new stdClass();
		$this->_data->username 			= $user->get('username');
		$this->_data->name 				= $user->get('name');
		$this->_data->email 			= $user->get('email');

		$membership_data =  $this->getSentData();

		if (isset($membership_data['custom_fields'])) {
			$this->_data->fields =
$membership_data['custom_fields'];
		}

		if (isset($membership_data['membership_fields'])) {
			$this->_data->membership_fields =
$membership_data['membership_fields'];
		}
		$row->user_data = serialize($this->_data);

		$row->type 	= 'renew';
		$params 	= array();
		$params[] 	= 'id='.$ids->cid;
		$params[] 	= 'membership_id='.$membership->id;
		if ( !empty($extras_ids) ) {
			$params[] = 'extras=' . implode(',', $extras_ids);
		}

		$row->params 	= implode(';', $params); // params,
membership, extras etc
		$row->date 		= JFactory::getDate()->toSql();
		$row->ip 		= RSMembershipHelper::getIP();
		$row->price 	= $total;
		$row->currency 	=
RSMembershipHelper::getConfig('currency');
		$row->hash 		= '';
		$row->gateway 	= $paymentplugin == 'none' ? 'No
Gateway' : RSMembership::getPlugin($paymentplugin);
		$row->status 	= 'pending';

		$this->_html = '';

		// trigger the payment plugin
		$delay = false;
		$args  = array(
			'plugin' => $paymentplugin,
			'data' => &$this->_data,
			'extras' => $extras,
			'membership' => $membership,
			'transaction' => &$row,
			'html' => &$this->_html
		);

		// trigger the payment plugin
		$returns = $app->triggerEvent('onMembershipPayment',
$args);

		// PHP 5.4 fix...
		if (version_compare(PHP_VERSION, '5.4.0', '>='))
{
			foreach ($returns as $value) {
				if ($value) {
					$this->_html = $value;
				}
			}
		}

		$properties = $row->getProperties();
		$returns = $app->triggerEvent('delayTransactionStoring',
array(array('plugin' => $paymentplugin, 'properties'
=> &$properties, 'delay' => &$delay)));

		// PHP 5.4 fix...
		if (version_compare(PHP_VERSION, '5.4.0', '>='))
{
			foreach ($returns as $value) {
				if ($value) {
					$delay = true;
				}
			}
		}

		// plugin can delay the transaction storing
		if ( !$delay )
		{
			// store the transaction
			$row->store();

			// store the transaction id
			$this->transaction_id = $row->id;

			// finalize the transaction (send emails)
			RSMembership::finalize($this->transaction_id);

			// approve the transaction
			if ( $row->status == 'completed' || ($row->price == 0
&& $membership->activation != 0) )
				RSMembership::approve($this->transaction_id, true);

			if ( $row->price == 0 )
				$app->redirect(JRoute::_('index.php?option=com_rsmembership&task=thankyou',
false));
		}
	}

	public function upgradePayment() {
		$ids = $this->_getIds('upgrade');

		$this->_emptySession('upgrade');

		$extras 		= array();
		$upgrade 		= $this->getMembershipSubscriber('upgrade');
		$membership 	=
$this->getMembershipUpgrade($upgrade->membership_to_id);

		$app = JFactory::getApplication();
		$paymentplugin 	= $app->input->get('payment',
'none', 'cmd');

		// calculate the total price
		$total = $upgrade->price;

		$user 	 = JFactory::getUser();
		$user_id = $user->get('id');

		$row =
JTable::getInstance('Transaction','RSMembershipTable');
		$row->user_id = $user_id;
		$row->user_email = $user->get('email');

		$this->_data = new stdClass();
		$this->_data->username 	= $user->get('username');
		$this->_data->name 		= $user->get('name');
		$this->_data->email 	= $user->get('email');

		$membership_data=  $this->getSentData('upgrade');
		if (isset($membership_data['custom_fields'])) {
			$this->_data->fields =
$membership_data['custom_fields'];
		}
		if ($membership_data['to_id'] == $upgrade->membership_to_id
) {
			if (isset($membership_data['membership_fields'])) {
				$this->_data->membership_fields =
$membership_data['membership_fields'];
			}
		}
		$row->user_data 		= serialize($this->_data);

		$row->type = 'upgrade';
		$params = array();
		$params[] = 'id='.$ids->cid;
		$params[] = 'from_id='.$upgrade->membership_from_id;
		$params[] = 'to_id='.$upgrade->membership_to_id;

		$row->params 	= implode(';', $params); // params,
membership, extras etc
		$row->date 		= JFactory::getDate()->toSql();
		$row->ip 		= RSMembershipHelper::getIP();
		$row->price 	= $total;
		$row->currency 	=
RSMembershipHelper::getConfig('currency');
		$row->hash 		= '';
		$row->gateway 	= $paymentplugin == 'none' ? 'No
Gateway' : RSMembership::getPlugin($paymentplugin);
		$row->status 	= 'pending';

		$this->_html = '';

		// trigger the payment plugin
		$delay = false;
		$args  = array(
			'plugin' => $paymentplugin,
			'data' => &$this->_data,
			'extras' => $extras,
			'membership' => $membership,
			'transaction' => &$row,
			'html' => &$this->_html
		);

		$returns = $app->triggerEvent('onMembershipPayment',
$args);

		// PHP 5.4 fix...
		if (version_compare(PHP_VERSION, '5.4.0', '>='))
{
			foreach ($returns as $value) {
				if ($value) {
					$this->_html = $value;
				}
			}
		}

		$properties = $row->getProperties();
		$returns = $app->triggerEvent('delayTransactionStoring',
array(array('plugin' => $paymentplugin, 'properties'
=> &$properties, 'delay' => &$delay)));

		// PHP 5.4 fix...
		if (version_compare(PHP_VERSION, '5.4.0', '>='))
{
			foreach ($returns as $value) {
				if ($value) {
					$delay = true;
				}
			}
		}

		// trigger the payment plugin
		// plugin can delay the transaction storing
		if (!$delay)
		{
			// store the transaction
			$row->store();

			// store the transaction id
			$this->transaction_id = $row->id;

			// finalize the transaction (send emails)
			RSMembership::finalize($this->transaction_id);

			// approve the transaction
			if ( $row->status == 'completed' || ($row->price == 0
&& $membership->activation != 0) )
				RSMembership::approve($this->transaction_id, true);

			if ( $row->price == 0 )
				$app->redirect(JRoute::_('index.php?option=com_rsmembership&task=thankyou',
false));
		}
	}

	public function getMembershipUpgrade ($cid)
	{
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);
		$cid	= (int) $cid;

		$query
			->select('*')
			->from($db->qn('#__rsmembership_memberships'))
			->where($db->qn('published').' =
'.$db->q(1))
			->where($db->qn('id').' = '.$db->q($cid));
		$db->setQuery($query);

		return $db->loadObject();
	}
}PKj��[�Z�+��mymemberships.phpnu�[���<?php
/**
 * @package	RSMembership!
 * @copyright	(c) 2009 - 2016 RSJoomla!
 * @link		https://www.rsjoomla.com
 * @license	GNU General Public License
http://www.gnu.org/licenses/gpl-3.0.en.html
 */

defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');

class RSMembershipModelMymemberships extends JModelList
{
	public $_context = 'com_rsmembership.mymemberships';

	public function __construct($config = array())
	{
		parent::__construct($config);

		$user = JFactory::getUser();
		if ( $user->get('guest') ) 
		{
			$link 		 = JUri::getInstance();
			$link 		 = base64_encode($link);
			$user_option = 'com_users';

			JFactory::getApplication()->redirect('index.php?option='.$user_option.'&view=login&return='.$link);
		}
	}

	public function getTable($type = 'Membership', $prefix =
'RSMembershipTable', $config = array())
	{
		return JTable::getInstance($type, $prefix, $config);
	}

	protected function getListQuery()
	{
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);
		$user 	= JFactory::getUser();
		$cid 	= $user->get('id');

		$query
			->select('u.*, '.$db->qn('m.name'))
			->from($db->qn('#__rsmembership_membership_subscribers',
'u'))
			->join('left',
$db->qn('#__rsmembership_memberships', 'm').'
ON '.$db->qn('u.membership_id').' =
'.$db->qn('m.id'))
			->where($db->qn('user_id').' =
'.$db->q($cid))
			->where($db->qn('m.published').' =
'.$db->q('1'))
			->where($db->qn('u.published').' =
'.$db->q('1'));

		return $query;
	}

	public function getTransactions()
	{
		$user 	= JFactory::getUser();
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);

		$query
			->select('*')
			->from($db->qn('#__rsmembership_transactions'))
			->where($db->qn('user_id').' =
'.$db->q($user->get('id')))
			->where($db->qn('status').' =
'.$db->q('pending'))
			->order($db->qn('date').' DESC');

		return $this->_getList($query);
	}
}PKj��[�y��
�
mytransactions.phpnu�[���<?php
/**
 * @package	RSMembership!
 * @copyright	(c) 2009 - 2016 RSJoomla!
 * @link		https://www.rsjoomla.com
 * @license	GNU General Public License
http://www.gnu.org/licenses/gpl-3.0.en.html
 */

defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');

class RSMembershipModelMytransactions extends JModelList
{
    public $_context = 'com_rsmembership.mytransactions';

    public function __construct($config = array())
    {
        parent::__construct($config);

        $user = JFactory::getUser();
        if ( $user->get('guest') )
        {
            $link 		 = JUri::getInstance();
            $link 		 = base64_encode($link);
            $user_option = 'com_users';

           
JFactory::getApplication()->redirect('index.php?option='.$user_option.'&view=login&return='.$link);
        }
    }

    public function getTable($type = 'Transaction', $prefix =
'RSMembershipTable', $config = array())
    {
        return JTable::getInstance($type, $prefix, $config);
    }

    protected function getListQuery()
    {
        $user 	= JFactory::getUser();
        $db 	= JFactory::getDBO();
        $query	= $db->getQuery(true);

        $query
            ->select('*')
           
->from($db->qn('#__rsmembership_transactions'))
            ->where($db->qn('user_id').' =
'.$db->q($user->get('id')))
            ->order($db->qn('date').' DESC');

        return $query;
    }

    public function getItems(){
        $items = parent::getItems();

        $cache_membership_data = array();

        foreach ($items as $item)
        {
            $membership_id_model = 0;

            $params = RSMembershipHelper::parseParams($item->params);
            switch($item->type)
            {
                case 'new':
                case 'renew':
                case 'addextra':
                    $membership_id_model =
!empty($params['membership_id']) ?
$params['membership_id'] : 0;
                    break;

                case 'upgrade':
                    $membership_id_model =
!empty($params['to_id']) ? $params['to_id'] : 0;
                    break;
            }

            if (!empty($membership_id_model) &&
!isset($cache_membership_data[$membership_id_model]))
            {
                $cache_membership_data[$membership_id_model] =
RSMembership::getMembershipData($membership_id_model);
            }

            if (!empty($membership_id_model))
            {
                $item->membership_data =
$cache_membership_data[$membership_id_model];
            }
            else
            {
                $item->membership_data = false;
            }
        }

        return $items;
    }
}PKj��[3��!
!
rsmembership.phpnu�[���<?php
/**
 * @package	RSMembership!
 * @copyright	(c) 2009 - 2016 RSJoomla!
 * @link		https://www.rsjoomla.com
 * @license	GNU General Public License
http://www.gnu.org/licenses/gpl-3.0.en.html
 */

defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');

class RSMembershipModelRSMembership extends JModelList
{
	public $_context = 'rsmembership';

    public function __construct($config = array()) {
        if (empty($config['filter_fields'])) {
            $config['filter_fields'] = array(
                'm.id', 'm.name', 'c.name',
'price'
            );
        }

        parent::__construct($config);
    }

	public function getTable($type = 'Membership', $prefix =
'RSMembershipTable', $config = array()) 
	{
		return JTable::getInstance($type, $prefix, $config);
	}

	protected function getListQuery() 
	{
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);
		$params = $this->getState($this->context.'.params');

		$query
			->select('COALESCE(`c`.`name`,
'.$db->q('').') AS
'.$db->qn('category_name').', m.*')
			->from($db->qn('#__rsmembership_memberships',
'm'))
			->join('left',
$db->qn('#__rsmembership_categories', 'c').' ON
'.$db->qn('c.id').' =
'.$db->qn('m.category_id'))
			->where($db->qn('m.published').' =
'.$db->q('1'));

		if ( $category = $this->getCategory() )
		{
			$query->where( $db->qn('m.category_id')." =
".$db->q($category->id) );
		}
		else 
		{
			$categories = $params->get('categories', array());
			if ( !is_array($categories) )
				$categories = (array) $categories;

			if ( !empty($categories) ) 
				$query->where($db->qn('m.category_id').'  IN
('.RSMembershipHelper::quoteImplode($categories).')');
		}

        $listOrdering = $this->getState('list.ordering',
'ordering');
		$listDirection 	= $this->getState('list.direction',
'ASC');

		$query->order($db->qn($listOrdering).'
'.$listDirection);

		return $query;
	}

	protected function populateState($ordering = null, $direction = null) 
	{
		if ($active = JFactory::getApplication()->getMenu()->getActive())
        {
            $params = $active->params;
        }
        else
        {
            $params = new JRegistry;
            $params->set('orderby', 'ordering');
            $params->set('orderdir', 'ASC');
        }

        $this->setState($this->context.'.params',
$params);

		parent::populateState($params->get('orderby',
'ordering'), $params->get('orderdir',
'ASC'));
	}

	public function getItems()
	{
		$items = parent::getItems();

		if (!empty($items))
		{
			$pattern =
'#<hr\s+id=("|\')system-readmore("|\')\s*\/*>#i';

			if (is_array($items))
			{
				foreach ( $items as $i => $row )
				{
					if ( $row->use_trial_period ) 
						$items[$i]->price = $row->trial_price;

					if ( preg_match($pattern, $row->description) )
						list($row->description, $fulldescription) = preg_split($pattern,
$row->description, 2);
				}
			}
		}

		return $items;
	}

	public function getCategory()
    {
        $id =
JFactory::getApplication()->input->get('catid', 0,
'int');
        $table = JTable::getInstance('Category',
'RSMembershipTable');
        if ($id)
        {
            $table->load($id);
            return $table;
        }

        return false;
    }
}PKj��[?_BW�h�h
subscribe.phpnu�[���<?php
/**
 * @package	RSMembership!
 * @copyright	(c) 2009 - 2016 RSJoomla!
 * @link		https://www.rsjoomla.com
 * @license	GNU General Public License
http://www.gnu.org/licenses/gpl-3.0.en.html
 */

defined('_JEXEC') or die('Restricted access');

class RSMembershipModelSubscribe extends JModelItem
{	
	protected $db;
	protected $recaptcha_error;
	protected $membership;
	protected $extras = array();
	protected $coupon;
	protected $data;
	
	protected $html;
	
	public function __construct() {
		parent::__construct();
		$this->db = JFactory::getDbo();
	}
	
	public function canSubscribe($user = null) {
		if (!$user) {
			$user = JFactory::getUser();
		}
		
		// If the membership is unique we must ensure that a new subscription is
not allowed
		if ($user->id && $this->membership->unique) {
			$db 			= &$this->db;
			$query			= $db->getQuery(true);
			$subscription 	= JTable::getInstance('Membership_Subscriber',
'RSMembershipTable');
			$keys			= array(
								'user_id' 		=> $user->id,
								'membership_id' => $this->membership->id
							);
			
			if ($subscription->load($keys)) {
				$this->setError(JText::_('COM_RSMEMBERSHIP_ALREADY_SUBSCRIBED'));
				return false;
			}
		}
		
		return true;
	}
	
	public function bindMembership($id) {
		// Can we get the JTable Object?
		$membership = JTable::getInstance('Membership',
'RSMembershipTable');
		$error		= '';
		
		// Does a membership with this ID exist?
		if ($membership && $id && $membership->load($id)) {
			// Is the membership published?
			if ($membership->published) {
				$membership->regular_price  		= $membership->price;
				$membership->regular_period 		= $membership->period;
				$membership->regular_period_type 	= $membership->period_type;
				
				// Adjust the period & price if it's a trial
				if ($membership->use_trial_period) {
					$membership->price 			= $membership->trial_price;
					$membership->period 		= $membership->trial_period;
					$membership->period_type 	= $membership->trial_period_type;
				}

				$membership->initial_price = $membership->price;
				
				$this->membership = $membership;
				// Load a list of extra IDs attached to this membership ID
				$db = JFactory::getDbo();
				$query = $db->getQuery(true);
				$query->select($db->qn('me.extra_id'))
					->from($db->qn('#__rsmembership_membership_extras',
'me'))
					->join('left',
$db->qn('#__rsmembership_extras', 'e').' ON
('.$db->qn('me.extra_id').'='.$db->qn('e.id').')')
					->where($db->qn('me.membership_id').' =
'.$db->q($this->membership->id))
					->where($db->qn('e.published').' =
'.$db->q(1));
				$this->membership->extras =
$db->setQuery($query)->loadColumn();

				
				return true;
			} else {
				$error = 'COM_RSMEMBERSHIP_MEMBERSHIP_NOT_PUBLISHED';
			}
		} elseif (!$id) {
			$error = 'COM_RSMEMBERSHIP_SESSION_EXPIRED';
		} else {
			$error = 'COM_RSMEMBERSHIP_MEMBERSHIP_NOT_EXIST';
		}
		
		$this->setError(JText::_($error));
		return false;
	}
	
	public function bindExtras($extras) {
		// Do we have extras attached to this membership?
		$db 	= &$this->db;
		$query 	= $db->getQuery(true);
		
		// Load a list of extra IDs attached to this membership ID
		if ($membershipExtras = $this->membership->extras) {
			// Load a list of extra value IDs attached to this membership's
extras.
			$query->clear();
			$query->select($db->qn('id'))
				  ->from($db->qn('#__rsmembership_extra_values'))
				  ->where($db->qn('extra_id').' IN
('.RSMembershipHelper::quoteImplode($membershipExtras).')')
				 
->where($db->qn('published').'='.$db->q(1));
			$db->setQuery($query);
			$membershipExtraValues = $db->loadColumn();
			
			foreach ($extras as $extra_id => $values) {
				// Does this extra_id exist in our database
				// and is it attached to this membership ID?
				if (in_array($extra_id, $membershipExtras)) {
					// Convert all values to an array for commodity
					if (!is_array($values)) {
						$values = (array) $values;
					}
					
					foreach ($values as $value) {
						// Does this value exist?
						if (in_array($value, $membershipExtraValues)) {
							$this->extras[] = $value;
						}
					}
				}
			}
		}
	}
	
	// @desc qi = quote & implode
	protected function qi($array) {
		$db = &$this->db;
		foreach ($array as $k => $v) {
			$array[$k] = $db->q($v);
		}
		return implode(',', $array);
	}
	
	public function getMembership() {
		return $this->membership;
	}
	
	public function getExtras() {
		static $list = array();
		if (empty($list) && is_array($this->extras)) {
			foreach ($this->extras as $id) {
				$table = JTable::getInstance('ExtraValue',
'RSMembershipTable');
				$table->load($id);
				
				$list[] = $table;
			}
		}

		return $list;
	}
	
	public function getMembershipTerms() {
		if ($this->membership->term_id) {
			$item = JTable::getInstance('Term',
'RSMembershipTable');
			if ($item && $item->load($this->membership->term_id)
&& $item->published) {
				return $item;
			}
		}
		
		return false;
	}
	
	public function getUseCaptcha() {
		if (!RSMembershipHelper::getConfig('captcha_enabled')) {
			return false;
		}

		$is_logged 			 = !JFactory::getUser()->get('guest');
		$captcha_enabled_for =
RSMembershipHelper::getConfig('captcha_enabled_for');
		
		// If Captcha is enabled for unregistered users
		// or Captcha is enabled for registered users
		if ((!$is_logged && in_array(0, $captcha_enabled_for)) ||
($is_logged && in_array(1, $captcha_enabled_for))) {
			return true;
		}
		
		return false;
	}
	
	public function getUseBuiltin() {
		return (int) RSMembershipHelper::getConfig('captcha_enabled')
=== 1;
	}
	
	public function getUseReCaptcha() {
		return (int) RSMembershipHelper::getConfig('captcha_enabled')
=== 2;
	}
	
	public function getUseReCaptchaNew() {
		return (int) RSMembershipHelper::getConfig('captcha_enabled')
=== 3;
	}
	
	public function getReCaptchaError() {
		return $this->recaptcha_error;
	}
	
	public function validateCaptcha() {
		$builtin 		= $this->getUseBuiltin();
		$recaptcha 		= $this->getUseReCaptcha();
		$recaptcha_new 	= $this->getUseReCaptchaNew();
		$input			= JFactory::getApplication()->input;
		
		if ($this->getUseCaptcha()) {
			if ($builtin) {
				// Load Captcha
				if (!class_exists('JSecurImage')) {
					require_once
JPATH_ADMINISTRATOR.'/components/com_rsmembership/helpers/securimage/securimage.php';
				}
				
				$image = new JSecurImage();
				$code  = $input->get('captcha', '',
'string');
				
				if (!$image->check($code)) {
					$this->setError(JText::_('COM_RSMEMBERSHIP_CAPTCHA_ERROR'));
					return false;
				}
			} elseif ($recaptcha) {
				// Load ReCaptcha
				if (!class_exists('JReCAPTCHA')) {
					require_once
JPATH_ADMINISTRATOR.'/components/com_rsmembership/helpers/recaptcha/recaptchalib.php';
				}
				
				$privatekey =
RSMembershipHelper::getConfig('recaptcha_private_key');
				$challenge	= $input->get('recaptcha_challenge_field',
'', 'string');
				$response	= $input->get('recaptcha_response_field',
'', 'string');
				
				$result = JReCAPTCHA::checkAnswer($privatekey,
JFactory::getApplication()->input->server->getString('REMOTE_ADDR'),
$challenge, $response);
				if (!$result || !$result->is_valid) {
					if ($result) {
						$this->recaptcha_error = $result->error;
					}
					$this->setError(JText::_('COM_RSMEMBERSHIP_CAPTCHA_ERROR'));
					return false;
				}
			} elseif ($recaptcha_new) {
				$response = $input->get('g-recaptcha-response',
'', 'raw');
				$ip		  = $input->server->getString('REMOTE_ADDR');
				$secret	  =
RSMembershipHelper::getConfig('recaptcha_new_secret_key');
				
				try {
					jimport('joomla.http.factory');
					$http = JHttpFactory::getHttp();
					if ($request =
$http->get('https://www.google.com/recaptcha/api/siteverify?secret='.urlencode($secret).'&response='.urlencode($response).'&remoteip='.urlencode($ip)))
{
						$json = json_decode($request->body);
					}
				} catch (Exception $e) {
					$this->setError($e->getMessage());
					return false;
				}
				
				if (empty($json->success) || !$json->success) {					
					if (!empty($json) &&
isset($json->{'error-codes'}) &&
is_array($json->{'error-codes'})) {
						foreach ($json->{'error-codes'} as $code) {
							$this->setError(JText::_('COM_RSMEMBERSHIP_RECAPTCHA_NEW_ERR_'.str_replace('-',
'_', $code)));
							return false;
						}
					}
				}
			}
		}
		
		return true;
	}
	
	public function getHasCoupons() {
		$db 		= &$this->db;
		$query		= $db->getQuery(true);
		$now		= JFactory::getDate()->toSql();
		$membership = $this->getMembership();

		$query->select($db->qn('c.name'))
			 
->select('COUNT('.$db->qn('t.coupon').') AS
'.$db->qn('uses'))
			  ->select($db->qn('c.max_uses'))
			 ->from($db->qn('#__rsmembership_coupons',
'c'))
			 ->join('left',
$db->qn('#__rsmembership_coupon_items', 'ci').'
ON
('.$db->qn('c.id').'='.$db->qn('ci.coupon_id').')')
			 ->join('left',
$db->qn('#__rsmembership_transactions', 't').'
ON
('.$db->qn('c.name').'='.$db->qn('t.coupon').'
AND '.$db->qn('t.coupon').' !=
'.$db->q('').' AND
'.$db->qn('c.max_uses').' >
'.$db->q(0).')')
			
->where('('.$db->qn('ci.membership_id').' =
'.$db->q($membership->id).' OR
'.$db->qn('ci.membership_id').' IS NULL)')
			 ->where('('.$db->qn('c.date_start').' =
'.$db->q($db->getNullDate()).' OR
'.$db->qn('c.date_start').' <
'.$db->q($now).')')
			 ->where('('.$db->qn('c.date_end').' =
'.$db->q($db->getNullDate()).' OR
'.$db->qn('c.date_end').' >
'.$db->q($now).')')
			 ->where($db->qn('c.published').' =
'.$db->q(1))
			 ->group($db->qn('c.name'))
			 ->having('('.$db->qn('max_uses').' >
'.$db->qn('uses'). ' OR
'.$db->qn('max_uses').' =
'.$db->q(0).')');
		$db->setQuery($query);
		
		return $db->loadObject() ? true : false;
	}
	
	public function bindData($data) {
		$membership = $this->getMembership();
		$db		= &$this->db;
		$user 	= JFactory::getUser();
		$guest	= $user->guest;
		
		// Create the empty data
		$this->data = new stdClass();
		
		// Bind username
		if (RSMembershipHelper::getConfig('choose_username')) {
			$username = isset($data['username']) ?
$data['username'] : '';
			
			if ($guest) {
				if (empty($username) || strlen(utf8_decode($username)) < 2) {
					$this->setError(JText::_('COM_RSMEMBERSHIP_PLEASE_TYPE_USERNAME'));
					return false;
				}

				$query = $db->getQuery(true);
				$query->select($db->qn('id'))
					  ->from($db->qn('#__users'))
					  ->where($db->qn('username').' =
'.$db->q($username));
				$db->setQuery($query);
				if ($db->loadResult()) {
					$this->setError(JText::_('COM_RSMEMBERSHIP_USERNAME_NOT_OK'));
					return false;
				}
			}
			
			$this->data->username = $guest ? $username : $user->username;
		}
		
		// Bind password
		if (RSMembershipHelper::getConfig('choose_password')) {
			$password  = isset($data['password']) ?
$data['password'] : '';
			$password2 = isset($data['password2']) ?
$data['password2'] : '';
			
			if ($guest) {
				JFactory::getLanguage()->load('com_users', JPATH_SITE);
				$rule = JFormHelper::loadRuleType('password');
				$field = new
SimpleXMLElement('<field></field>');
				if (!$rule->test($field, $password)) {
					return false;
				}
				
				
				if ($password != $password2) {
					$this->setError(JText::_('COM_RSMEMBERSHIP_PLEASE_CONFIRM_PASSWORD'));
					return false;
				}
			}
			$this->data->password = $guest ? md5($password) : '';
		}
		
		// Bind email
		$email = isset($data['email']) ? $data['email'] :
'';
		if ($guest) {
			jimport('joomla.mail.helper');
			if (empty($email) || !JMailHelper::isEmailAddress($email)) {
				$this->setError(JText::_('COM_RSMEMBERSHIP_PLEASE_TYPE_EMAIL'));
				return false;
			}
		}
		$this->data->email = $guest ? $email : $user->email;
		
		// Bind name
		$name = isset($data['name']) ? $data['name'] :
'';
		if ($guest && empty($name)) {
			$this->setError(JText::_('COM_RSMEMBERSHIP_PLEASE_TYPE_NAME'));
			return false;
		}
		$this->data->name = $guest ? $name : $user->name;
		
		$sentFields 			= isset($data['fields']) ?
$data['fields'] : array();
		$sentMembershipFields 	= isset($data['membership_fields']) ?
$data['membership_fields'] : array();
		
		if (isset($data['membership_fields'])) {
			$verifyFields = array_merge($sentFields, $sentMembershipFields);
		}

		$fields 			= RSMembership::getCustomFields();
		$membership_fields 	=
RSMembership::getCustomMembershipFields($membership->id);
		$fields 			= array_merge($fields, $membership_fields);
		
		
		foreach ($fields as $field) {
			if (($field->required &&
empty($verifyFields[$field->name])) ||
				($field->rule && !empty($verifyFields[$field->name])
&& is_callable('RSMembershipValidation', $field->rule)
&& !call_user_func(array('RSMembershipValidation',
$field->rule), $verifyFields[$field->name]))) {
				$message = JText::_($field->validation);
				if (empty($message)) {
					$message =
JText::sprintf('COM_RSMEMBERSHIP_VALIDATION_DEFAULT_ERROR',
JText::_($field->label));
				}
				
				$this->setError($message);
				return false;
				
			}
		}
		$this->data->fields = $sentFields;
		$this->data->membership_fields = $sentMembershipFields;
		
		// Bind an empty coupon for legacy reasons
		$this->data->coupon = '';
		
		return true;
	}
	
	public function bindCoupon($coupon, $skip_errors = false) {
		// Did the customer enter a coupon?
		if ($coupon) {
			$db 	= &$this->db;
			$query	= $db->getQuery(true);
			
			$query->select('*')
				  ->from($db->qn('#__rsmembership_coupons'))
				  ->where($db->qn('name').' =
'.$db->q($coupon))
				  ->where($db->qn('published').' =
'.$db->q(1));
			$db->setQuery($query);
			if ($coupon = $db->loadObject()) {
				$now 		= JFactory::getDate()->toUnix();
				$nullDate 	= $db->getNullDate();
				
				// Check if promotion hasn't started yet
				if ($coupon->date_start != $nullDate) {
					$start = JFactory::getDate($coupon->date_start)->toUnix();
					if ($start > $now) {
						if (!$skip_errors) {
							$this->setError(JText::_('COM_RSMEMBERSHIP_COUPON_CODE_NOT_STARTED'));
						}
						return false;
					}
				}
				
				// Check if promotion expired
				if ($coupon->date_end != $nullDate) {
					$end = JFactory::getDate($coupon->date_end)->toUnix();
					if ($end < $now) {
						if (!$skip_errors) {
							$this->setError(JText::_('COM_RSMEMBERSHIP_COUPON_CODE_EXPIRED'));
						}
						return false;
					}
				}
				
				// Check if valid for this membership
				$query->clear();
				$query->select($db->qn('membership_id'))
					  ->from($db->qn('#__rsmembership_coupon_items'))
					  ->where($db->qn('coupon_id').' =
'.$db->q($coupon->id));
				$db->setQuery($query);
				$memberships = $db->loadColumn();
				if ($memberships && !in_array($this->membership->id,
$memberships)) {
					if (!$skip_errors) {
						$this->setError(JText::_('COM_RSMEMBERSHIP_COUPON_CODE_NOT_VALID_FOR_MEMBERSHIP'));
					}
					return false;
				}

				// Check max uses
				if ($coupon->max_uses > 0) {
					$query->clear();
					$query->select('COUNT('.$db->qn('id').')')
						  ->from($db->qn('#__rsmembership_transactions'))
						  ->where($db->qn('status').' =
'.$db->q('completed'))
						  ->where($db->qn('coupon') .' =
'.$db->q($coupon->name));
					$db->setQuery($query);
					$used = $db->loadResult();
					if ($used >= $coupon->max_uses) {
						if (!$skip_errors) {
							$this->setError(JText::_('COM_RSMEMBERSHIP_COUPON_MAX_USAGE'));
						}
						return false;
					}
				}
				
				// Calculate percentage discount
				$coupon->discount_set_price = $coupon->discount_price;
				if ($coupon->discount_type == 0) {
					$coupon->discount_price = $this->membership->price *
($coupon->discount_price / 100);
				}

				// Adjust membership price.
				$this->membership->price -= $coupon->discount_price;
				if ($this->membership->price < 0) {
					$this->membership->price = 0;
				}

				if ($skip_errors) {
					return $coupon;
				}
				// Bind coupon
				$this->coupon = $coupon;
				$this->data->coupon = $coupon->name;
			} else {
				if (!$skip_errors) {
					$this->setError(JText::_('COM_RSMEMBERSHIP_COUPON_INVALID'));
				}
				return false;
			}
		}
		
		return true;
	}
	
	public function getTotal($only_extras = false) {
		$total = $this->membership->price;
		
		if ($extras = $this->getExtras()) {
			if ($only_extras) {
				$total = 0;
			}
			foreach ($extras as $extra) {
				$total += $extra->price;
			}
		}
		
		return $total;
	}
	
	public function saveTransaction($paymentPlugin) {
		// Empty the session, no point in keeping it.
		$this->clearData();
		
		// Empty the HTML variable.
		$this->html = '';

		// Get some data.
		$extras 	= $this->getExtras();
		$membership = $this->getMembership();
		$total 		= $this->getTotal();
		$user 		= JFactory::getUser();
		$app		= JFactory::getApplication();

		// Asign the user.
		$userId = 0;
		if ($user->guest) {
			// Create the user instantly if this option is enabled.
			if (RSMembershipHelper::getConfig('create_user_instantly')) {
				$userId = RSMembership::createUser($this->data->email,
$this->data);
			}
		} else {
			// Grab logged in user's ID.
			$userId = $user->id;
			
			// Update user's custom fields.
			RSMembership::createUserData($userId, $this->data->fields);
		}
		// Create user data object.
		$newData = (object) array(
			'name' 				=> $this->data->name,
			'username' 			=> isset($this->data->username) ?
$this->data->username : '',
			'fields' 			=> $this->data->fields,
			'membership_fields' =>
$this->data->membership_fields,
		);

		if (!empty($this->data->password)) {
			$newData->password = $this->data->password;
		}
		
		// Create transaction params array.
		$params = array('membership_id='.$membership->id);
		if ($this->extras) {
			$params[] = 'extras='.implode(',',
$this->extras);
		}
		$params	= implode(';', $params);
		
		// if the total is 0 than in case coupons are used and discounts are 100%
sot to none the  paymentPlugin
		$ignore_payment_taxes = empty($total) &&
!empty($this->data->coupon);

		$transaction_data = array(
			'membership' => (object) array('price' =>
$membership->initial_price)
		);

		if (!empty($extras)) {
			$transaction_data['extras'] = array();
			foreach ($extras as $extra) {
				$transaction_data['extras'][] = (object)
array('name' => $extra->name, 'price' =>
$extra->price);
			}

		}

		if (isset($this->coupon)) {
			$transaction_data['discount'] = (object)
array('type' => $this->coupon->discount_type,
'price' => $this->coupon->discount_set_price);
		}

		$transaction_data = json_encode($transaction_data);

		// Create the JTable object.
		$row = JTable::getInstance('Transaction',
'RSMembershipTable');
		$row->bind(array(
			'user_id' 		 	=> $userId,
			'user_email' 	 	=> $this->data->email,
			'user_data'		 	=> serialize($newData),
			'type'			 	=> 'new',
			'params'		 	=> $params,
			'date'			 	=> JFactory::getDate()->toSql(),
			'ip'			 	=> RSMembershipHelper::getIP(),
			'price'			 	=> $total,
			'coupon'		 	=> $this->data->coupon,
			'transaction_data'	=> $transaction_data,
			'currency'		 	=>
RSMembershipHelper::getConfig('currency'),
			'gateway'			=> $paymentPlugin == 'none' ?
'No Gateway' : RSMembership::getPlugin($paymentPlugin),
			'status'		 	=> 'pending'
		));

		// Trigger the payment plugin
		$delay = false;
		$args  = array(
			'plugin' 		=> $paymentPlugin,
			'data' 			=> &$this->data,
			'extras'		=> $extras,
			'membership' 	=> $membership,
			'transaction' 	=> &$row,
			'html' 			=> &$this->html
		);

		$returns = $app->triggerEvent('onMembershipPayment',
$args);
		
		if ($ignore_payment_taxes) {
			$row->tax_value = 0;
			$row->price = 0;
		}
		
		// PHP 5.4 fix...
		if (version_compare(PHP_VERSION, '5.4.0', '>='))
{
			foreach ($returns as $value) {
				if ($value) {
					$this->html = $value;
				}
			}
		}
		
		$properties = $row->getProperties();
		$returns = $app->triggerEvent('delayTransactionStoring',
array(array('plugin' => $paymentPlugin, 'properties'
=> &$properties, 'delay' => &$delay)));

		// PHP 5.4 fix...
		if (version_compare(PHP_VERSION, '5.4.0', '>='))
{
			foreach ($returns as $value) {
				if ($value) {
					$delay = true;
				}
			}
		}
		
		// Plugin can delay the transaction storing
		if (!$delay) {
			// Store the transaction
			$row->store();

			// Finalize the transaction (send emails)
			RSMembership::finalize($row->id);
			
			// Approve the transaction
			if ($row->status == 'completed' ||
(!$this->showPaymentOptions() && $membership->activation !=
MEMBERSHIP_ACTIVATION_MANUAL) || $membership->activation ==
MEMBERSHIP_ACTIVATION_INSTANT) {
				RSMembership::approve($row->id, true);
			}
		}
		
		return $row;
	}
	
	public function showPaymentOptions() {
		$total 			= $this->getTotal();
		$membership 	= $this->getMembership();
		$showPayments 	= false;
		
		// Do we have an amount to pay? If we do, show the payment options.
		if ((float) $total) {
			$showPayments = true;
		} else {
			// Trials can be sent to the payment gateway as well
			// Only if we have something to pay afterwards (regular price or renewal
price)
			if ($membership->recurring &&
$membership->use_trial_period && ((float)
$membership->regular_price || ($membership->use_renewal_price
&& (float) $membership->renewal_price))) {
				$showPayments = true;
			}
		}
		
		return $showPayments;
	}
	
	public function storeData($params) {
		$session = JFactory::getSession();
	
		$context = 'com_rsmembership.subscribe.';
		$session->set($context.'id', $params['id']);
		
		$newcontext = $context.$params['id'].'.';
		$session->set($newcontext.'extras',
$params['extras']);
		$session->set($newcontext.'data',
	$params['data']);
		$session->set($newcontext.'coupon',
$params['coupon']);
	}
	
	public function markCorrectData($id) {
		$session = JFactory::getSession();
		
		$context = 'com_rsmembership.subscribe.';
		$session->set($context.$id.'.correct', 1);
	}
	
	public function isCorrectData() {
		$session = JFactory::getSession();
		$id		 = $this->membership->id;
		$context = 'com_rsmembership.subscribe.'.$id.'.';
		
		if ($session->get($context.'correct', 0)) {
			return true;
		} else {
			$this->setError(JText::_('COM_RSMEMBERSHIP_THERE_WAS_AN_ERROR'));
			return false;
		}
	}
	
	// @desc Returns an array with data from the session.
	public function getData() {
		$session = JFactory::getSession();
		$params	 = array(
			'cid' => 0
		);
		
		$context = 'com_rsmembership.subscribe.';
		if ($id = $session->get($context.'id')) {
			$params['cid'] = $id;
		}
		
		if ($params['cid']) {
			$newcontext = $context.$params['cid'].'.';
			
			// Retrieve selected extras
			if ($extras = $session->get($newcontext.'extras')) {
				$params['rsmembership_extra'] = $extras;
			}
			
			// Retrieve coupon
			if ($coupon = $session->get($newcontext.'coupon')) {
				$params['coupon'] = $coupon;
			}
			
			// Retrieve data
			if ($data = $session->get($newcontext.'data')) {
				if (isset($data['username'])) {
					$params['username'] = $data['username'];
				}
				if (isset($data['email'])) {
					$params['email'] = $data['email'];
				}
				if (isset($data['name'])) {
					$params['name'] = $data['name'];
				}
				if (isset($data['password'])) {
					$params['password'] = $data['password'];
				}
				if (isset($data['password2'])) {
					$params['password2'] = $data['password2'];
				}
				if (isset($data['fields'])) {
					$params['rsm_fields'] = $data['fields'];
				}
				if (isset($data['membership_fields'])) {
					$params['rsm_membership_fields'] =
$data['membership_fields'];
				}
			}
		}
		
		return $params;
	}
	
	public function clearData() {
		$session = JFactory::getSession();
		$context = 'com_rsmembership.subscribe.';
		if ($id = $session->get($context.'id')) {
			$session->clear($context.'id');
			
			$newcontext = $context.$id.'.';
			$session->clear($newcontext.'correct');
			$session->clear($newcontext.'extras');
			$session->clear($newcontext.'data');
			$session->clear($newcontext.'coupon');
		}
	}
	
	public function checkUsername() {
		// Get vars
		$jinput		= JFactory::getApplication()->input;
		$db 		= JFactory::getDBO();
		$query		= $db->getQuery(true);

		$username 	= $jinput->get('username', '',
'string');
		
		$username   =
preg_replace('#[<>"\'%;()&\\\\]|\\.\\./#',
'', $username);
		$username   = trim($username);
		$name		= strtolower($jinput->get('name', '',
'string'));

		if ( strlen($name) < 2 ) 
			$name = '';
		$email		  = strtolower($jinput->get('email', '',
'string'));
		if ( strlen($email) < 2 ) 
			$email = '';

		// Keep the username intact
		$new_username = $username;

		// Local flags
		$used_name	  = false;
		$used_email	  = false;
		$reverted	  = false;

		// Return
		$suggestions  = array();

		// Check if username is available
		$query->select('Count('.$db->qn('id').')')
			  ->from($db->qn('#__users'))
			  ->where($db->qn('username').' =
'.$db->q($new_username));
		$db->setQuery($query);
		
		while ( ( $num_rows = $db->loadResult() ) || count($suggestions) <
3)
		{
			// Add only if no rows are found
			if (!$num_rows && !in_array($new_username, $suggestions))
				$suggestions[] = $new_username;
			
			// Use a variation of the name, if available
			if ($name && !$used_name)
			{
				$used_name = true;
				$reverted = false;
				$new_username = str_replace('-', '_',
JFilterOutput::stringURLSafe($name));
			}
			// Use a variation of the email, if available
			elseif ($email && !$used_email)
			{
				$used_email = true;
				$reverted = false;
				$new_username = str_replace('-', '_',
JFilterOutput::stringURLSafe($email));
			}
			// Add random numbers to the username
			else
			{
				if (($used_name || $used_email) && !$reverted)
				{
					$reverted = true;
					$new_username = $username;
				}
				$new_username .= mt_rand(0,9);
			}
			
			if (strlen($new_username) < 2)
				$new_username = str_pad($new_username, 2, '_',
STR_PAD_RIGHT);
			
			$query->clear();
			$query->select($db->qn('id'))
				  ->from($db->qn('#__users'))
				  ->where($db->qn('username').' =
'.$db->q($new_username));
			$db->setQuery($query);
		}
		
		return $suggestions;
	}
	
	public function getHTML() {
		return $this->html;
	}
}PKj��[��rmm	terms.phpnu�[���<?php
/**
 * @package	RSMembership!
 * @copyright	(c) 2009 - 2016 RSJoomla!
 * @link		https://www.rsjoomla.com
 * @license	GNU General Public License
http://www.gnu.org/licenses/gpl-3.0.en.html
 */

defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');

class RSMembershipModelTerms extends JModelList
{
	public $message;
	
	public function __construct()
	{
		parent::__construct();
	}

	public function getTerms()
	{
		$app = JFactory::getApplication();
		$cid = $app->input->get('cid', 0, 'int');
		$row =
JTable::getInstance('Term','RSMembershipTable');

		$row->load($cid);

		if ( !$row->published ) 
		{
			JFactory::getApplication()->enqueueMessage(JText::_('COM_RSMEMBERSHIP_NO_TERM'),
'warning');
			$app->redirect(JRoute::_(RSMembershipRoute::Memberships(), false));
		}
		return $row;
	}
}PKj��[��T�		thankyou.phpnu�[���<?php
/**
 * @package	RSMembership!
 * @copyright	(c) 2009 - 2016 RSJoomla!
 * @link		https://www.rsjoomla.com
 * @license	GNU General Public License
http://www.gnu.org/licenses/gpl-3.0.en.html
 */

defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');

class RSMembershipModelThankYou extends JModelLegacy
{
	public $message;
	
	public function __construct()
	{
		parent::__construct();

		$app 	 = JFactory::getApplication();
		$option  = 'com_rsmembership';

		$session  = JFactory::getSession();
		$action   = $session->get($option.'.subscribe.action',
null);		
		$message  = $session->get($option.'.subscribe.thankyou',
null);
		$redirect = $session->get($option.'.subscribe.redirect',
null);

		$session->set($option.'.subscribe.action', null);
		$session->set($option.'.subscribe.thankyou', null);
		$session->set($option.'.subscribe.redirect', null);
		
		// No session data
		if (is_null($action)) {
			$app->redirect(JRoute::_('index.php?option=com_rsmembership',
false));
		}
		
		// Redirect?
		if ($action == 1 && $redirect) {
			$app->redirect($redirect);
		}
		
		// Store the message
		$this->message = $message;
	}
	
	public function getMessage()
	{		
		return $this->message;
	}
}PKj��['s�pg	g	user.phpnu�[���<?php
/**
 * @package	RSMembership!
 * @copyright	(c) 2009 - 2016 RSJoomla!
 * @link		https://www.rsjoomla.com
 * @license	GNU General Public License
http://www.gnu.org/licenses/gpl-3.0.en.html
 */

defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');

class RSMembershipModelUser extends JModelItem 
{

	public function __construct()
	{
		parent::__construct();
		
		$app = JFactory::getApplication();
		$option = 'com_rsmembership';
		
		$user = JFactory::getUser();
		if ($user->get('guest'))
		{
			$link = base64_encode(JUri::getInstance());
			$app->redirect('index.php?option=com_users&view=login&return='.$link);
		}
	}

	public function getUser()
	{
		$user 	= JFactory::getUser();
		$db 	= JFactory::getDBO();
		$query	= $db->getQuery(true);

		$query->select('*')->from($db->qn('#__rsmembership_subscribers'))->where($db->qn('user_id').'
= '.$db->q($user->get('id')));
		$db->setQuery($query);

		return $db->loadObject();
	}

	public function save()
	{
		$user 	= JFactory::getUser();
		$fields =
JFactory::getApplication()->input->get('rsm_fields',
array(), 'array');
		RSMembership::createUserData($user->get('id'), $fields);
	}
	
	public function _bindData($verbose=true)
	{
		$return = true;
		$rsm_fields =
JFactory::getApplication()->input->get('rsm_fields',
array(), 'array');

		if (empty($rsm_fields))
			return false;
		
		$fields =
RSMembership::getCustomFields(array('published'=>1,
'required'=>1));

		foreach ( $fields as $field ) 
			if ( ($field->required &&
empty($rsm_fields[$field->name])) ||
(!empty($rsm_fields[$field->name]) && $field->rule &&
is_callable('RSMembershipValidation', $field->rule) &&
!call_user_func(array('RSMembershipValidation', $field->rule),
$rsm_fields[$field->name])) ) 
			{
				$validation_message = JText::_($field->validation);
				if ( empty($validation_message) ) 
					$validation_message =
JText::sprintf('COM_RSMEMBERSHIP_VALIDATION_DEFAULT_ERROR',
JText::_($field->label));

				if ( $verbose ) {
					JFactory::getApplication()->enqueueMessage($validation_message,
'warning');
				}

				$return = false;
			}

		return $return;
	}

	public function getRSFieldset() 
	{
		require_once
JPATH_SITE.'/components/com_rsmembership/helpers/adapters/fieldset.php';

		$fieldset = new RSFieldset();
		return $fieldset;
	}
}PKOg�[~�J8+8+category.phpnu�[���<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_contact
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\Registry\Registry;

/**
 * Single item model for a contact
 *
 * @package     Joomla.Site
 * @subpackage  com_contact
 * @since       1.5
 */
class ContactModelCategory extends JModelList
{
	/**
	 * Category items data
	 *
	 * @var array
	 */
	protected $_item = null;

	protected $_articles = null;

	protected $_siblings = null;

	protected $_children = null;

	protected $_parent = null;

	/**
	 * The category that applies.
	 *
	 * @access    protected
	 * @var        object
	 */
	protected $_category = null;

	/**
	 * The list of other contact categories.
	 *
	 * @access    protected
	 * @var       array
	 */
	protected $_categories = null;

	/**
	 * Constructor.
	 *
	 * @param   array  $config  An optional associative array of configuration
settings.
	 *
	 * @since   1.6
	 */
	public function __construct($config = array())
	{
		if (empty($config['filter_fields']))
		{
			$config['filter_fields'] = array(
				'id', 'a.id',
				'name', 'a.name',
				'con_position', 'a.con_position',
				'suburb', 'a.suburb',
				'state', 'a.state',
				'country', 'a.country',
				'ordering', 'a.ordering',
				'sortname',
				'sortname1', 'a.sortname1',
				'sortname2', 'a.sortname2',
				'sortname3', 'a.sortname3'
			);
		}

		parent::__construct($config);
	}

	/**
	 * Method to get a list of items.
	 *
	 * @return  mixed  An array of objects on success, false on failure.
	 */
	public function getItems()
	{
		// Invoke the parent getItems method to get the main list
		$items = parent::getItems();

		// Convert the params field into an object, saving original in _params
		for ($i = 0, $n = count($items); $i < $n; $i++)
		{
			$item = &$items[$i];

			if (!isset($this->_params))
			{
				$item->params = new Registry($item->params);
			}

			// Some contexts may not use tags data at all, so we allow callers to
disable loading tag data
			if ($this->getState('load_tags', true))
			{
				$this->tags = new JHelperTags;
				$this->tags->getItemTags('com_contact.contact',
$item->id);
			}
		}

		return $items;
	}

	/**
	 * Method to build an SQL query to load the list data.
	 *
	 * @return  string    An SQL query
	 *
	 * @since   1.6
	 */
	protected function getListQuery()
	{
		$user = JFactory::getUser();
		$groups = implode(',', $user->getAuthorisedViewLevels());

		// Create a new query object.
		$db = $this->getDbo();
		$query = $db->getQuery(true);

		// Select required fields from the categories.
		// Changes for sqlsrv
		$case_when = ' CASE WHEN ';
		$case_when .= $query->charLength('a.alias', '!=',
'0');
		$case_when .= ' THEN ';
		$a_id = $query->castAsChar('a.id');
		$case_when .= $query->concatenate(array($a_id, 'a.alias'),
':');
		$case_when .= ' ELSE ';
		$case_when .= $a_id . ' END as slug';

		$case_when1 = ' CASE WHEN ';
		$case_when1 .= $query->charLength('c.alias', '!=',
'0');
		$case_when1 .= ' THEN ';
		$c_id = $query->castAsChar('c.id');
		$case_when1 .= $query->concatenate(array($c_id, 'c.alias'),
':');
		$case_when1 .= ' ELSE ';
		$case_when1 .= $c_id . ' END as catslug';
		$query->select($this->getState('list.select',
'a.*') . ',' . $case_when . ',' .
$case_when1)
		/**
		 * TODO: we actually should be doing it but it's wrong this way
		 *	. ' CASE WHEN CHAR_LENGTH(a.alias) THEN
CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, '
		 *	. ' CASE WHEN CHAR_LENGTH(c.alias) THEN
CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END AS catslug ');
		 */
			->from($db->quoteName('#__contact_details') . ' AS
a')
			->join('LEFT', '#__categories AS c ON c.id =
a.catid')
			->where('a.access IN (' . $groups . ')');

		// Filter by category.
		if ($categoryId = $this->getState('category.id'))
		{
			$query->where('a.catid = ' . (int) $categoryId)
				->where('c.access IN (' . $groups . ')');
		}

		// Join over the users for the author and modified_by names.
		$query->select("CASE WHEN a.created_by_alias > ' '
THEN a.created_by_alias ELSE ua.name END AS author")
			->select('ua.email AS author_email')

			->join('LEFT', '#__users AS ua ON ua.id =
a.created_by')
			->join('LEFT', '#__users AS uam ON uam.id =
a.modified_by');

		// Filter by state
		$state = $this->getState('filter.published');

		if (is_numeric($state))
		{
			$query->where('a.published = ' . (int) $state);
		}
		else
		{
			$query->where('(a.published IN (0,1,2))');
		}

		// Filter by start and end dates.
		$nullDate = $db->quote($db->getNullDate());
		$nowDate = $db->quote(JFactory::getDate()->toSql());

		if ($this->getState('filter.publish_date'))
		{
			$query->where('(a.publish_up = ' . $nullDate . ' OR
a.publish_up <= ' . $nowDate . ')')
				->where('(a.publish_down = ' . $nullDate . ' OR
a.publish_down >= ' . $nowDate . ')');
		}

		// Filter by search in title
		$search = $this->getState('list.filter');

		if (!empty($search))
		{
			$search = $db->quote('%' . $db->escape($search, true) .
'%');
			$query->where('(a.name LIKE ' . $search . ')');
		}

		// Filter by language
		if ($this->getState('filter.language'))
		{
			$query->where('a.language in (' .
$db->quote(JFactory::getLanguage()->getTag()) . ',' .
$db->quote('*') . ')');
		}

		// Set sortname ordering if selected
		if ($this->getState('list.ordering') ===
'sortname')
		{
			$query->order($db->escape('a.sortname1') . ' '
. $db->escape($this->getState('list.direction',
'ASC')))
				->order($db->escape('a.sortname2') . ' ' .
$db->escape($this->getState('list.direction',
'ASC')))
				->order($db->escape('a.sortname3') . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
		}
		else
		{
			$query->order($db->escape($this->getState('list.ordering',
'a.ordering')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
		}

		return $query;
	}

	/**
	 * Method to auto-populate the model state.
	 *
	 * Note. Calling getState in this method will result in recursion.
	 *
	 * @param   string  $ordering   An optional ordering field.
	 * @param   string  $direction  An optional direction (asc|desc).
	 *
	 * @return  void
	 *
	 * @since   1.6
	 */
	protected function populateState($ordering = null, $direction = null)
	{
		$app = JFactory::getApplication();
		$params = JComponentHelper::getParams('com_contact');

		// List state information
		$format = $app->input->getWord('format');

		if ($format === 'feed')
		{
			$limit = $app->get('feed_limit');
		}
		else
		{
			$limit = $app->getUserStateFromRequest('global.list.limit',
'limit', $app->get('list_limit'), 'uint');
		}

		$this->setState('list.limit', $limit);

		$limitstart = $app->input->get('limitstart', 0,
'uint');
		$this->setState('list.start', $limitstart);

		// Optional filter text
		$itemid = $app->input->get('Itemid', 0, 'int');
		$search =
$app->getUserStateFromRequest('com_contact.category.list.' .
$itemid . '.filter-search', 'filter-search',
'', 'string');
		$this->setState('list.filter', $search);

		// Get list ordering default from the parameters
		$menuParams = new Registry;

		if ($menu = $app->getMenu()->getActive())
		{
			$menuParams->loadString($menu->params);
		}

		$mergedParams = clone $params;
		$mergedParams->merge($menuParams);

		$orderCol = $app->input->get('filter_order',
$mergedParams->get('initial_sort', 'ordering'));

		if (!in_array($orderCol, $this->filter_fields))
		{
			$orderCol = 'ordering';
		}

		$this->setState('list.ordering', $orderCol);

		$listOrder = $app->input->get('filter_order_Dir',
'ASC');

		if (!in_array(strtoupper($listOrder), array('ASC',
'DESC', '')))
		{
			$listOrder = 'ASC';
		}

		$this->setState('list.direction', $listOrder);

		$id = $app->input->get('id', 0, 'int');
		$this->setState('category.id', $id);

		$user = JFactory::getUser();

		if ((!$user->authorise('core.edit.state',
'com_contact')) &&
(!$user->authorise('core.edit', 'com_contact')))
		{
			// Limit to published for people who can't edit or edit.state.
			$this->setState('filter.published', 1);

			// Filter by start and end dates.
			$this->setState('filter.publish_date', true);
		}

		$this->setState('filter.language',
JLanguageMultilang::isEnabled());

		// Load the parameters.
		$this->setState('params', $params);
	}

	/**
	 * Method to get category data for the current category
	 *
	 * @return  object  The category object
	 *
	 * @since   1.5
	 */
	public function getCategory()
	{
		if (!is_object($this->_item))
		{
			$app = JFactory::getApplication();
			$menu = $app->getMenu();
			$active = $menu->getActive();
			$params = new Registry;

			if ($active)
			{
				$params->loadString($active->params);
			}

			$options = array();
			$options['countItems'] =
$params->get('show_cat_items', 1) ||
$params->get('show_empty_categories', 0);
			$categories = JCategories::getInstance('Contact', $options);
			$this->_item =
$categories->get($this->getState('category.id',
'root'));

			if (is_object($this->_item))
			{
				$this->_children = $this->_item->getChildren();
				$this->_parent = false;

				if ($this->_item->getParent())
				{
					$this->_parent = $this->_item->getParent();
				}

				$this->_rightsibling = $this->_item->getSibling();
				$this->_leftsibling = $this->_item->getSibling(false);
			}
			else
			{
				$this->_children = false;
				$this->_parent = false;
			}
		}

		return $this->_item;
	}

	/**
	 * Get the parent category.
	 *
	 * @return  mixed  An array of categories or false if an error occurs.
	 */
	public function getParent()
	{
		if (!is_object($this->_item))
		{
			$this->getCategory();
		}

		return $this->_parent;
	}

	/**
	 * Get the sibling (adjacent) categories.
	 *
	 * @return  mixed  An array of categories or false if an error occurs.
	 */
	public function &getLeftSibling()
	{
		if (!is_object($this->_item))
		{
			$this->getCategory();
		}

		return $this->_leftsibling;
	}

	/**
	 * Get the sibling (adjacent) categories.
	 *
	 * @return  mixed  An array of categories or false if an error occurs.
	 */
	public function &getRightSibling()
	{
		if (!is_object($this->_item))
		{
			$this->getCategory();
		}

		return $this->_rightsibling;
	}

	/**
	 * Get the child categories.
	 *
	 * @return  mixed  An array of categories or false if an error occurs.
	 */
	public function &getChildren()
	{
		if (!is_object($this->_item))
		{
			$this->getCategory();
		}

		return $this->_children;
	}

	/**
	 * Increment the hit counter for the category.
	 *
	 * @param   integer  $pk  Optional primary key of the category to
increment.
	 *
	 * @return  boolean  True if successful; false otherwise and internal
error set.
	 *
	 * @since   3.2
	 */
	public function hit($pk = 0)
	{
		$input = JFactory::getApplication()->input;
		$hitcount = $input->getInt('hitcount', 1);

		if ($hitcount)
		{
			$pk = (!empty($pk)) ? $pk : (int)
$this->getState('category.id');

			$table = JTable::getInstance('Category', 'JTable');
			$table->hit($pk);
		}

		return true;
	}
}
PKOg�[�/��<J<Jcontact.phpnu�[���<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_contact
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\Registry\Registry;

/**
 * Single item model for a contact
 *
 * @package     Joomla.Site
 * @subpackage  com_contact
 * @since       1.5
 */
class ContactModelContact extends JModelForm
{
	/**
	 * The name of the view for a single item
	 *
	 * @since   1.6
	 */
	protected $view_item = 'contact';

	/**
	 * A loaded item
	 *
	 * @since   1.6
	 */
	protected $_item = null;

	/**
	 * Model context string.
	 *
	 * @var		string
	 */
	protected $_context = 'com_contact.contact';

	/**
	 * Method to auto-populate the model state.
	 *
	 * Note. Calling getState in this method will result in recursion.
	 *
	 * @return  void
	 *
	 * @since   1.6
	 */
	protected function populateState()
	{
		$app = JFactory::getApplication();

		$this->setState('contact.id',
$app->input->getInt('id'));
		$this->setState('params', $app->getParams());

		$user = JFactory::getUser();

		if ((!$user->authorise('core.edit.state',
'com_contact')) && 
(!$user->authorise('core.edit', 'com_contact')))
		{
			$this->setState('filter.published', 1);
			$this->setState('filter.archived', 2);
		}
	}

	/**
	 * Method to get the contact form.
	 * The base form is loaded from XML and then an event is fired
	 *
	 * @param   array    $data      An optional array of data for the form to
interrogate.
	 * @param   boolean  $loadData  True if the form is to load its own data
(default case), false if not.
	 *
	 * @return  JForm  A JForm object on success, false on failure
	 *
	 * @since   1.6
	 */
	public function getForm($data = array(), $loadData = true)
	{
		$form = $this->loadForm('com_contact.contact',
'contact', array('control' => 'jform',
'load_data' => true));

		if (empty($form))
		{
			return false;
		}

		$temp = clone $this->getState('params');

		$contact = $this->_item[$this->getState('contact.id')];

		$active = JFactory::getApplication()->getMenu()->getActive();

		if ($active)
		{
			// If the current view is the active item and a contact view for this
contact, then the menu item params take priority
			if (strpos($active->link, 'view=contact') &&
strpos($active->link, '&id=' . (int) $contact->id))
			{
				// $contact->params are the contact params, $temp are the menu item
params
				// Merge so that the menu item params take priority
				$contact->params->merge($temp);
			}
			else
			{
				// Current view is not a single contact, so the contact params take
priority here
				// Merge the menu item params with the contact params so that the
contact params take priority
				$temp->merge($contact->params);
				$contact->params = $temp;
			}
		}
		else
		{
			// Merge so that contact params take priority
			$temp->merge($contact->params);
			$contact->params = $temp;
		}

		if (!$contact->params->get('show_email_copy', 0))
		{
			$form->removeField('contact_email_copy');
		}

		return $form;
	}

	/**
	 * Method to get the data that should be injected in the form.
	 *
	 * @return  array    The default data is an empty array.
	 *
	 * @since   1.6.2
	 */
	protected function loadFormData()
	{
		$data = (array)
JFactory::getApplication()->getUserState('com_contact.contact.data',
array());

		if (empty($data['language']) &&
JLanguageMultilang::isEnabled())
		{
			$data['language'] = JFactory::getLanguage()->getTag();
		}

		// Add contact id to contact form data, so fields plugin can work
properly
		if (empty($data['catid']))
		{
			$data['catid'] = $this->getItem()->catid;
		}

		$this->preprocessData('com_contact.contact', $data);

		return $data;
	}

	/**
	 * Gets a contact
	 *
	 * @param   integer  $pk  Id for the contact
	 *
	 * @return  mixed Object or null
	 *
	 * @since   1.6.0
	 */
	public function &getItem($pk = null)
	{
		$pk = (!empty($pk)) ? $pk : (int)
$this->getState('contact.id');

		if ($this->_item === null)
		{
			$this->_item = array();
		}

		if (!isset($this->_item[$pk]))
		{
			try
			{
				$db = $this->getDbo();
				$query = $db->getQuery(true);

				// Changes for sqlsrv
				$case_when = ' CASE WHEN ';
				$case_when .= $query->charLength('a.alias',
'!=', '0');
				$case_when .= ' THEN ';
				$a_id = $query->castAsChar('a.id');
				$case_when .= $query->concatenate(array($a_id, 'a.alias'),
':');
				$case_when .= ' ELSE ';
				$case_when .= $a_id . ' END as slug';

				$case_when1 = ' CASE WHEN ';
				$case_when1 .= $query->charLength('c.alias',
'!=', '0');
				$case_when1 .= ' THEN ';
				$c_id = $query->castAsChar('c.id');
				$case_when1 .= $query->concatenate(array($c_id,
'c.alias'), ':');
				$case_when1 .= ' ELSE ';
				$case_when1 .= $c_id . ' END as catslug';

				$query->select($this->getState('item.select',
'a.*') . ',' . $case_when . ',' .
$case_when1)
					->from('#__contact_details AS a')

					// Join on category table.
					->select('c.title AS category_title, c.alias AS
category_alias, c.access AS category_access')
					->join('LEFT', '#__categories AS c on c.id =
a.catid')

					// Join over the categories to get parent category titles
					->select('parent.title as parent_title, parent.id as
parent_id, parent.path as parent_route, parent.alias as parent_alias')
					->join('LEFT', '#__categories as parent ON parent.id
= c.parent_id')

					->where('a.id = ' . (int) $pk);

				// Filter by start and end dates.
				$nullDate = $db->quote($db->getNullDate());
				$nowDate = $db->quote(JFactory::getDate()->toSql());

				// Filter by published state.
				$published = $this->getState('filter.published');
				$archived = $this->getState('filter.archived');

				if (is_numeric($published))
				{
					$query->where('(a.published = ' . (int) $published .
' OR a.published =' . (int) $archived . ')')
						->where('(a.publish_up = ' . $nullDate . ' OR
a.publish_up <= ' . $nowDate . ')')
						->where('(a.publish_down = ' . $nullDate . ' OR
a.publish_down >= ' . $nowDate . ')');
				}

				$db->setQuery($query);
				$data = $db->loadObject();

				if (empty($data))
				{
					JError::raiseError(404,
JText::_('COM_CONTACT_ERROR_CONTACT_NOT_FOUND'));
				}

				// Check for published state if filter set.
				if ((is_numeric($published) || is_numeric($archived)) &&
(($data->published != $published) && ($data->published !=
$archived)))
				{
					JError::raiseError(404,
JText::_('COM_CONTACT_ERROR_CONTACT_NOT_FOUND'));
				}

				/**
				 * In case some entity params have been set to "use global",
those are
				 * represented as an empty string and must be "overridden" by
merging
				 * the component and / or menu params here.
				 */
				$registry = new Registry($data->params);

				$data->params = clone $this->getState('params');
				$data->params->merge($registry);

				$registry = new Registry($data->metadata);
				$data->metadata = $registry;

				// Some contexts may not use tags data at all, so we allow callers to
disable loading tag data
				if ($this->getState('load_tags', true))
				{
					$data->tags = new JHelperTags;
					$data->tags->getItemTags('com_contact.contact',
$data->id);
				}

				// Compute access permissions.
				if (($access = $this->getState('filter.access')))
				{
					// If the access filter has been set, we already know this user can
view.
					$data->params->set('access-view', true);
				}
				else
				{
					// If no access filter is set, the layout takes some responsibility
for display of limited information.
					$user = JFactory::getUser();
					$groups = $user->getAuthorisedViewLevels();

					if ($data->catid == 0 || $data->category_access === null)
					{
						$data->params->set('access-view',
in_array($data->access, $groups));
					}
					else
					{
						$data->params->set('access-view',
in_array($data->access, $groups) &&
in_array($data->category_access, $groups));
					}
				}

				$this->_item[$pk] = $data;
			}
			catch (Exception $e)
			{
				$this->setError($e);
				$this->_item[$pk] = false;
			}
		}

		if ($this->_item[$pk])
		{
			$this->buildContactExtendedData($this->_item[$pk]);
		}

		return $this->_item[$pk];
	}

	/**
	 * Load extended data (profile, articles) for a contact
	 *
	 * @param   object  $contact  The contact object
	 *
	 * @return  void
	 */
	protected function buildContactExtendedData($contact)
	{
		$db        = $this->getDbo();
		$nullDate  = $db->quote($db->getNullDate());
		$nowDate   = $db->quote(JFactory::getDate()->toSql());
		$user      = JFactory::getUser();
		$groups    = implode(',', $user->getAuthorisedViewLevels());
		$published = $this->getState('filter.published');

		// If we are showing a contact list, then the contact parameters take
priority
		// So merge the contact parameters with the merged parameters
		if
($this->getState('params')->get('show_contact_list'))
		{
			$this->getState('params')->merge($contact->params);
		}

		// Get the com_content articles by the linked user
		if ((int) $contact->user_id &&
$this->getState('params')->get('show_articles'))
		{
			$query = $db->getQuery(true)
				->select('a.id')
				->select('a.title')
				->select('a.state')
				->select('a.access')
				->select('a.catid')
				->select('a.created')
				->select('a.language')
				->select('a.publish_up');

			// SQL Server changes
			$case_when = ' CASE WHEN ';
			$case_when .= $query->charLength('a.alias', '!=',
'0');
			$case_when .= ' THEN ';
			$a_id = $query->castAsChar('a.id');
			$case_when .= $query->concatenate(array($a_id, 'a.alias'),
':');
			$case_when .= ' ELSE ';
			$case_when .= $a_id . ' END as slug';
			$case_when1 = ' CASE WHEN ';
			$case_when1 .= $query->charLength('c.alias',
'!=', '0');
			$case_when1 .= ' THEN ';
			$c_id = $query->castAsChar('c.id');
			$case_when1 .= $query->concatenate(array($c_id, 'c.alias'),
':');
			$case_when1 .= ' ELSE ';
			$case_when1 .= $c_id . ' END as catslug';
			$query->select($case_when1 . ',' . $case_when)
				->from('#__content as a')
				->join('LEFT', '#__categories as c on
a.catid=c.id')
				->where('a.created_by = ' . (int) $contact->user_id)
				->where('a.access IN (' . $groups . ')')
				->order('a.publish_up DESC');

			// Filter per language if plugin published
			if (JLanguageMultilang::isEnabled())
			{
				$query->where('a.language IN (' .
$db->quote(JFactory::getLanguage()->getTag()) . ',' .
$db->quote('*') . ')');
			}

			if (is_numeric($published))
			{
				$query->where('a.state IN (1,2)')
					->where('(a.publish_up = ' . $nullDate . ' OR
a.publish_up <= ' . $nowDate . ')')
					->where('(a.publish_down = ' . $nullDate . ' OR
a.publish_down >= ' . $nowDate . ')');
			}

			// Number of articles to display from config/menu params
			$articles_display_num =
$this->getState('params')->get('articles_display_num',
10);

			// Use contact setting?
			if ($articles_display_num === 'use_contact')
			{
				$articles_display_num =
$contact->params->get('articles_display_num', 10);

				// Use global?
				if ((string) $articles_display_num === '')
				{
					$articles_display_num =
JComponentHelper::getParams('com_contact')->get('articles_display_num',
10);
				}
			}

			$db->setQuery($query, 0, (int) $articles_display_num);
			$articles = $db->loadObjectList();
			$contact->articles = $articles;
		}
		else
		{
			$contact->articles = null;
		}

		// Get the profile information for the linked user
		JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR .
'/components/com_users/models', 'UsersModel');
		$userModel = JModelLegacy::getInstance('User',
'UsersModel', array('ignore_request' => true));
		$data = $userModel->getItem((int) $contact->user_id);

		JPluginHelper::importPlugin('user');

		// Get the form.
		JForm::addFormPath(JPATH_SITE .
'/components/com_users/models/forms');
		JForm::addFieldPath(JPATH_SITE .
'/components/com_users/models/fields');
		JForm::addFormPath(JPATH_SITE .
'/components/com_users/model/form');
		JForm::addFieldPath(JPATH_SITE .
'/components/com_users/model/field');

		$form = JForm::getInstance('com_users.profile',
'profile');

		// Get the dispatcher.
		$dispatcher = JEventDispatcher::getInstance();

		// Trigger the form preparation event.
		$dispatcher->trigger('onContentPrepareForm', array($form,
$data));

		// Trigger the data preparation event.
		$dispatcher->trigger('onContentPrepareData',
array('com_users.profile', $data));

		// Load the data into the form after the plugins have operated.
		$form->bind($data);
		$contact->profile = $form;
	}

	/**
	 * Gets the query to load a contact item
	 *
	 * @param   integer  $pk  The item to be loaded
	 *
	 * @return  mixed    The contact object on success, false on failure
	 *
	 * @throws  Exception  On database failure
	 * @deprecated  4.0    Use ContactModelContact::getItem() instead
	 */
	protected function getContactQuery($pk = null)
	{
		// @todo Cache on the fingerprint of the arguments
		$db       = $this->getDbo();
		$nullDate = $db->quote($db->getNullDate());
		$nowDate  = $db->quote(JFactory::getDate()->toSql());
		$user     = JFactory::getUser();
		$pk       = (!empty($pk)) ? $pk : (int)
$this->getState('contact.id');
		$query    = $db->getQuery(true);

		if ($pk)
		{
			// Sqlsrv changes
			$case_when  = ' CASE WHEN ';
			$case_when .= $query->charLength('a.alias', '!=',
'0');
			$case_when .= ' THEN ';

			$a_id       = $query->castAsChar('a.id');
			$case_when .= $query->concatenate(array($a_id, 'a.alias'),
':');
			$case_when .= ' ELSE ';
			$case_when .= $a_id . ' END as slug';

			$case_when1  = ' CASE WHEN ';
			$case_when1 .= $query->charLength('cc.alias',
'!=', '0');
			$case_when1 .= ' THEN ';

			$c_id        = $query->castAsChar('cc.id');
			$case_when1 .= $query->concatenate(array($c_id,
'cc.alias'), ':');
			$case_when1 .= ' ELSE ';
			$case_when1 .= $c_id . ' END as catslug';

			$query->select(
				'a.*, cc.access as category_access, cc.title as category_name,
'
				. $case_when . ',' . $case_when1
			)
				->from('#__contact_details AS a')
				->join('INNER', '#__categories AS cc on cc.id =
a.catid')
				->where('a.id = ' . (int) $pk);

			$published = $this->getState('filter.published');

			if (is_numeric($published))
			{
				$query->where('a.published IN (1,2)')
					->where('cc.published IN (1,2)');
			}

			$groups = implode(',', $user->getAuthorisedViewLevels());
			$query->where('a.access IN (' . $groups . ')');

			try
			{
				$db->setQuery($query);
				$result = $db->loadObject();

				if (empty($result))
				{
					return false;
				}
			}
			catch (Exception $e)
			{
				$this->setError($e->getMessage());

				return false;
			}

			if ($result)
			{
				$contactParams = new Registry($result->params);

				// If we are showing a contact list, then the contact parameters take
priority
				// So merge the contact parameters with the merged parameters
				if
($this->getState('params')->get('show_contact_list'))
				{
					$this->getState('params')->merge($contactParams);
				}

				// Get the com_content articles by the linked user
				if ((int) $result->user_id &&
$this->getState('params')->get('show_articles'))
				{
					$query = $db->getQuery(true)
						->select('a.id')
						->select('a.title')
						->select('a.state')
						->select('a.access')
						->select('a.catid')
						->select('a.created')
						->select('a.language')
						->select('a.publish_up');

					// SQL Server changes
					$case_when = ' CASE WHEN ';
					$case_when .= $query->charLength('a.alias',
'!=', '0');
					$case_when .= ' THEN ';
					$a_id = $query->castAsChar('a.id');
					$case_when .= $query->concatenate(array($a_id,
'a.alias'), ':');
					$case_when .= ' ELSE ';
					$case_when .= $a_id . ' END as slug';
					$case_when1 = ' CASE WHEN ';
					$case_when1 .= $query->charLength('c.alias',
'!=', '0');
					$case_when1 .= ' THEN ';
					$c_id = $query->castAsChar('c.id');
					$case_when1 .= $query->concatenate(array($c_id,
'c.alias'), ':');
					$case_when1 .= ' ELSE ';
					$case_when1 .= $c_id . ' END as catslug';
					$query->select($case_when1 . ',' . $case_when)
						->from('#__content as a')
						->join('LEFT', '#__categories as c on
a.catid=c.id')
						->where('a.created_by = ' . (int) $result->user_id)
						->where('a.access IN (' . $groups . ')')
						->order('a.publish_up DESC');

					// Filter per language if plugin published
					if (JLanguageMultilang::isEnabled())
					{
						$query->where('a.language IN (' .
$db->quote(JFactory::getLanguage()->getTag()) . ',' .
$db->quote('*') . ')');
					}

					if (is_numeric($published))
					{
						$query->where('a.state IN (1,2)')
							->where('(a.publish_up = ' . $nullDate . ' OR
a.publish_up <= ' . $nowDate . ')')
							->where('(a.publish_down = ' . $nullDate . ' OR
a.publish_down >= ' . $nowDate . ')');
					}

					// Number of articles to display from config/menu params
					$articles_display_num =
$this->getState('params')->get('articles_display_num',
10);

					// Use contact setting?
					if ($articles_display_num === 'use_contact')
					{
						$articles_display_num =
$contactParams->get('articles_display_num', 10);

						// Use global?
						if ((string) $articles_display_num === '')
						{
							$articles_display_num =
JComponentHelper::getParams('com_contact')->get('articles_display_num',
10);
						}
					}

					$db->setQuery($query, 0, (int) $articles_display_num);
					$articles = $db->loadObjectList();
					$result->articles = $articles;
				}
				else
				{
					$result->articles = null;
				}

				// Get the profile information for the linked user
				JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR .
'/components/com_users/models', 'UsersModel');
				$userModel = JModelLegacy::getInstance('User',
'UsersModel', array('ignore_request' => true));
				$data = $userModel->getItem((int) $result->user_id);

				JPluginHelper::importPlugin('user');
				$form = new JForm('com_users.profile');

				// Get the dispatcher.
				$dispatcher = JEventDispatcher::getInstance();

				// Trigger the form preparation event.
				$dispatcher->trigger('onContentPrepareForm', array($form,
$data));

				// Trigger the data preparation event.
				$dispatcher->trigger('onContentPrepareData',
array('com_users.profile', $data));

				// Load the data into the form after the plugins have operated.
				$form->bind($data);
				$result->profile = $form;
				$this->contact = $result;

				return $result;
			}
		}

		return false;
	}

	/**
	 * Increment the hit counter for the contact.
	 *
	 * @param   integer  $pk  Optional primary key of the contact to
increment.
	 *
	 * @return  boolean  True if successful; false otherwise and internal
error set.
	 *
	 * @since   3.0
	 */
	public function hit($pk = 0)
	{
		$input = JFactory::getApplication()->input;
		$hitcount = $input->getInt('hitcount', 1);

		if ($hitcount)
		{
			$pk = (!empty($pk)) ? $pk : (int)
$this->getState('contact.id');

			$table = JTable::getInstance('Contact',
'ContactTable');
			$table->hit($pk);
		}

		return true;
	}
}
PKOg�[��Vxxfeatured.phpnu�[���<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_contact
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\Registry\Registry;

/**
 * Featured contact model class.
 *
 * @since  1.6.0
 */
class ContactModelFeatured extends JModelList
{
	/**
	 * Category items data
	 *
	 * @var         array
	 * @since       1.6.0-beta1
	 * @deprecated  4.0  Variable not used since 1.6.0-beta8
	 */
	protected $_item = null;

	/**
	 * Who knows what this was for? It has never been used
	 *
	 * @var          array
	 * @since        1.6.0-beta1
	 * @deprecated   4.0  Variable not used ever
	 */
	protected $_articles = null;

	/**
	 * Get the siblings of the category
	 *
	 * @var          array
	 * @since        1.6.0-beta1
	 * @deprecated   4.0  Variable not used since 1.6.0-beta8
	 */
	protected $_siblings = null;

	/**
	 * Get the children of the category
	 *
	 * @var          array
	 * @since        1.6.0-beta1
	 * @deprecated   4.0  Variable not used since 1.6.0-beta8
	 */
	protected $_children = null;

	/**
	 * Get the parent of the category
	 *
	 * @var          array
	 * @since        1.6.0-beta1
	 * @deprecated   4.0  Variable not used since 1.6.0-beta8
	 */
	protected $_parent = null;

	/**
	 * The category that applies.
	 *
	 * @access      protected
	 * @var         object
	 * @deprecated   4.0  Variable not used ever
	 */
	protected $_category = null;

	/**
	 * The list of other contact categories.
	 *
	 * @access    protected
	 * @var       array
	 * @deprecated   4.0  Variable not used ever
	 */
	protected $_categories = null;

	/**
	 * Constructor.
	 *
	 * @param   array  $config  An optional associative array of configuration
settings.
	 *
	 * @since   1.6
	 */
	public function __construct($config = array())
	{
		if (empty($config['filter_fields']))
		{
			$config['filter_fields'] = array(
				'id', 'a.id',
				'name', 'a.name',
				'con_position', 'a.con_position',
				'suburb', 'a.suburb',
				'state', 'a.state',
				'country', 'a.country',
				'ordering', 'a.ordering',
			);
		}

		parent::__construct($config);
	}

	/**
	 * Method to get a list of items.
	 *
	 * @return  mixed  An array of objects on success, false on failure.
	 */
	public function getItems()
	{
		// Invoke the parent getItems method to get the main list
		$items = parent::getItems();

		// Convert the params field into an object, saving original in _params
		for ($i = 0, $n = count($items); $i < $n; $i++)
		{
			$item = &$items[$i];

			if (!isset($this->_params))
			{
				$item->params = new Registry($item->params);
			}
		}

		return $items;
	}

	/**
	 * Method to build an SQL query to load the list data.
	 *
	 * @return  string    An SQL query
	 *
	 * @since   1.6
	 */
	protected function getListQuery()
	{
		$user = JFactory::getUser();
		$groups = implode(',', $user->getAuthorisedViewLevels());

		// Create a new query object.
		$db = $this->getDbo();
		$query = $db->getQuery(true);

		// Select required fields from the categories.
		$query->select($this->getState('list.select',
'a.*'))
			->from($db->quoteName('#__contact_details') . ' AS
a')
			->where('a.access IN (' . $groups . ')')
			->where('a.featured=1')
			->join('INNER', '#__categories AS c ON c.id =
a.catid')
			->where('c.access IN (' . $groups . ')');

		// Filter by category.
		if ($categoryId = $this->getState('category.id'))
		{
			$query->where('a.catid = ' . (int) $categoryId);
		}

		// Change for sqlsrv... aliased c.published to cat_published
		$query->select('c.published as cat_published, c.published AS
parents_published')
			->where('c.published = 1');

		// Filter by state
		$state = $this->getState('filter.published');

		if (is_numeric($state))
		{
			$query->where('a.published = ' . (int) $state);

			// Filter by start and end dates.
			$nullDate = $db->quote($db->getNullDate());
			$date = JFactory::getDate();
			$nowDate = $db->quote($date->toSql());
			$query->where('(a.publish_up = ' . $nullDate . ' OR
a.publish_up <= ' . $nowDate . ')')
				->where('(a.publish_down = ' . $nullDate . ' OR
a.publish_down >= ' . $nowDate . ')');
		}

		// Filter by language
		if ($this->getState('filter.language'))
		{
			$query->where('a.language in (' .
$db->quote(JFactory::getLanguage()->getTag()) . ',' .
$db->quote('*') . ')');
		}

		// Add the list ordering clause.
		$query->order($db->escape($this->getState('list.ordering',
'a.ordering')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));

		return $query;
	}

	/**
	 * Method to auto-populate the model state.
	 *
	 * Note. Calling getState in this method will result in recursion.
	 *
	 * @param   string  $ordering   An optional ordering field.
	 * @param   string  $direction  An optional direction (asc|desc).
	 *
	 * @return  void
	 *
	 * @since   1.6
	 */
	protected function populateState($ordering = null, $direction = null)
	{
		$app = JFactory::getApplication();
		$params = JComponentHelper::getParams('com_contact');

		// List state information
		$limit = $app->getUserStateFromRequest('global.list.limit',
'limit', $app->get('list_limit'), 'uint');
		$this->setState('list.limit', $limit);

		$limitstart = $app->input->get('limitstart', 0,
'uint');
		$this->setState('list.start', $limitstart);

		$orderCol = $app->input->get('filter_order',
'ordering');

		if (!in_array($orderCol, $this->filter_fields))
		{
			$orderCol = 'ordering';
		}

		$this->setState('list.ordering', $orderCol);

		$listOrder = $app->input->get('filter_order_Dir',
'ASC');

		if (!in_array(strtoupper($listOrder), array('ASC',
'DESC', '')))
		{
			$listOrder = 'ASC';
		}

		$this->setState('list.direction', $listOrder);

		$user = JFactory::getUser();

		if ((!$user->authorise('core.edit.state',
'com_contact')) &&
(!$user->authorise('core.edit', 'com_contact')))
		{
			// Limit to published for people who can't edit or edit.state.
			$this->setState('filter.published', 1);

			// Filter by start and end dates.
			$this->setState('filter.publish_date', true);
		}

		$this->setState('filter.language',
JLanguageMultilang::isEnabled());

		// Load the parameters.
		$this->setState('params', $params);
	}
}
PKOg�[����forms/contact.xmlnu�[���<?xml
version="1.0" encoding="UTF-8"?>
<form>
	<fieldset name="contact"
addrulepath="components/com_contact/models/rules"
label="COM_CONTACT_CONTACT_DEFAULT_LABEL">
		<field
			name="spacer"
			type="spacer"
			label="COM_CONTACT_CONTACT_REQUIRED"
			class="text"
		/>

		<field
			name="contact_name"
			type="text"
			label="COM_CONTACT_CONTACT_EMAIL_NAME_LABEL"
			description="COM_CONTACT_CONTACT_EMAIL_NAME_DESC"
			id="contact-name"
			size="30"
			filter="string"
			required="true"
		/>

		<field
			name="contact_email"
			type="email"
			label="COM_CONTACT_EMAIL_LABEL"
			description="COM_CONTACT_EMAIL_DESC"
			id="contact-email"
			size="30"
			filter="string"
			validate="contactemail"
			autocomplete="email"
			required="true"
		/>

		<field
			name="contact_subject"
			type="text"
			label="COM_CONTACT_CONTACT_MESSAGE_SUBJECT_LABEL"
			description="COM_CONTACT_CONTACT_MESSAGE_SUBJECT_DESC"
			id="contact-emailmsg"
			size="60"
			filter="string"
			validate="contactemailsubject"
			required="true"
		/>

		<field
			name="contact_message"
			type="textarea"
			label="COM_CONTACT_CONTACT_ENTER_MESSAGE_LABEL"
			description="COM_CONTACT_CONTACT_ENTER_MESSAGE_DESC"
			cols="50"
			rows="10"
			id="contact-message"
			filter="safehtml"
			validate="contactemailmessage"
			required="true"
		/>

		<field
			name="contact_email_copy"
			type="checkbox"
			label="COM_CONTACT_CONTACT_EMAIL_A_COPY_LABEL"
			description="COM_CONTACT_CONTACT_EMAIL_A_COPY_DESC"
			id="contact-email-copy"
			default="0"
		/>
	</fieldset>

	<fieldset name="captcha">
		<field
			name="captcha"
			type="captcha"
			label="COM_CONTACT_CAPTCHA_LABEL"
			description="COM_CONTACT_CAPTCHA_DESC"
			validate="captcha"
			namespace="contact"
		/>
	</fieldset>
</form>
PKOg�[���+��forms/filter_contacts.xmlnu�[���<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_contacts/models/fields"
/>
	<fields name="filter">

		<field
			name="search"
			type="text"
			inputmode="search"
			label="COM_CONTACT_FILTER_SEARCH_LABEL"
			description="COM_CONTACT_FILTER_SEARCH_DESC"
			hint="JSEARCH_FILTER"
		/>

		<field
			name="published"
			type="status"
			label="JOPTION_SELECT_PUBLISHED"
			description="JOPTION_SELECT_PUBLISHED_DESC"
			onchange="this.form.submit();"
			>
			<option value="">JOPTION_SELECT_PUBLISHED</option>
		</field>

		<field
			name="category_id"
			type="category"
			label="JOPTION_FILTER_CATEGORY"
			description="JOPTION_FILTER_CATEGORY_DESC"
			extension="com_contact"
			published="0,1,2"
			onchange="this.form.submit();"
			>
			<option value="">JOPTION_SELECT_CATEGORY</option>
		</field>

		<field
			name="access"
			type="accesslevel"
			label="JOPTION_FILTER_ACCESS"
			description="JOPTION_FILTER_ACCESS_DESC"
			onchange="this.form.submit();"
			>
			<option value="">JOPTION_SELECT_ACCESS</option>
		</field>

		<field
			name="language"
			type="contentlanguage"
			label="JOPTION_FILTER_LANGUAGE"
			description="JOPTION_FILTER_LANGUAGE_DESC"
			onchange="this.form.submit();"
			>
			<option value="">JOPTION_SELECT_LANGUAGE</option>
			<option value="*">JALL</option>
		</field>

		<field
			name="tag"
			type="tag"
			label="JOPTION_FILTER_TAG"
			description="JOPTION_FILTER_TAG_DESC"
			mode="nested"
			onchange="this.form.submit();"
			>
			<option value="">JOPTION_SELECT_TAG</option>
		</field>

		<field
			name="level"
			type="integer"
			label="JOPTION_FILTER_LEVEL"
			description="JOPTION_FILTER_LEVEL_DESC"
			first="1"
			last="10"
			step="1"
			languages="*"
			onchange="this.form.submit();"
			>
			<option
value="">JOPTION_SELECT_MAX_LEVELS</option>
		</field>
	</fields>

	<fields name="list">

		<field
			name="fullordering"
			type="list"
			label="COM_CONTACT_LIST_FULL_ORDERING"
			description="COM_CONTACT_LIST_FULL_ORDERING_DESC"
			default="a.name ASC"
			onchange="this.form.submit();"
			validate="options"
			>
			<option value="">JGLOBAL_SORT_BY</option>
			<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
			<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
			<option value="a.published
ASC">JSTATUS_ASC</option>
			<option value="a.published
DESC">JSTATUS_DESC</option>
			<option value="a.featured
ASC">JFEATURED_ASC</option>
			<option value="a.featured
DESC">JFEATURED_DESC</option>
			<option value="a.name
ASC">JGLOBAL_TITLE_ASC</option>
			<option value="a.name
DESC">JGLOBAL_TITLE_DESC</option>
			<option value="category_title
ASC">JCATEGORY_ASC</option>
			<option value="category_title
DESC">JCATEGORY_DESC</option>
			<option value="ul.name
ASC">COM_CONTACT_FIELD_LINKED_USER_LABEL_ASC</option>
			<option value="ul.name
DESC">COM_CONTACT_FIELD_LINKED_USER_LABEL_DESC</option>
			<option value="access_level
ASC">JGRID_HEADING_ACCESS_ASC</option>
			<option value="access_level
DESC">JGRID_HEADING_ACCESS_DESC</option>
			<option
				value="association ASC"
				requires="associations"
				>
				JASSOCIATIONS_ASC
			</option>
			<option
				value="association DESC"
				requires="associations"
				>
				JASSOCIATIONS_DESC
			</option>
			<option value="language_title
ASC">JGRID_HEADING_LANGUAGE_ASC</option>
			<option value="language_title
DESC">JGRID_HEADING_LANGUAGE_DESC</option>
			<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
			<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
		</field>

		<field
			name="limit"
			type="limitbox"
			label="COM_CONTACT_LIST_LIMIT"
			description="COM_CONTACT_LIST_LIMIT_DESC"
			default="25"
			class="input-mini"
			onchange="this.form.submit();"
		/>
	</fields>
</form>
PKOg�[���\>\>forms/form.xmlnu�[���<?xml
version="1.0" encoding="UTF-8"?>
<!-- @deprecated  4.0  Not used since 1.6 No replacement. -->
<form>
	<fieldset>
		<field
			name="id"
			type="hidden"
			label="COM_CONTACT_ID_LABEL"
			default="0"
			readonly="true"
			required="true"
			size="10"
		/>

		<field
			name="name"
			type="text"
			label="CONTACT_NAME_LABEL"
			description="CONTACT_NAME_DESC"
			required="true"
			size="30"
		/>

		<field
			name="alias"
			type="text"
			label="JFIELD_ALIAS_LABEL"
			description="JFIELD_ALIAS_DESC"
			hint="JFIELD_ALIAS_PLACEHOLDER"
			size="30"
		/>

		<field
			name="user_id"
			type="user"
			label="CONTACT_LINKED_USER_LABEL"
			description="CONTACT_LINKED_USER_DESC"
		/>

		<field
			name="published"
			type="list"
			label="JFIELD_PUBLISHED_LABEL"
			description="JFIELD_PUBLISHED_DESC"
			default="1"
			size="1"
			>
			<option value="1">JPUBLISHED</option>
			<option value="0">JUNPUBLISHED</option>
			<option value="-1">JARCHIVED</option>
			<option value="-2">JTRASHED</option>
		</field>

		<field
			name="catid"
			type="category"
			label="JCATEGORY"
			description="JFIELD_CATEGORY_DESC"
			extension="com_contact"
			required="true"
		/>

		<field
			name="access"
			type="accesslevel"
			label="JFIELD_ACCESS_LABEL"
			description="JFIELD_ACCESS_DESC"
			size="1"
		/>

		<field
			name="sortname1"
			type="text"
			label="CONTACT_SORTNAME1_LABEL"
			description="CONTACT_SORTNAME1_DESC"
			size="30"
		/>

		<field
			name="sortname2"
			type="text"
			label="CONTACT_SORTNAME2_LABEL"
			description="CONTACT_SORTNAME3_DESC"
			size="30"
		/>

		<field
			name="sortname3"
			type="text"
			label="CONTACT_SORTNAME3_LABEL"
			description="CONTACT_SORTNAME3_DESC"
			size="30"
		/>

		<field
			name="language"
			type="text"
			label="CONTACT_LANGUAGE_LABEL"
			description="CONTACT_LANGUAGE_DESC"
			size="30"
		/>

		<field
			name="con_position"
			type="text"
			label="CONTACT_INFORMATION_POSITION_LABEL"
			description="CONTACT_INFORMATION_POSITION_DESC"
			size="30"
		/>

		<field
			name="email_to"
			type="email"
			label="CONTACT_INFORMATION_EMAIL_LABEL"
			description="CONTACT_INFORMATION_EMAIL_DESC"
			size="30"
			validate="email"
			filter="string"
			autocomplete="email"
		/>

		<field
			name="address"
			type="textarea"
			label="CONTACT_INFORMATION_ADDRESS_LABEL"
			description="CONTACT_INFORMATION_ADDRESS_DESC"
			cols="30"
			rows="3"
		/>

		<field
			name="suburb"
			type="text"
			label="CONTACT_INFORMATION_SUBURB_LABEL"
			description="CONTACT_INFORMATION_SUBURB_DESC"
			size="30"
		/>

		<field
			name="state"
			type="text"
			label="CONTACT_INFORMATION_STATE_LABEL"
			description="CONTACT_INFORMATION_STATE_DESC"
			size="30"
		/>

		<field
			name="postcode"
			type="text"
			label="CONTACT_INFORMATION_POSTCODE_LABEL"
			description="CONTACT_INFORMATION_POSTCODE_DESC"
			size="30"
		/>

		<field
			name="country"
			type="text"
			label="CONTACT_INFORMATION_COUNTRY_LABEL"
			description="CONTACT_INFORMATION_COUNTRY_DESC"
			size="30"
		/>

		<field
			name="telephone"
			type="text"
			label="CONTACT_INFORMATION_TELEPHONE_LABEL"
			description="CONTACT_INFORMATION_TELEPHONE_DESC"
			size="30"
		/>

		<field
			name="mobile"
			type="text"
			label="CONTACT_INFORMATION_MOBILE_LABEL"
			description="CONTACT_INFORMATION_MOBILE_DESC"
			size="30"
		/>

		<field
			name="webpage"
			type="text"
			label="CONTACT_INFORMATION_WEBPAGE_LABEL"
			description="CONTACT_INFORMATION_WEBPAGE_DESC"
			size="30"
		/>

		<field
			name="misc"
			type="editor"
			label="CONTACT_INFORMATION_MISC_LABEL"
			description="CONTACT_INFORMATION_MISC_DESC"
			buttons="true"
			hide="pagebreak,readmore"
			filter="safehtml"
			size="30"
		/>

		<field
			name="checked_out"
			type="hidden"
			filter="unset"
		/>

		<field
			name="checked_out_time"
			type="hidden"
			filter="unset"
		/>

		<field
			name="ordering"
			type="ordering"
			label="JFIELD_ORDERING_LABEL"
			description="JFIELD_ORDERING_DESC"
			content_type="com_contact.contact"
		/>

		<field
			name="metakey"
			type="textarea"
			label="JFIELD_META_KEYWORDS_LABEL"
			description="JFIELD_META_KEYWORDS_DESC"
			cols="30"
			rows="3"
		/>

		<field
			name="metadesc"
			type="textarea"
			label="JFIELD_META_DESCRIPTION_LABEL"
			description="JFIELD_META_DESCRIPTION_DESC"
			cols="30"
			rows="3"
		/>

		<field
			name="language"
			type="contentlanguage"
			label="JFIELD_LANGUAGE_LABEL"
			description="JFIELD_CONTACT_LANGUAGE_DESC"
			>
			<option value="">JALL</option>
		</field>

		<field
			name="contact_icons"
			type="list"
			label="Icons/text"
			description="PARAMCONTACTICONS"
			default="0"
			>
			<option
value="0">CONTACT_ICONS_OPTIONS_NONE</option>
			<option
value="1">CONTACT_ICONS_OPTIONS_TEXT</option>
			<option
value="2">CONTACT_ICONS_OPTIONS_TEXT</option>
		</field>

		<field
			name="icon_address"
			type="imagelist"
			label="CONTACT_ICONS_ADDRESS_LABEL"
			description="CONTACT_ICONS_ADDRESS_DESC"
			directory="/images"
			hide_none="1"
		/>

		<field
			name="icon_email"
			type="imagelist"
			label="CONTACT_ICONS_EMAIL_LABEL"
			description="CONTACT_ICONS_EMAIL_DESC"
			directory="/images"
			hide_none="1"
		/>

		<field
			name="icon_telephone"
			type="imagelist"
			label="CONTACT_ICONS_TELEPHONE_LABEL"
			description="CONTACT_ICONS_TELEPHONE_DESC"
			directory="/images"
			hide_none="1"
		/>

		<field
			name="icon_mobile"
			type="imagelist"
			label="CONTACT_ICONS_MOBILE_LABEL"
			description="CONTACT_ICONS_MOBILE_DESC"
			directory="/images"
			hide_none="1"
		/>

		<field
			name="icon_fax"
			type="imagelist"
			label="CONTACT_ICONS_FAX_LABEL"
			description="CONTACT_ICONS_FAX_DESC"
			directory="/images"
			hide_none="1"
		/>

		<field
			name="icon_misc"
			type="imagelist"
			label="CONTACT_ICONS_MISC_LABEL"
			description="CONTACT_ICONS_MISC_DESC"
			directory="/images"
			hide_none="1"
		/>

	</fieldset>

	<fields name="metadata">
		<fieldset name="metadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
			<field
				name="robots"
				type="list"
				label="JFIELD_METADATA_ROBOTS_LABEL"
				description="JFIELD_METADATA_ROBOTS_DESC"
				>
				<option value="">JGLOBAL_USE_GLOBAL</option>
				<option value="index, follow"></option>
				<option value="noindex, follow"></option>
				<option value="index, nofollow"></option>
				<option value="noindex, nofollow"></option>
			</field>

			<field
				name="rights"
				type="text"
				label="JFIELD_METADATA_RIGHTS_LABEL"
				description="JFIELD_METADATA_RIGHTS_DESC"
				size="20"
			/>

		</fieldset>
	</fields>

	<fields name="params">
		<fieldset name="options"
label="CONTACT_PARAMETERS">

			<field
				name="show_tags"
				type="list"
				label="COM_CONTACT_FIELD_SHOW_TAGS_LABEL"
				description="COM_CONTACT_FIELD_SHOW_TAGS_DESC"
				>
				<option value="">JGLOBAL_USE_GLOBAL</option>
				<option value="0">JHIDE</option>
				<option value="1">JSHOW</option>
			</field>

			<field
				name="show_info"
				type="list"
				label="COM_CONTACT_FIELD_SHOW_INFO_LABEL"
				description="COM_CONTACT_FIELD_SHOW_INFO_DESC"
				>
				<option value="">JGLOBAL_USE_GLOBAL</option>
				<option value="0">JHIDE</option>
				<option value="1">JSHOW</option>
			</field>

		<field
			name="show_name"
			type="list"
			label="CONTACT_PARAMS_NAME_LABEL"
			description="CONTACT_PARAMS_NAME_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_position"
			type="list"
			label="CONTACT_PARAMS_CONTACT_POSITION_LABEL"
			description="CONTACT_PARAMS_NAME_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_email"
			type="list"
			label="CONTACT_PARAMS_CONTACT_POSITION_E_MAIL_LABEL"
			description="CONTACT_PARAMS_NAME_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_street_address"
			type="list"
			label="CONTACT_PARAMS_STREET_ADDRESS_LABEL"
			description="CONTACT_PARAMS_NAME_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_suburb"
			type="list"
			label="CONTACT_PARAMS_TOWN_SUBURB_LABEL"
			description="CONTACT_PARAMS_NAME_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_state"
			type="list"
			label="CONTACT_PARAMS_STATE_COUNTY_LABEL"
			description="CONTACT_PARAMS_NAME_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_postcode"
			type="list"
			label="CONTACT_PARAMS_POST_ZIP_CODE_LABEL"
			description="CONTACT_PARAMS_NAME_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_country"
			type="list"
			label="CONTACT_PARAMS_COUNTRY_LABEL"
			description="CONTACT_PARAMS_NAME_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_telephone"
			type="list"
			label="CONTACT_PARAMS_TELEPHONE_LABEL"
			description="CONTACT_PARAMS_NAME_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_mobile"
			type="list"
			label="CONTACT_PARAMS_MOBILE_LABEL"
			description="CONTACT_PARAMS_NAME_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_fax"
			type="list"
			label="CONTACT_PARAMS_FAX_LABEL"
			description="CONTACT_PARAMS_NAME_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_webpage"
			type="list"
			label="CONTACT_PARAMS_WEBPAGE_LABEL"
			description="CONTACT_PARAMS_NAME_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_image"
			type="list"
			label="CONTACT_PARAMS_IMAGE_LABEL"
			description="CONTACT_PARAMS_NAME_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="allow_vcard"
			type="list"
			label="CONTACT_PARAMS_VCARD_LABEL"
			description="CONTACT_PARAMS_VCARD_LABEL"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_misc"
			type="list"
			label="CONTACT_PARAMS_MISC_INFO_LABEL"
			description="CONTACT_PARAMS_NAME_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_articles"
			type="list"
			label="CONTACT_SHOW_ARTICLES_LABEL"
			description="CONTACT_SHOW_ARTICLES_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="articles_display_num"
			type="list"
			label="COM_CONTACT_FIELD_ARTICLES_DISPLAY_NUM_LABEL"
			description="COM_CONTACT_FIELD_ARTICLES_DISPLAY_NUM_DESC"
			default=""
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="5">J5</option>
			<option value="10">J10</option>
			<option value="15">J15</option>
			<option value="20">J20</option>
			<option value="25">J25</option>
			<option value="30">J30</option>
			<option value="50">J50</option>
			<option value="75">J75</option>
			<option value="100">J100</option>
			<option value="150">J150</option>
			<option value="200">J200</option>
			<option value="250">J250</option>
			<option value="300">J300</option>
			<option value="0">JALL</option>
		</field>

		<field
			name="show_profile"
			type="list"
			label="CONTACT_PROFILE_SHOW_LABEL"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="show_user_custom_fields"
			type="fieldgroups"
			label="COM_CONTACT_FIELD_USER_CUSTOM_FIELDS_SHOW_LABEL"
			description="COM_CONTACT_FIELD_USER_CUSTOM_FIELDS_SHOW_DESC"
			multiple="true"
			context="com_users.user"
			>
			<option value="-1">JALL</option>
		</field>

		<field
			name="show_links"
			type="list"
			label="CONTACT_SHOW_LINKS_LABEL"
			description="CONTACT_SHOW_LINKS_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="linka_name"
			type="text"
			label="CONTACT_LINKA_NAME_LABEL"
			description="CONTACT_LINKA_NAME_DESC"
			size="30"
		/>

		<field
			name="linka"
			type="text"
			label="CONTACT_LINKA_LABEL"
			description="CONTACT_LINKA_DESC"
			size="30"
		/>

		<field
			name="linkb_name"
			type="text"
			label="CONTACT_LINKB_NAME_LABEL"
			description="CONTACT_LINKB_NAME_DESC"
			size="30"
		/>

		<field
			name="linkb"
			type="text"
			label="CONTACT_LINKB_LABEL"
			description="CONTACT_LINKB_DESC"
			size="30"
		/>

		<field
			name="linkc_name"
			type="text"
			label="CONTACT_LINKC_NAME_LABEL"
			description="CONTACT_LINKC_NAME_DESC"
			size="30"
		/>

		<field
			name="linkc"
			type="text"
			label="CONTACT_LINKC_LABEL"
			description="CONTACT_LINKC_DESC"
			size="30"
		/>

		<field
			name="linkd_name"
			type="text"
			label="CONTACT_LINKD_NAME_LABEL"
			description="CONTACT_LINKD_NAME_DESC"
			size="30"
		/>

		<field
			name="linkd"
			type="text"
			label="CONTACT_LINKD_LABEL"
			description="CONTACT_LINKD_DESC"
			size="30"
		/>

		<field
			name="linke_name"
			type="text"
			label="CONTACT_LINKE_NAME_LABEL"
			description="CONTACT_LINKE_NAME_DESC"
			size="30"
		/>

		<field
			name="linke"
			type="text"
			label="CONTACT_LINKE_LABEL"
			description="CONTACT_LINKE_DESC"
			size="30"
		/>

		</fieldset>
	</fields>

	<fields name="email_form">
		<fieldset name="email_form"
label="CONTACT_EMAIL_FORM_LABEL">

		<field
			name="show_email_form"
			type="list"
			label="CONTACT_EMAIL_SHOW_FORM_LABEL"
			description="CONTACT_EMAIL_SHOW_FORM_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="email_description"
			type="text"
			label="CONTACT_EMAIL_DESCRIPTION_TEXT_LABEL"
			description="CONTACT_EMAIL_DESCRIPTION_TEXT_DESC"
			size="30"
		/>

		<field
			name="show_email_copy"
			type="list"
			label="CONTACT_EMAIL_EMAIL_COPY_LABEL"
			description="CONTACT_EMAIL_EMAIL_COPY_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JHIDE</option>
			<option value="1">JSHOW</option>
		</field>

		<field
			name="validate_session"
			type="list"
			label="CONTACT_CONFIG_SESSION_CHECK_LABEL"
			description="CONTACT_CONFIG_SESSION_CHECK_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JNO</option>
			<option value="1">JYES</option>
		</field>

		<field
			name="custom_reply"
			type="list"
			label="CONTACT_CONFIG_CUSTOM_REPLY"
			description="CONTACT_CONFIG_CUSTOM_REPLY_DESC"
			>
			<option value="">JGLOBAL_USE_GLOBAL</option>
			<option value="0">JNO</option>
			<option value="1">JYES</option>
		</field>

		<field
			name="redirect"
			type="text"
			label="COM_CONTACT_FIELD_CONFIG_REDIRECT_LABEL"
			description="COM_CONTACT_FIELD_CONFIG_REDIRECT_DESC"
			size="30"
		/>

		</fieldset>
	</fields>
</form>

PKOg�[o-��rules/contactemail.phpnu�[���<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_contact
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\Registry\Registry;
use Joomla\String\StringHelper;

JFormHelper::loadRuleClass('email');

/**
 * JFormRule for com_contact to make sure the email address is not blocked.
 *
 * @since  1.6
 */
class JFormRuleContactEmail extends JFormRuleEmail
{
	/**
	 * Method to test for banned email addresses
	 *
	 * @param   SimpleXMLElement  $element  The SimpleXMLElement object
representing the <field /> tag for the form field object.
	 * @param   mixed             $value    The form field value to validate.
	 * @param   string            $group    The field name group control
value. This acts as an array container for the field.
	 *                                      For example if the field has
name="foo" and the group value is set to "bar" then the
	 *                                      full field name would end up being
"bar[foo]".
	 * @param   Registry          $input    An optional Registry object with
the entire data set to validate against the entire form.
	 * @param   JForm             $form     The form object for which the
field is being tested.
	 *
	 * @return  boolean  True if the value is valid, false otherwise.
	 */
	public function test(SimpleXMLElement $element, $value, $group = null,
Registry $input = null, JForm $form = null)
	{
		if (!parent::test($element, $value, $group, $input, $form))
		{
			return false;
		}

		$params = JComponentHelper::getParams('com_contact');
		$banned = $params->get('banned_email');

		if ($banned)
		{
			foreach (explode(';', $banned) as $item)
			{
				if ($item != '' && StringHelper::stristr($value,
$item) !== false)
				{
					return false;
				}
			}
		}

		return true;
	}
}
PKOg�[����rules/contactemailmessage.phpnu�[���<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_contact
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\Registry\Registry;
use Joomla\String\StringHelper;

/**
 * JFormRule for com_contact to make sure the message body contains no
banned word.
 *
 * @since  1.6
 */
class JFormRuleContactEmailMessage extends JFormRule
{
	/**
	 * Method to test a message for banned words
	 *
	 * @param   SimpleXMLElement  $element  The SimpleXMLElement object
representing the <field /> tag for the form field object.
	 * @param   mixed             $value    The form field value to validate.
	 * @param   string            $group    The field name group control
value. This acts as an array container for the field.
	 *                                      For example if the field has
name="foo" and the group value is set to "bar" then the
	 *                                      full field name would end up being
"bar[foo]".
	 * @param   Registry          $input    An optional Registry object with
the entire data set to validate against the entire form.
	 * @param   JForm             $form     The form object for which the
field is being tested.
	 *
	 * @return  boolean  True if the value is valid, false otherwise.
	 */
	public function test(SimpleXMLElement $element, $value, $group = null,
Registry $input = null, JForm $form = null)
	{
		$params = JComponentHelper::getParams('com_contact');
		$banned = $params->get('banned_text');

		if ($banned)
		{
			foreach (explode(';', $banned) as $item)
			{
				if ($item != '' && StringHelper::stristr($value,
$item) !== false)
				{
					return false;
				}
			}
		}

		return true;
	}
}
PKOg�[2�$5		rules/contactemailsubject.phpnu�[���<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_contact
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\Registry\Registry;
use Joomla\String\StringHelper;

/**
 * JFormRule for com_contact to make sure the subject contains no banned
word.
 *
 * @since  1.6
 */
class JFormRuleContactEmailSubject extends JFormRule
{
	/**
	 * Method to test for a banned subject
	 *
	 * @param   SimpleXMLElement  $element  The SimpleXMLElement object
representing the <field /> tag for the form field object.
	 * @param   mixed             $value    The form field value to validate.
	 * @param   string            $group    The field name group control
value. This acts as an array container for the field.
	 *                                      For example if the field has
name="foo" and the group value is set to "bar" then the
	 *                                      full field name would end up being
"bar[foo]".
	 * @param   Registry          $input    An optional Registry object with
the entire data set to validate against the entire form.
	 * @param   JForm             $form     The form object for which the
field is being tested.
	 *
	 * @return  boolean  True if the value is valid, false otherwise
	 */
	public function test(SimpleXMLElement $element, $value, $group = null,
Registry $input = null, JForm $form = null)
	{
		$params = JComponentHelper::getParams('com_contact');
		$banned = $params->get('banned_subject');

		if ($banned)
		{
			foreach (explode(';', $banned) as $item)
			{
				if ($item != '' && StringHelper::stristr($value,
$item) !== false)
				{
					return false;
				}
			}
		}

		return true;
	}
}
PKbV�[9S��ooforms/filter_items.xmlnu�[���PKj��[��~

�categories.phpnu�[���PKj��[���66
�extras.phpnu�[���PKj��[�#o,,
o"index.htmlnu�[���PKj��[�m�ש��"membership.phpnu�[���PKj��[P��e�e��'mymembership.phpnu�[���PKj��[�Z�+��a�mymemberships.phpnu�[���PKj��[�y��
�
W�mytransactions.phpnu�[���PKj��[3��!
!
l�rsmembership.phpnu�[���PKj��[?_BW�h�h
��subscribe.phpnu�[���PKj��[��rmm	�Fterms.phpnu�[���PKj��[��T�		vJthankyou.phpnu�[���PKj��['s�pg	g	�Ouser.phpnu�[���PKOg�[~�J8+8+ZYcategory.phpnu�[���PKOg�[�/��<J<J΄contact.phpnu�[���PKOg�[��VxxE�featured.phpnu�[���PKOg�[������forms/contact.xmlnu�[���PKOg�[���+���forms/filter_contacts.xmlnu�[���PKOg�[���\>\>;�forms/form.xmlnu�[���PKOg�[o-���<rules/contactemail.phpnu�[���PKOg�[�����Drules/contactemailmessage.phpnu�[���PKOg�[2�$5		Lrules/contactemailsubject.phpnu�[���PK�WS