Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+22 -14
View File
@@ -11,40 +11,48 @@
namespace IPS\Helpers\Form\Captcha;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Http\Url;
use IPS\Login;
use IPS\Request;
use IPS\Settings;
use IPS\Theme;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* keyCAPTCHA
*/
class _Keycaptcha implements CaptchaInterface
class Keycaptcha implements CaptchaInterface
{
/**
* Does this CAPTCHA service support being added in a modal?
*/
public static $supportsModal = FALSE;
public static bool $supportsModal = FALSE;
/**
* @brief Error
*/
protected $error;
protected ?string $error;
/**
* Display
*
* @return string
*/
public function getHtml()
public function getHtml(): string
{
$explodedKey = explode( '0', \IPS\Settings::i()->keycaptcha_privatekey, 2 );
$explodedKey = explode( '0', Settings::i()->keycaptcha_privatekey, 2 );
$uniq = md5( mt_rand() );
$sign = md5( $uniq . \IPS\Request::i()->ipAddress . $explodedKey[0] );
$sign = md5( $uniq . Request::i()->ipAddress . $explodedKey[0] );
$sign2 = md5( $uniq . $explodedKey[0] );
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->captchaKeycaptcha( $explodedKey[1], $uniq, $sign, $sign2 );
return Theme::i()->getTemplate( 'forms', 'core', 'global' )->captchaKeycaptcha( $explodedKey[1], $uniq, $sign, $sign2 );
}
/**
@@ -52,14 +60,14 @@ class _Keycaptcha implements CaptchaInterface
*
* @return bool|null TRUE/FALSE indicate if the test passed or not. NULL indicates the test failed, but the captcha system will display an error so we don't have to.
*/
public function verify()
public function verify(): ?bool
{
$explodedResponse = explode( '|', \IPS\Request::i()->keycaptcha );
$explodedKey = explode( '0', \IPS\Settings::i()->keycaptcha_privatekey );
$explodedResponse = explode( '|', Request::i()->keycaptcha );
$explodedKey = explode( '0', Settings::i()->keycaptcha_privatekey );
if( \IPS\Login::compareHashes( $explodedResponse[0], md5( 'accept' . $explodedResponse[1] . $explodedKey[0] . $explodedResponse[2] ) ) )
if( Login::compareHashes( $explodedResponse[0], md5( 'accept' . $explodedResponse[1] . $explodedKey[0] . $explodedResponse[2] ) ) )
{
if( (string) \IPS\Http\Url::external( $explodedResponse[2] )->request()->get() === '1' )
if( (string) Url::external( $explodedResponse[2] )->request()->get() === '1' )
{
return TRUE;
}