- md5
- ec1deb04a6cfdd0ab24f4c372cac3fa6
- sha1
- 87536438151962da41f1876e51aae5b1e54a89fc
- sha256
- 79d910d99157bf52ad6e1bf13fb5d00c57914cdec6d140824ebe2d693ebabd4e
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
<?php
/**
* @package Joomla.Plugin
* @subpackage Captcha.POWCaptcha
*
* @copyright (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\Captcha\POWCaptcha\Extension;
use Joomla\CMS\Event\Captcha\CaptchaSetupEvent;
use Joomla\CMS\Event\Plugin\AjaxEvent;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Event\SubscriberInterface;
use Joomla\Plugin\Captcha\POWCaptcha\Provider\POWCaptchaProvider;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Proof of work captcha Plugin
* Based on the ALTCHA captcha library
*
* @since 6.1.0
*/
final class POWCaptcha extends CMSPlugin implements SubscriberInterface
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 6.1.0
*/
protected $autoloadLanguage = true;
public static function getSubscribedEvents(): array
{
return [
'onAjaxPowcaptcha' => 'handleAjaxRequest',
'onCaptchaSetup' => 'setupCaptcha',
];
}
/**
* Register Captcha instance
*
* @param CaptchaSetupEvent $event
*
* @return void
*/
public function setupCaptcha(CaptchaSetupEvent $event)
{
$event->getCaptchaRegistry()->add($this->getProvider());
}
/**
* Handles the ajax request triggered by altcha to fetch the challenge code
*
* @param AjaxEvent $event
*/
public function handleAjaxRequest(AjaxEvent $event)
{
$event->updateEventResult(
json_encode(
$this->getProvider()->getChallenge()
)
);
}
/**
* Returns the actual captcha provider instance
*
* @return POWCaptchaProvider
*/
protected function getProvider(): POWCaptchaProvider
{
return new POWCaptchaProvider(
$this->params,
$this->getApplication()
);
}
}
The same content is in 7 releases, Joomla 6.1.4-rc1 to 6.2.1-rc1. See them all, or every version of this file.