Version 4.7.23
This commit is contained in:
1 parent
7124a02564
commit
25ddeb65d6
1791 files changed
+76990
-44452
No files matched your search
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Cloudflare Turnstile
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 13 June 2025
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form\Captcha;
|
||||
|
||||
use IPS\Http\Request\Exception;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Log;
|
||||
use IPS\Member;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use RuntimeException;
|
||||
use function defined;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cloudflare Turnstile
|
||||
*/
|
||||
class _Turnstile implements CaptchaInterface
|
||||
{
|
||||
/**
|
||||
* Does this CAPTCHA service support being added in a modal?
|
||||
*/
|
||||
public static bool $supportsModal = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Error
|
||||
*/
|
||||
protected ?string $error;
|
||||
|
||||
/**
|
||||
* Display
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHtml(): string
|
||||
{
|
||||
return Theme::i()->getTemplate( 'forms', 'core', 'global' )->captchaTurnstile( $this->getTurnstileCredentials()['site_key'], preg_replace( '/^(.+?)\..*$/', '$1', Member::loggedIn()->language()->short ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify
|
||||
*
|
||||
* @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(): ?bool
|
||||
{
|
||||
try
|
||||
{
|
||||
$response = Url::external( 'https://challenges.cloudflare.com/turnstile/v0/siteverify' )->request(5)->post( [
|
||||
'secret' => $this->getTurnstileCredentials()['secret_key'],
|
||||
'response' => trim( Request::i()->__get('cf-turnstile-response') ),
|
||||
'remoteip' => Request::i()->ipAddress(),
|
||||
] )->decodeJson();
|
||||
|
||||
return ( ( $response['success'] ) and ( $response['hostname'] === Url::internal('')->data[ Url::COMPONENT_HOST ] ) );
|
||||
}
|
||||
catch( Exception $e )
|
||||
{
|
||||
Log::log( $e, 'turnstile_exception' );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
catch( RuntimeException $e )
|
||||
{
|
||||
if( $e->getMessage() == 'BAD_JSON' )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Turnstile credentials
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTurnstileCredentials(): array
|
||||
{
|
||||
return [
|
||||
'site_key' => Settings::i()->turnstile_site_key,
|
||||
'secret_key' => Settings::i()->turnstile_secret_key
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -35,8 +35,9 @@ class _Editor extends FormAbstract
|
||||
'foo'
|
||||
),
|
||||
'attachIdsLang' => NULL, // Language ID number if this Editor is part of a Translatable field.
|
||||
'minimize' => 'clickme', // Language string to use for minimized view. NULL will mean editor is not minimized.
|
||||
'minimize' => 'clickme', // Language string to use for minimized view. NULL will mean editor is not minimized.0
|
||||
'minimizeIcon' => 'flag-us', // Icon to use for minimized view
|
||||
'minimizeAfterReset' => FALSE, // Whether to minimize the editor after resetting (note resetting is handled by JS usually after AJAX submission)
|
||||
'allButtons' => FALSE, // Only used for the customisation ACP page. Do not use.
|
||||
'tags' => array(), // An array of extra insertable tags in key => value pair with key being what is inserted and value serving as a description
|
||||
'autoGrow' => FALSE, // Used to specify if editor should grow in size as content is added. Defaults to TRUE.
|
||||
@@ -59,6 +60,7 @@ class _Editor extends FormAbstract
|
||||
'attachIdsLang' => NULL,
|
||||
'minimize' => NULL,
|
||||
'minimizeIcon' => 'fa fa-comment-o',
|
||||
'minimizeAfterReset' => FALSE,
|
||||
'allButtons' => FALSE,
|
||||
'tags' => array(),
|
||||
'autoGrow' => TRUE,
|
||||
@@ -524,6 +526,7 @@ class _Editor extends FormAbstract
|
||||
}
|
||||
|
||||
/* Remove abandoned attachments */
|
||||
/* @note SELECT_FROM_WRITE_SERVER Added in d901b5446e4fca3fc88c55d2de19397aeafc8911 We need to fetch from the write server to make sure we have all recenty added attachments */
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_attachments', array( array( 'attach_id NOT IN(?)', \IPS\Db::i()->select( 'DISTINCT attachment_id', 'core_attachments_map', NULL, NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER ) ), array( 'attach_member_id=? AND attach_date<?', \IPS\Member::loggedIn()->member_id, time() - 86400 ) ) ) as $attachment )
|
||||
{
|
||||
try
|
||||
@@ -723,6 +726,7 @@ class _Editor extends FormAbstract
|
||||
{
|
||||
try
|
||||
{
|
||||
/* @note SELECT_FROM_WRITE_SERVER added 735824c35ab73cd81bd31cdfcc0435a71104f942 "RW DB issue with inserting data into core_temp_files and then reading it back" */
|
||||
$fileInfo = \IPS\Db::i()->select( 'requires_moderation, labels', 'core_files_temp', array( 'contents=?', (string) $file ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
$requiresModeration = (bool) $fileInfo['requires_moderation'];
|
||||
$labels = $fileInfo['labels'];
|
||||
|
||||
@@ -469,6 +469,10 @@ class _Node extends FormAbstract
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else if ( $this->options['clubs'] AND $this->options['permissionCheck'] == 'add' )
|
||||
{
|
||||
return 'add';
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( \IPS\Dispatcher::hasInstance() and \IPS\Dispatcher::i()->controllerLocation === 'front' ) ? 'view' : NULL;
|
||||
|
||||
@@ -321,7 +321,7 @@ class _Upload extends FormAbstract
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
\IPS\Log::log( $e, 'upload_failure' );
|
||||
\IPS\Log::debug( $e, 'upload_failure' );
|
||||
|
||||
$message = $e->getMessage();
|
||||
|
||||
|
||||
Reference in new issue
Block a user