Файловый менеджер - Редактировать - /home/lmsyaran/public_html/pusher/captcha.tar
Назад
recaptcha/postinstall/actions.php 0000644 00000003026 15116741203 0013224 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage Captcha * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt * * This file contains the functions used by the com_postinstall code to deliver * the necessary post-installation messages for the end of life of reCAPTCHA V1. */ /** * Checks if the plugin is enabled and reCAPTCHA V1 is being used. If true then the * message about reCAPTCHA v1 EOL should be displayed. * * @return boolean * * @since 3.8.6 */ function recaptcha_postinstall_condition() { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('1') ->from($db->qn('#__extensions')) ->where($db->qn('name') . ' = ' . $db->q('plg_captcha_recaptcha')) ->where($db->qn('enabled') . ' = 1') ->where($db->qn('params') . ' LIKE ' . $db->q('%1.0%')); $db->setQuery($query); $enabled_plugins = $db->loadObjectList(); return count($enabled_plugins) === 1; } /** * Open the reCAPTCHA plugin so that they can update the settings to V2 and new keys. * * @return void * * @since 3.8.6 */ function recaptcha_postinstall_action() { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('extension_id') ->from($db->qn('#__extensions')) ->where($db->qn('name') . ' = ' . $db->q('plg_captcha_recaptcha')); $db->setQuery($query); $e_id = $db->loadResult(); $url = 'index.php?option=com_plugins&task=plugin.edit&extension_id=' . $e_id; JFactory::getApplication()->redirect($url); } recaptcha/recaptcha.php 0000644 00000023126 15116741203 0011145 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage Captcha * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Captcha\Google\HttpBridgePostRequestMethod; use Joomla\Utilities\IpHelper; /** * Recaptcha Plugin * Based on the official recaptcha library( https://packagist.org/packages/google/recaptcha ) * * @since 2.5 */ class PlgCaptchaRecaptcha extends JPlugin { /** * Load the language file on instantiation. * * @var boolean * @since 3.1 */ protected $autoloadLanguage = true; /** * Reports the privacy related capabilities for this plugin to site administrators. * * @return array * * @since 3.9.0 */ public function onPrivacyCollectAdminCapabilities() { $this->loadLanguage(); return array( JText::_('PLG_CAPTCHA_RECAPTCHA') => array( JText::_('PLG_RECAPTCHA_PRIVACY_CAPABILITY_IP_ADDRESS'), ) ); } /** * Initialise the captcha * * @param string $id The id of the field. * * @return Boolean True on success, false otherwise * * @since 2.5 * @throws \RuntimeException */ public function onInit($id = 'dynamic_recaptcha_1') { $pubkey = $this->params->get('public_key', ''); if ($pubkey === '') { throw new \RuntimeException(JText::_('PLG_RECAPTCHA_ERROR_NO_PUBLIC_KEY')); } if ($this->params->get('version', '1.0') === '1.0') { JHtml::_('jquery.framework'); $theme = $this->params->get('theme', 'clean'); $file = 'https://www.google.com/recaptcha/api/js/recaptcha_ajax.js'; JHtml::_('script', $file); JFactory::getDocument()->addScriptDeclaration('jQuery( document ).ready(function() {Recaptcha.create("' . $pubkey . '", "' . $id . '", {theme: "' . $theme . '",' . $this->_getLanguage() . 'tabindex: 0});});'); } else { // Load callback first for browser compatibility JHtml::_('script', 'plg_captcha_recaptcha/recaptcha.min.js', array('version' => 'auto', 'relative' => true)); $file = 'https://www.google.com/recaptcha/api.js?onload=JoomlaInitReCaptcha2&render=explicit&hl=' . JFactory::getLanguage()->getTag(); JHtml::_('script', $file); } return true; } /** * Gets the challenge HTML * * @param string $name The name of the field. Not Used. * @param string $id The id of the field. * @param string $class The class of the field. * * @return string The HTML to be embedded in the form. * * @since 2.5 */ public function onDisplay($name = null, $id = 'dynamic_recaptcha_1', $class = '') { $dom = new \DOMDocument('1.0', 'UTF-8'); $ele = $dom->createElement('div'); $ele->setAttribute('id', $id); if ($this->params->get('version', '1.0') === '1.0') { $ele->setAttribute('class', $class); } else { $ele->setAttribute('class', ((trim($class) == '') ? 'g-recaptcha' : ($class . ' g-recaptcha'))); $ele->setAttribute('data-sitekey', $this->params->get('public_key', '')); $ele->setAttribute('data-theme', $this->params->get('theme2', 'light')); $ele->setAttribute('data-size', $this->params->get('size', 'normal')); $ele->setAttribute('data-tabindex', $this->params->get('tabindex', '0')); $ele->setAttribute('data-callback', $this->params->get('callback', '')); $ele->setAttribute('data-expired-callback', $this->params->get('expired_callback', '')); $ele->setAttribute('data-error-callback', $this->params->get('error_callback', '')); } $dom->appendChild($ele); return $dom->saveHTML($ele); } /** * Calls an HTTP POST function to verify if the user's guess was correct * * @param string $code Answer provided by user. Not needed for the Recaptcha implementation * * @return True if the answer is correct, false otherwise * * @since 2.5 * @throws \RuntimeException */ public function onCheckAnswer($code = null) { $input = \JFactory::getApplication()->input; $privatekey = $this->params->get('private_key'); $version = $this->params->get('version', '1.0'); $remoteip = IpHelper::getIp(); switch ($version) { case '1.0': $challenge = $input->get('recaptcha_challenge_field', '', 'string'); $response = $code ? $code : $input->get('recaptcha_response_field', '', 'string'); $spam = ($challenge === '' || $response === ''); break; case '2.0': // Challenge Not needed in 2.0 but needed for getResponse call $challenge = null; $response = $code ? $code : $input->get('g-recaptcha-response', '', 'string'); $spam = ($response === ''); break; } // Check for Private Key if (empty($privatekey)) { throw new \RuntimeException(JText::_('PLG_RECAPTCHA_ERROR_NO_PRIVATE_KEY')); } // Check for IP if (empty($remoteip)) { throw new \RuntimeException(JText::_('PLG_RECAPTCHA_ERROR_NO_IP')); } // Discard spam submissions if ($spam) { throw new \RuntimeException(JText::_('PLG_RECAPTCHA_ERROR_EMPTY_SOLUTION')); } return $this->getResponse($privatekey, $remoteip, $response, $challenge); } /** * Get the reCaptcha response. * * @param string $privatekey The private key for authentication. * @param string $remoteip The remote IP of the visitor. * @param string $response The response received from Google. * @param string $challenge The challenge field from the reCaptcha. Only for 1.0 * * @return bool True if response is good | False if response is bad. * * @since 3.4 * @throws \RuntimeException */ private function getResponse($privatekey, $remoteip, $response, $challenge = null) { $version = $this->params->get('version', '1.0'); switch ($version) { case '1.0': $response = $this->_recaptcha_http_post( 'www.google.com', '/recaptcha/api/verify', array( 'privatekey' => $privatekey, 'remoteip' => $remoteip, 'challenge' => $challenge, 'response' => $response ) ); $answers = explode("\n", $response[1]); if (trim($answers[0]) !== 'true') { // @todo use exceptions here $this->_subject->setError(JText::_('PLG_RECAPTCHA_ERROR_' . strtoupper(str_replace('-', '_', $answers[1])))); return false; } break; case '2.0': $reCaptcha = new \ReCaptcha\ReCaptcha($privatekey, new HttpBridgePostRequestMethod); $response = $reCaptcha->verify($response, $remoteip); if (!$response->isSuccess()) { foreach ($response->getErrorCodes() as $error) { throw new \RuntimeException($error); } return false; } break; } return true; } /** * Encodes the given data into a query string format. * * @param array $data Array of string elements to be encoded * * @return string Encoded request * * @since 2.5 */ private function _recaptcha_qsencode($data) { $req = ''; foreach ($data as $key => $value) { $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; } // Cut the last '&' $req = rtrim($req, '&'); return $req; } /** * Submits an HTTP POST to a reCAPTCHA server. * * @param string $host Host name to POST to. * @param string $path Path on host to POST to. * @param array $data Data to be POSTed. * @param int $port Optional port number on host. * * @return array Response * * @since 2.5 */ private function _recaptcha_http_post($host, $path, $data, $port = 80) { $req = $this->_recaptcha_qsencode($data); $http_request = "POST $path HTTP/1.0\r\n"; $http_request .= "Host: $host\r\n"; $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; $http_request .= "Content-Length: " . strlen($req) . "\r\n"; $http_request .= "User-Agent: reCAPTCHA/PHP\r\n"; $http_request .= "\r\n"; $http_request .= $req; $response = ''; if (($fs = @fsockopen($host, $port, $errno, $errstr, 10)) === false) { die('Could not open socket'); } fwrite($fs, $http_request); while (!feof($fs)) { // One TCP-IP packet $response .= fgets($fs, 1160); } fclose($fs); $response = explode("\r\n\r\n", $response, 2); return $response; } /** * Get the language tag or a custom translation * * @return string * * @since 2.5 */ private function _getLanguage() { $language = JFactory::getLanguage(); $tag = explode('-', $language->getTag()); $tag = $tag[0]; $available = array('en', 'pt', 'fr', 'de', 'nl', 'ru', 'es', 'tr'); if (in_array($tag, $available)) { return "lang : '" . $tag . "',"; } // If the default language is not available, let's search for a custom translation if ($language->hasKey('PLG_RECAPTCHA_CUSTOM_LANG')) { $custom[] = 'custom_translations : {'; $custom[] = "\t" . 'instructions_visual : "' . JText::_('PLG_RECAPTCHA_INSTRUCTIONS_VISUAL') . '",'; $custom[] = "\t" . 'instructions_audio : "' . JText::_('PLG_RECAPTCHA_INSTRUCTIONS_AUDIO') . '",'; $custom[] = "\t" . 'play_again : "' . JText::_('PLG_RECAPTCHA_PLAY_AGAIN') . '",'; $custom[] = "\t" . 'cant_hear_this : "' . JText::_('PLG_RECAPTCHA_CANT_HEAR_THIS') . '",'; $custom[] = "\t" . 'visual_challenge : "' . JText::_('PLG_RECAPTCHA_VISUAL_CHALLENGE') . '",'; $custom[] = "\t" . 'audio_challenge : "' . JText::_('PLG_RECAPTCHA_AUDIO_CHALLENGE') . '",'; $custom[] = "\t" . 'refresh_btn : "' . JText::_('PLG_RECAPTCHA_REFRESH_BTN') . '",'; $custom[] = "\t" . 'help_btn : "' . JText::_('PLG_RECAPTCHA_HELP_BTN') . '",'; $custom[] = "\t" . 'incorrect_try_again : "' . JText::_('PLG_RECAPTCHA_INCORRECT_TRY_AGAIN') . '",'; $custom[] = '},'; $custom[] = "lang : '" . $tag . "',"; return implode("\n", $custom); } // If nothing helps fall back to english return ''; } } recaptcha/recaptcha.xml 0000644 00000007423 15116741203 0011160 0 ustar 00 <?xml version="1.0" encoding="utf-8"?> <extension version="3.4" type="plugin" group="captcha" method="upgrade"> <name>plg_captcha_recaptcha</name> <version>3.4.0</version> <creationDate>December 2011</creationDate> <author>Joomla! Project</author> <authorEmail>admin@joomla.org</authorEmail> <authorUrl>www.joomla.org</authorUrl> <copyright>(C) 2011 Open Source Matters, Inc.</copyright> <license>GNU General Public License version 2 or later; see LICENSE.txt</license> <description>PLG_CAPTCHA_RECAPTCHA_XML_DESCRIPTION</description> <files> <filename plugin="recaptcha">recaptcha.php</filename> </files> <languages> <language tag="en-GB">en-GB.plg_captcha_recaptcha.ini</language> <language tag="en-GB">en-GB.plg_captcha_recaptcha.sys.ini</language> </languages> <config> <fields name="params"> <fieldset name="basic"> <field name="message" type="note" label="PLG_RECAPTCHA_VERSION_1_WARNING_LABEL" showon="version:1.0" /> <field name="version" type="list" label="PLG_RECAPTCHA_VERSION_LABEL" description="PLG_RECAPTCHA_VERSION_DESC" default="2.0" size="1" > <option value="1.0">PLG_RECAPTCHA_VERSION_V1</option> <option value="2.0">PLG_RECAPTCHA_VERSION_V2</option> </field> <field name="public_key" type="text" label="PLG_RECAPTCHA_PUBLIC_KEY_LABEL" description="PLG_RECAPTCHA_PUBLIC_KEY_DESC" default="" required="true" filter="string" size="100" class="input-xxlarge" /> <field name="private_key" type="text" label="PLG_RECAPTCHA_PRIVATE_KEY_LABEL" description="PLG_RECAPTCHA_PRIVATE_KEY_DESC" default="" required="true" filter="string" size="100" class="input-xxlarge" /> <field name="theme" type="list" label="PLG_RECAPTCHA_THEME_LABEL" description="PLG_RECAPTCHA_THEME_DESC" default="clean" showon="version:1.0" filter="" > <option value="clean">PLG_RECAPTCHA_THEME_CLEAN</option> <option value="white">PLG_RECAPTCHA_THEME_WHITE</option> <option value="blackglass">PLG_RECAPTCHA_THEME_BLACKGLASS</option> <option value="red">PLG_RECAPTCHA_THEME_RED</option> </field> <field name="theme2" type="list" label="PLG_RECAPTCHA_THEME_LABEL" description="PLG_RECAPTCHA_THEME_DESC" default="light" showon="version:2.0" filter="" > <option value="light">PLG_RECAPTCHA_THEME_LIGHT</option> <option value="dark">PLG_RECAPTCHA_THEME_DARK</option> </field> <field name="size" type="list" label="PLG_RECAPTCHA_SIZE_LABEL" description="PLG_RECAPTCHA_SIZE_DESC" default="normal" showon="version:2.0" filter="" > <option value="normal">PLG_RECAPTCHA_THEME_NORMAL</option> <option value="compact">PLG_RECAPTCHA_THEME_COMPACT</option> </field> <field name="tabindex" type="number" label="PLG_RECAPTCHA_TABINDEX_LABEL" description="PLG_RECAPTCHA_TABINDEX_DESC" default="0" showon="version:2.0" min="0" /> <field name="callback" type="text" label="PLG_RECAPTCHA_CALLBACK_LABEL" description="PLG_RECAPTCHA_CALLBACK_DESC" default="" showon="version:2.0" filter="string" /> <field name="expired_callback" type="text" label="PLG_RECAPTCHA_EXPIRED_CALLBACK_LABEL" description="PLG_RECAPTCHA_EXPIRED_CALLBACK_DESC" default="" showon="version:2.0" filter="string" /> <field name="error_callback" type="text" label="PLG_RECAPTCHA_ERROR_CALLBACK_LABEL" description="PLG_RECAPTCHA_ERROR_CALLBACK_DESC" default="" showon="version:2.0" filter="string" /> </fieldset> </fields> </config> </extension> recaptcha_invisible/recaptcha_invisible.php 0000644 00000012704 15116741203 0015255 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage Captcha * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Captcha\Google\HttpBridgePostRequestMethod; use Joomla\Utilities\IpHelper; /** * Invisible reCAPTCHA Plugin. * * @since 3.9.0 */ class PlgCaptchaRecaptcha_Invisible extends \JPlugin { /** * Load the language file on instantiation. * * @var boolean * @since 3.9.0 */ protected $autoloadLanguage = true; /** * Reports the privacy related capabilities for this plugin to site administrators. * * @return array * * @since 3.9.0 */ public function onPrivacyCollectAdminCapabilities() { $this->loadLanguage(); return array( JText::_('PLG_CAPTCHA_RECAPTCHA_INVISIBLE') => array( JText::_('PLG_RECAPTCHA_INVISIBLE_PRIVACY_CAPABILITY_IP_ADDRESS'), ) ); } /** * Initialise the captcha * * @param string $id The id of the field. * * @return boolean True on success, false otherwise * * @since 3.9.0 * @throws \RuntimeException */ public function onInit($id = 'dynamic_recaptcha_invisible_1') { $pubkey = $this->params->get('public_key', ''); if ($pubkey === '') { throw new \RuntimeException(JText::_('PLG_RECAPTCHA_INVISIBLE_ERROR_NO_PUBLIC_KEY')); } // Load callback first for browser compatibility \JHtml::_( 'script', 'plg_captcha_recaptcha_invisible/recaptcha.min.js', array('version' => 'auto', 'relative' => true), array('async' => 'async', 'defer' => 'defer') ); // Load Google reCAPTCHA api js $file = 'https://www.google.com/recaptcha/api.js' . '?onload=JoomlaInitReCaptchaInvisible' . '&render=explicit' . '&hl=' . \JFactory::getLanguage()->getTag(); \JHtml::_( 'script', $file, array(), array('async' => 'async', 'defer' => 'defer') ); return true; } /** * Gets the challenge HTML * * @param string $name The name of the field. Not Used. * @param string $id The id of the field. * @param string $class The class of the field. * * @return string The HTML to be embedded in the form. * * @since 3.9.0 */ public function onDisplay($name = null, $id = 'dynamic_recaptcha_invisible_1', $class = '') { $dom = new \DOMDocument('1.0', 'UTF-8'); $ele = $dom->createElement('div'); $ele->setAttribute('id', $id); $ele->setAttribute('class', ((trim($class) == '') ? 'g-recaptcha' : ($class . ' g-recaptcha'))); $ele->setAttribute('data-sitekey', $this->params->get('public_key', '')); $ele->setAttribute('data-badge', $this->params->get('badge', 'bottomright')); $ele->setAttribute('data-size', 'invisible'); $ele->setAttribute('data-tabindex', $this->params->get('tabindex', '0')); $ele->setAttribute('data-callback', $this->params->get('callback', '')); $ele->setAttribute('data-expired-callback', $this->params->get('expired_callback', '')); $ele->setAttribute('data-error-callback', $this->params->get('error_callback', '')); $dom->appendChild($ele); return $dom->saveHTML($ele); } /** * Calls an HTTP POST function to verify if the user's guess was correct * * @param string $code Answer provided by user. Not needed for the Recaptcha implementation * * @return boolean True if the answer is correct, false otherwise * * @since 3.9.0 * @throws \RuntimeException */ public function onCheckAnswer($code = null) { $input = \JFactory::getApplication()->input; $privatekey = $this->params->get('private_key'); $remoteip = IpHelper::getIp(); $response = $input->get('g-recaptcha-response', '', 'string'); // Check for Private Key if (empty($privatekey)) { throw new \RuntimeException(JText::_('PLG_RECAPTCHA_INVISIBLE_ERROR_NO_PRIVATE_KEY')); } // Check for IP if (empty($remoteip)) { throw new \RuntimeException(JText::_('PLG_RECAPTCHA_INVISIBLE_ERROR_NO_IP')); } // Discard spam submissions if (trim($response) == '') { throw new \RuntimeException(JText::_('PLG_RECAPTCHA_INVISIBLE_ERROR_EMPTY_SOLUTION')); } return $this->getResponse($privatekey, $remoteip, $response); } /** * Method to react on the setup of a captcha field. Gives the possibility * to change the field and/or the XML element for the field. * * @param \Joomla\CMS\Form\Field\CaptchaField $field Captcha field instance * @param \SimpleXMLElement $element XML form definition * * @return void * * @since 3.9.0 */ public function onSetupField(\Joomla\CMS\Form\Field\CaptchaField $field, \SimpleXMLElement $element) { // Hide the label for the invisible recaptcha type $element['hiddenLabel'] = true; } /** * Get the reCaptcha response. * * @param string $privatekey The private key for authentication. * @param string $remoteip The remote IP of the visitor. * @param string $response The response received from Google. * * @return boolean True if response is good | False if response is bad. * * @since 3.9.0 * @throws \RuntimeException */ private function getResponse($privatekey, $remoteip, $response) { $reCaptcha = new \ReCaptcha\ReCaptcha($privatekey, new HttpBridgePostRequestMethod); $response = $reCaptcha->verify($response, $remoteip); if (!$response->isSuccess()) { foreach ($response->getErrorCodes() as $error) { throw new \RuntimeException($error); } return false; } return true; } } recaptcha_invisible/recaptcha_invisible.xml 0000644 00000005374 15116741203 0015273 0 ustar 00 <?xml version="1.0" encoding="utf-8"?> <extension version="3.8" type="plugin" group="captcha" method="upgrade"> <name>plg_captcha_recaptcha_invisible</name> <version>3.8</version> <creationDate>November 2017</creationDate> <author>Joomla! Project</author> <authorEmail>admin@joomla.org</authorEmail> <authorUrl>www.joomla.org</authorUrl> <copyright>(C) 2017 Open Source Matters, Inc.</copyright> <license>GNU General Public License version 2 or later; see LICENSE.txt</license> <description>PLG_CAPTCHA_RECAPTCHA_INVISIBLE_XML_DESCRIPTION</description> <files> <filename plugin="recaptcha_invisible">recaptcha_invisible.php</filename> </files> <languages> <language tag="en-GB">en-GB.plg_captcha_recaptcha_invisible.ini</language> <language tag="en-GB">en-GB.plg_captcha_recaptcha_invisible.sys.ini</language> </languages> <config> <fields name="params"> <fieldset name="basic"> <field name="public_key" type="text" label="PLG_RECAPTCHA_INVISIBLE_PUBLIC_KEY_LABEL" description="PLG_RECAPTCHA_INVISIBLE_PUBLIC_KEY_DESC" default="" required="true" filter="string" size="100" class="input-xxlarge" /> <field name="private_key" type="text" label="PLG_RECAPTCHA_INVISIBLE_PRIVATE_KEY_LABEL" description="PLG_RECAPTCHA_INVISIBLE_PRIVATE_KEY_DESC" default="" required="true" filter="string" size="100" class="input-xxlarge" /> <field name="badge" type="list" label="PLG_RECAPTCHA_INVISIBLE_BADGE_LABEL" description="PLG_RECAPTCHA_INVISIBLE_BADGE_DESC" default="bottomright" > <option value="bottomright">PLG_RECAPTCHA_INVISIBLE_BADGE_BOTTOMRIGHT</option> <option value="bottomleft">PLG_RECAPTCHA_INVISIBLE_BADGE_BOTTOMLEFT</option> <option value="inline">PLG_RECAPTCHA_INVISIBLE_BADGE_INLINE</option> </field> <field name="tabindex" type="number" label="PLG_RECAPTCHA_INVISIBLE_TABINDEX_LABEL" description="PLG_RECAPTCHA_INVISIBLE_TABINDEX_DESC" default="0" min="0" filter="integer" /> <field name="callback" type="text" label="PLG_RECAPTCHA_INVISIBLE_CALLBACK_LABEL" description="PLG_RECAPTCHA_INVISIBLE_CALLBACK_DESC" default="" filter="string" /> <field name="expired_callback" type="text" label="PLG_RECAPTCHA_INVISIBLE_EXPIRED_CALLBACK_LABEL" description="PLG_RECAPTCHA_INVISIBLE_EXPIRED_CALLBACK_DESC" default="" filter="string" /> <field name="error_callback" type="text" label="PLG_RECAPTCHA_INVISIBLE_ERROR_CALLBACK_LABEL" description="PLG_RECAPTCHA_INVISIBLE_ERROR_CALLBACK_DESC" default="" filter="string" /> </fieldset> </fields> </config> </extension>
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка