<?php
/*
 * @package 	RSFirewall!
 * @copyright 	(c) 2009 - 2024 RSJoomla!
 * @link 		https://www.rsjoomla.com/joomla-extensions/joomla-security.html
 * @license 	GNU General Public License https://www.gnu.org/licenses/gpl-3.0.en.html
 */

defined('_JEXEC') or die;

use Joomla\CMS\Factory;

class RSFirewallProtectionAstroid extends RSFirewallProtection
{
	protected $reason = 'COM_RSFIREWALL_PHP_CODE_DETECTED';
	protected $code = 'ASTROID_INJECTION_ATTEMPT';

	public function isInjection()
	{
		if ($this->getOption() === 'com_ajax' && isset($_REQUEST['astroid']) && in_array(strtolower($_REQUEST['astroid']), array('media', 'installtemplate')))
		{
			$user = Factory::getUser();
			if ($user->guest || !$user->authorise('core.manage', 'com_templates'))
			{
				return true;
			}
		}

		return false;
	}
}