Файловый менеджер - Редактировать - /var/www/html/components/com_community/helpers/captcha/cloudflare.php
Ðазад
<?php use Joomla\CMS\Factory; use Joomla\CMS\Http\Http; use Joomla\Registry\Registry; defined('_JEXEC') or die('Restricted access'); class CloudflareCCaptchaHelper { public $enabled = false; public $ip; private $privateKey; private $publicKey; private $theme; private $apiUrl; private $verifyUrl; /* * Load config data and object vars */ public function __construct() { // Config data $config = CFactory::getConfig(); $this->enabled = $config->get('nocloudflare', false); $this->privateKey = $config->get('cloudflareprivate'); $this->publicKey = $config->get('cloudflarepublic'); $this->apiUrl = $config->get('cloudflare_server'); $this->theme = $config->get('cloudflaretheme'); $this->verifyUrl = $config->get('cloudflare_server_verify'); // Grab the IP, remember load balancers // @todo is there a framework way to do it? $this->ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; // If any of the vital vars is missing, disable the whole thing if (!$this->privateKey || !$this->publicKey || !$this->apiUrl || !$this->verifyUrl) { $this->enabled = false; } } public function html() { if (!$this->enabled) { return ''; } // start output buffer, if cloudflare is enabled add HTML and JS to the buffer ob_start(); ?> <div id="joms-cloudflare"></div> <script type="text/javascript"> const form = document.getElementsByTagName('form'); var jomsCloudflareCaptchaCallback = function() { turnstile.render("#joms-cloudflare", { "sitekey": "<?php echo $this->publicKey; ?>", "theme": "<?php echo $this->theme; ?>", callback: function(token) { jQuery(form).append('<input name="g-cloudflare-response" type="hidden" value="' + token + '" />'); }, }) }; </script> <script src="<?php echo $this->apiUrl; ?>?onload=jomsCloudflareCaptchaCallback"></script> <?php // get the contents of te buffer and return it $html = ob_get_clean(); return $html; } public function verify() { // get the Recaptcha response from the form data $token = Factory::getApplication()->input->get('g-cloudflare-response'); if (!$token) return false; $http = new Http(); try { $response = $http->post( $this->verifyUrl, array( 'secret' => $this->privateKey, 'remoteip' => $this->ip, 'response' => $token, ) ); } catch (Exception $e) { dump($e); return false; } if ($response->code !== 200) { return false; } $result = new Registry($response->body); if ($result->get('success')) { return true; } return false; } }
| ver. 1.1 | |
.
| PHP 8.4.18 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка