- md5
- 667b243cd19c8ed5a45c198361bf3db3
- sha1
- 698795eb40a94df197d05506ec11ccf6469e5462
- sha256
- f19ae16738616a605128efa1357f7c9e81554d609f040412fb0cee0991c5be26
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
<?php
/**
* @package Joomla.Administrator
* @subpackage com_csp
*
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Csp\Administrator\Helper;
\defined('_JEXEC') or die;
use Joomla\CMS\Factory;
/**
* Reporter component helper.
*
* @since 4.0.0
*/
class ReporterHelper
{
/**
* Gets the httpheaders system plugin extension id.
*
* @return mixed The httpheaders system plugin extension id or false in case of an error.
*
* @since 4.0.0
*/
public static function getHttpHeadersPluginId()
{
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('extension_id'))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('folder') . ' = ' . $db->quote('system'))
->where($db->quoteName('element') . ' = ' . $db->quote('httpheaders'));
$db->setQuery($query);
try
{
$result = (int) $db->loadResult();
}
catch (\RuntimeException $e)
{
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
return false;
}
return $result;
}
/**
* Check the com_csp trash to show a warning in this case
*
* @return boolean The status of the trash; Do items exists in the trash
*
* @since 4.0.0
*/
public static function getCspTrashStatus()
{
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('COUNT(*)')
->from($db->quoteName('#__csp'))
->where($db->quoteName('published') . ' = ' . $db->quote('-2'));
$db->setQuery($query);
try
{
$result = (int) $db->loadResult();
}
catch (\RuntimeException $e)
{
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
return false;
}
return boolval($result);
}
/**
* Check whether there are unsafe-inline rules published
*
* @return boolean Whether there are unsafe-inline rules published
*
* @since 4.0.0
*/
public static function getCspUnsafeInlineStatus()
{
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('COUNT(*)')
->from($db->quoteName('#__csp'))
->where($db->quoteName('blocked_uri') . ' = ' . $db->quote("'unsafe-inline'"))
->where($db->quoteName('published') . ' = 1');
$db->setQuery($query);
try
{
$result = (int) $db->loadResult();
}
catch (\RuntimeException $e)
{
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
return false;
}
return boolval($result);
}
/**
* Check whether there are unsafe-eval rules published
*
* @return boolean Whether there are unsafe-eval rules published
*
* @since 4.0.0
*/
public static function getCspUnsafeEvalStatus()
{
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('COUNT(*)')
->from($db->quoteName('#__csp'))
->where($db->quoteName('blocked_uri') . ' = ' . $db->quote("'unsafe-eval'"))
->where($db->quoteName('published') . ' = 1');
$db->setQuery($query);
try
{
$result = (int) $db->loadResult();
}
catch (\RuntimeException $e)
{
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
return false;
}
return boolval($result);
}
}
The same content is in 2 releases, Joomla 4.0.0-beta6 to 4.0.0-beta7. See them all, or every version of this file.