Joomla.it Forum
Joomla! 3 => Joomla! 3 => : dali 12 Nov 2013, 19:32:36
-
Ho creato il modulo contatti, ho chiesto le keys a Captcha e le ho avute, ho attivato il plugin relativo e nella configurazione del sito ho messo Captcha/Recaptcha cosi' come nell'utente in gestione utenti.
Perche' l'immagine Captcha non si vede?
-
edit: eccola!!!
http://www.joomla.it/articoli-community-16-e-17-tab/7315-joomla-25-plugin-recaptcha-e-sparito.html
in alternativa: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=32576
-
google ha cambiato indirizzo delle apikey, quindi per adesso e almeno fino al prossimo aggiornamento non funzionano i captcha.
c'è una discussione di questi giorni con la soluzione da adottare.
-
Ho provato a modificare il plugin php a cui si fa riferimento nel primo articolo ma le righe su cui intervenire non corrispondono e mi risulta, dopo un'accurata ricerca, che non ci siano. In ogni caso questo e' il php del plugin :
Edited: eliminato codice
-
Ciao dali,
ho eliminato il codice tanto ce l'abbiamo tutti.
Le stringhe da cambiare comunque erano presenti.
Qui trovi come fare per la versione 3.x
Il file da editare è:
plugins/captcha/recaptcha/recaptcha.php
https://github.com/joomla/joomla-cms/pull/2437/files
-
Ho sostituito i codici e ora e' tutto OK
-
OK, va tutto bene. Grazie per la disponibilità
Francesco :D
-
Benche sia risolto vorrei aggiungere una nota, avendo avuto lo stesso problema e pur cambiando le stringhe in oggetto sul file recaptcha.php non sono riuscito a risolvere, poi mi è venuto in mente che avevo attivato anche il recaptcha su K2 con le stesse chiavi del pannello di configurazione di joomla, mi e bastato creare un altro set di chiavi sempre per lo stesso sito e tutto a ripresoa funzionare correttamente.
Quindi, se non ho scoperto l'acqua calda... , credo che se recaptcha è attivo su un altro componente in questo caso K2, le chiavi devono essere diverse altrimenti uno non funziona .... sara giusta questa mia riflessione? be adesso funziona :)
-
Salve.
Nell'articolo della community ho trovato un errore. Difatti pur modificando il file recaptcha.php secondo le istruzioni ancora non era visibile.
Qui inserisco il codice che adesso funziona.
<?php
/**
* @package Joomla.Plugin
* @subpackage Captcha
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.environment.browser');
/**
* Recaptcha Plugin.
* Based on the official recaptcha library( https://developers.google.com/recaptcha/docs/php )
*
* @package Joomla.Plugin
* @subpackage Captcha
* @since 2.5
*/
class plgCaptchaRecaptcha extends JPlugin
{
const RECAPTCHA_API_SERVER = "http://www.google.com/recaptcha/api";
const RECAPTCHA_API_SECURE_SERVER = "https://www.google.com/recaptcha/api";
const RECAPTCHA_VERIFY_SERVER = "www.google.com";
public function __construct($subject, $config)
{
parent::__construct($subject, $config);
$this->loadLanguage();
}
/**
* Initialise the captcha
*
* @param string $id The id of the field.
*
* @return Boolean True on success, false otherwise
*
* @since 2.5
*/
public function onInit($id)
{
// Initialise variables
$lang = $this->_getLanguage();
$pubkey = $this->params->get('public_key', '');
$theme = $this->params->get('theme', 'clean');
if ($pubkey == null || $pubkey == '')
{
throw new Exception(JText::_('PLG_RECAPTCHA_ERROR_NO_PUBLIC_KEY'));
}
$server = self::RECAPTCHA_API_SERVER;
if (JBrowser::getInstance()->isSSLConnection())
{
$server = self::RECAPTCHA_API_SECURE_SERVER;
}
JHtml::_('script', $server.'/js/recaptcha_ajax.js');
$document = JFactory::getDocument();
$document->addScriptDeclaration('window.addEvent(\'domready\', function() {
Recaptcha.create("'.$pubkey.'", "dynamic_recaptcha_1", {theme: "'.$theme.'",'.$lang.'tabindex: 0});});'
);
return true;
}
/**
* Gets the challenge HTML
*
* @return string The HTML to be embedded in the form.
*
* @since 2.5
*/
public function onDisplay($name, $id, $class)
{
return '<div id="dynamic_recaptcha_1"><>';
}
/**
* Calls an HTTP POST function to verify if the user's guess was correct
*
* @return True if the answer is correct, false otherwise
*
* @since 2.5
*/
public function onCheckAnswer($code)
{
// Initialise variables
$privatekey = $this->params->get('private_key');
$remoteip = JRequest::getVar('REMOTE_ADDR', '', 'SERVER');
$challenge = JRequest::getString('recaptcha_challenge_field', '');
$response = JRequest::getString('recaptcha_response_field', '');;
// Check for Private Key
if (empty($privatekey))
{
$this->_subject->setError(JText::_('PLG_RECAPTCHA_ERROR_NO_PRIVATE_KEY'));
return false;
}
// Check for IP
if (empty($remoteip))
{
$this->_subject->setError(JText::_('PLG_RECAPTCHA_ERROR_NO_IP'));
return false;
}
// Discard spam submissions
if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0)
{
$this->_subject->setError(JText::_('PLG_RECAPTCHA_ERROR_EMPTY_SOLUTION'));
return false;
}
$response = $this->_recaptcha_http_post(self::RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
array(
'privatekey' => $privatekey,
'remoteip' => $remoteip,
'challenge' => $challenge,
'response' => $response
)
);
$answers = explode("\n", $response[1]);
if (trim($answers[0]) == 'true') {
return true;
}
else
{
//@todo use exceptions here
$this->_subject->setError(JText::_('PLG_RECAPTCHA_ERROR_'.strtoupper(str_replace('-', '_', $answers[1]))));
return false;
}
}
/**
* Encodes the given data into a query string format.
*
* @param string $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
* @param string $path
* @param array $data
* @param int $port
*
* @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()
{
// Initialise variables
$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 '';
}
}
Basta copiare e incollare tutto.
Alla prossima.
-
Salve a tutti,
premesso che:
-la mia versione di joomla è la 3.2.1 (ed è la prima volta che la uso);
-ho attivato il plugin captcha-recaptcha;
-ho scelto il suddetto plugin come predefinito nella configurazione del sito;
-ho inserito le key di Google;
-ho già eseguito con successo la procedura su installazioni con joomla 2.5;
-ho provato la procedura descritta in questa discussione, ma le righe da modificare erano già scritte nel modo corretto;
- ho provato a copiare ed incollare l'intero script di artenelweb nel file recaptcha.php col solo effetto di ottenere invece dell'immagine captcha questi "<>";
-la mia istallazione è praticamente vergine, cioè ci sono 2 articoli, uno slideshow ed un template e nient'arltro.
Comunque non riesco a visualizzare il captcha nel modulo contatto.
che fare?
Grazie in anticipo per l'interessamento.
p.s. il sito in questione è www.volontary.it
-
nessuno può aiutarmi?
grazie e buone feste... :P
-
Accodarsi ad un topic risolto difficilmente si ricev aiuto. Aprine uno tutto tuo perché nessun problema in genere è proprio uguale ad un altro e di conseguenza le soluzioni.
-
Grazie per la risposta, in realtà ci avevo pensato, ma pensavo che, chi ha partecipato vedesse ancora le nuove risposte... comunque farò come dici grazie.