4images Forum & Community
4images Modifications / Modifikationen => Templates & Styles (Releases & Support) => Topic started by: V@no on October 03, 2008, 03:57:30 AM
-
This mod will replace 4images default captcha graphic with more advanced reCAPTCHA (http://recaptcha.net)
Step 1
Register at http://recaptcha.net
Once registered, go to "My account" -> "My sites" and add each domain where you want use reCAPTCHA.
Then go to "My account" -> "My sites" and click on each domain you've added, it will show you Public Key and Private Key, write them down, you'll need them in next step.
Download PHP plugin (http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest), extract it and upload recaptchalib.php into 4images includes/ folder
Step 2
Open global.php
Find:
$captcha_filter_bg = 1;
Insert BELOW:
$captcha_recaptcha = 1; //0 = disable; 1 = enable with auto domain select; "yourdomain" = for one specific domain only, this domain must be specified in $recaptcha_domains below
//$captcha_recaptcha = "yourdomain2"; //use only reCAPTCHA keys for yourdomain2
$recaptcha_domains['yourdomain1'] = array("public key for yourdomain1", "private key for yourdomain1");
/*//to add more then one domain:
$recaptcha_domains['example.com'] = array("public key for example.com", "private key for example.com");
$recaptcha_domains['4homepages.de'] = array("asdfasdfasdf", "a98sd7as9df7as");
$recaptcha_domains['google.com'] = array("23kj423h42k", "8fas9d8a9sdf9a");
*/
if ($captcha_enable && $captcha_recaptcha
&& (isset($recaptcha_domains[$captcha_recaptcha])
|| isset($recaptcha_domains[strtolower($_SERVER["HTTP_HOST"])])))
{
$captcha_recaptcha = (isset($recaptcha_domains[$captcha_recaptcha]))
? $recaptcha_domains[$captcha_recaptcha]
: $recaptcha_domains[strtolower($_SERVER["HTTP_HOST"])];
}
else
{
$captcha_recaptcha = 0;
}
In the code you just inserted update $recaptcha_domains['yourdomain1'] = array("public key for yourdomain1", "private key for yourdomain1"); with the correct data, yourdomain1 replace with the domain name of your website. public key for yourdomain1 and private key for yourdomain1 with the public and private keys from Step 1.
You can add as many domains as you wish.
Step 3
Open includes/captcha_utils.php
Find:
$captcha_enable = $captcha_enable && function_exists("imagecreatetruecolor") && function_exists("imagecopyresampled");
Replace it with:function recaptcha_image()
{
global $captcha_recaptcha;
if ($captcha_recaptcha)
{
require_once(ROOT_PATH . 'includes/recaptchalib.php');
return recaptcha_get_html($captcha_recaptcha[0]);
}
}
if (!$captcha_recaptcha)
{
$captcha_enable = $captcha_enable && function_exists("imagecreatetruecolor") && function_exists("imagecopyresampled");
}
Step 3.1
Find:
$sess_code = trim($site_sess->get_session_var('captcha'));
Insert ABOVE:
global $captcha_recaptcha, $HTTP_POST_VARS;
if ($captcha_recaptcha)
{
require_once(ROOT_PATH . 'includes/recaptchalib.php');
$resp = recaptcha_check_answer ($captcha_recaptcha[1],
$_SERVER["REMOTE_ADDR"],
$HTTP_POST_VARS["recaptcha_challenge_field"],
$HTTP_POST_VARS["recaptcha_response_field"]);
if ($resp->is_valid)
return true;
}
Step 4
Open includes/page_header.php
Find:
"url_captcha_image" => $site_sess->url(ROOT_PATH."captcha.php"),
Insert BELOW::
"recaptcha" => ($captcha_recaptcha) ? recaptcha_image() : "",
"recaptcha_public" => @$captcha_recaptcha[0],
"recaptcha_private" => @$captcha_recaptcha[1],
Step 5
In templates comment_form.html, member_uploadform.html, postcard_preview.html, register_form.html and in any others where you were using captcha, use this tag:
{recaptcha}
If you wish to customize reCAPTCHA view to match your site theme or whatever, you probably will need do it via javascript (don't ask me how, I don't know), in that case you might need public or private key, for that you can use these tags:
{recaptcha_public}
{recaptcha_private}
P.S.
You can use both 4images built-in captcha and reCAPTCHA at the same time if you wish.
-
works cool! POwer to the books and the blind people! Cool audio captcha.. first I was thinking... what the? but very cool.. better than entering numbers like a machiene :)
-
Hi,
I feel stupid for asking, but I can't figure out how to incorporate the {recaptcha} into the pages. I would like to completely replace the 4Images Captcha with the reCaptcha mod. Can someone help me properly on how to substitute. I thought I added the tag in correctly, but nothing is showing up...
Original register_form.html block of code...
<td class="row2"><b>{lang_password}</b></td>
<td class="row2"><input type="password" name="user_password" size="30" class="input" /></td>
</tr>
<tr>
<td class="row1"><b>{lang_email}</b></td>
<td class="row1"><input type="text" name="user_email" size="30" class="input" value="{user_email}" /></td>
</tr>
{if captcha_registration}
<tr>
<td class="row1" valign="top"><b>{lang_captcha}</b></td>
<td class="row1">
<a href="javascript:new_captcha_image();"><img src="{url_captcha_image}" border="0" id="captcha_image" /></a> <br />
<input type="text" name="captcha" size="30" value="" class="commentinput" id="captcha_input" />
<br />
{lang_captcha_desc}
</td>
</tr>
{endif captcha_registration}
</table>
</td>
</tr>
-
Where is {recaptcha} tag?
And make sure you did steps 1 and 2 properly.
-
I forgot to implement the PHP Plugin from the first step. I redid the other steps, but feel like I'm improperly adding the {recaptcha} string to the files. I have been testing it on the register_form.html. Below is the full modified script from that file. As of right now, nothing is showing up.
{lang_register_msg}
<form method="POST" action="{url_register}">
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td valign="top" class="head1">
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td colspan="2" valign="top" class="head1">{lang_register}</td>
</tr>
<tr>
<td class="row1"><b>{lang_user_name}</b></td>
<td class="row1"><input type="text" name="user_name" size="30" value="{user_name}" class="input" /></td>
</tr>
<tr>
<td class="row2"><b>{lang_password}</b></td>
<td class="row2"><input type="password" name="user_password" size="30" class="input" /></td>
</tr>
<tr>
<td class="row1"><b>{lang_email}</b></td>
<td class="row1"><input type="text" name="user_email" size="30" class="input" value="{user_email}" /></td>
</tr>
{if captcha_registration}
<tr>
<td class="row1" valign="top"><b>{lang_captcha}</b></td>
<td class="row1">{recaptcha}
</td>
</tr>
{endif captcha_registration}
</table>
</td>
</tr>
</table>
<input type="hidden" name="action" value="register" />
<p align="center">
<input type="submit" value="{lang_submit}" class="button" />
<input type="reset" value="{lang_reset}" class="button" />
</p>
</form>
Here is the test page, since I am newly creating the complete script, I will then move it over to my site...
http://www.savegasforums.com/register.php
^^^ You can see the reCAPTCHA isn't showing up.
Thanks in advance!
-
make sure you've registered savegasforums.com at your recaptcha account (step 1) and in step 2 you added the correct public and private keys for the domain.
-
Man, is this odd! Apparently, it is something on the host server's side. If I type my site in like "http://mysite.com", the captcha shows up. BUT... if I type in my site like "http://www.mysite.com", it doesn't show. I've had this happen to me again, so I think I can fix this.
-
no, www.mysite.com and mysite.com are two different domains. they might point to the same server, but they are different.
add both domains in you recaptcha account.
-
no, www.mysite.com and mysite.com are two different domains. they might point to the same server, but they are different.
add both domains in you recaptcha account.
Ahhh, that I didn't consider. Thank you for the tip. I'll do that.
-
Have installed recaptcha because built in captcha showing red X server side unable to correct, recaptcha works fine
BUT I have to leave captcha turned on otherwise recaptcha shows but is bypassed regardless of correct or not,
How can I turn off captcha to remove red x but leave recaptcha working?
http://www.suffolkbandarchives.co.uk/4images/register.php
-
You'll need remove it manually from comment_form.html and register_form.html templates.
-
Localisation (e.g. in german)
Just add the following part somewhere in the template (like register_form.html) above the {recaptcha}
<script>
var RecaptchaOptions = {
lang : 'de'
};
</script>
de is (of course) the part for the localisation. So Spanish-Users should change this to es and french to fr.
Further informations here (http://recaptcha.net/apidocs/captcha/client.html).
I've also made a tiny snippet to recaptcha an e-mail address (http://www.4homepages.de/forum/index.php?topic=25263.0)
-
Hallo! Funktioniert der Mod noch mit der aktuellen 4images Version 1.7.7 und der Lib aus der recaptcha-php-1.10.zip?
Ich habe gestern das Mod versucht auf meiner privaten Gallery zu installieren. Zuvor hatte ich das Mod Ajax Comments / Comment Rating http://www.4homepages.de/forum/index.php?topic=23866.0 installiert.
Merkwürdigerweise wurde jeder Kommentar eingetragen, auch wenn ich im Recaptcha "Hützen Grützen" eingegeben habe (was selbstverständlich nicht abgefragt wurde) ;)
Daraufhin habe ich dieses Mod für sich auf meiner öffentlichen Testgallery http://www.pawlikonline.de/temp/4images/details.php?image_id=9 installiert, und komischerweise wird dort kein Kommentar akzeptiert (auch wenn ich das Captcha löse) ;)
Hat jemand einen Tipp für mich?
Anbei noch manuellen Änderungen in der global.php. Alles andere habe ich wie beschrieben installiert.
//$captcha_recaptcha = 1; //0 = disable; 1 = enable with auto domain select; "yourdomain" = for one specific domain only, this domain must be specified in $recaptcha_domains below
$captcha_recaptcha = "pawlikonline.de"; //use only reCAPTCHA keys for yourdomain2
$recaptcha_domains['pawlikonline.de'] = array("6Ldq6AcAAAAAA********************", "6Ldq6AcAAAAAA********************");
/*//to add more then one domain:
$recaptcha_domains['example.com'] = array("public key for example.com", "private key for example.com");
$recaptcha_domains['4homepages.de'] = array("asdfasdfasdf", "a98sd7as9df7as");
$recaptcha_domains['google.com'] = array("23kj423h42k", "8fas9d8a9sdf9a");
*/
if ($captcha_enable && $captcha_recaptcha
&& (isset($recaptcha_domains[$captcha_recaptcha])
|| isset($recaptcha_domains[strtolower($_SERVER["HTTP_HOST"])])))
{
$captcha_recaptcha = (isset($recaptcha_domains[$captcha_recaptcha]))
? $recaptcha_domains[$captcha_recaptcha]
: $recaptcha_domains[strtolower($_SERVER["HTTP_HOST"])];
}
else
{
$captcha_recaptcha = 0;
}
Hint:Selbst wenn ich die Zeile $captcha_recaptcha = 1;
wieder einkommentiere sieht das Ergebnis gleich aus.
Viele Grüße,
Bash-T
-
Hast Du das auch mal als "Nicht-Admin" ausprobiert? Soweit ich das in Erinnerung habe, wird bei Admins die Captcha-Funktion nicht überprüft.
-
@Sebas Bonito
... richtig ... ;)
@bash-t
... willst du dir dieses gewaltige Captcha-Gerät tatsächlich in dein filigranes Template einpflanzen ...
... ich denke Captcha sollte nur eine Hilfe gegen Spam und so unscheinbar wie möglich auf der Seite sein ...
... selbst das Original 4images-Captcha ist mir zu gewaltig ... daher hier (http://www.4homepages.de/forum/index.php?topic=21028.0) ... ;)
-
@Sebas Bonito: Vielen Dank für die schnelle Antwort!
Ich ziehe meine Frage vorerst ein bisschen zurück!
Hab gar nicht gesehen, dass ich "nicht" eingelogged war, aber als Benutzer beim Kommentar meinen Namen angegeben hatte. Die "Fehlermeldung" über dem Bild (welche ich übersehen hatte) hieß: Es existiert bereits ein User mit dem Namen".
Als ich einen fiktiven Namen eingegeben hatte (und das Captcha korrekt) wurde der Kommentar gespeichert.
Nun also nur noch meine Frage ob es Erfahrungen gibt, ob dieses Mod zusammen mit dem Ajax Comment Mod ( http://www.4homepages.de/forum/index.php?topic=23866.0 ) zusammenarbeitet?
EDIT: @mawenzi: Du hast recht, das Captcha ist schon riesengroß. Ich hatte allerdings sowieso vor den gesamten Kommentar-Formular-Kram in ein YUI-Dialog zu packen (siehe z.B. hier http://developer.yahoo.com/yui/examples/container/dialog-quickstart.html ), somit wäre der Bereich solange für den User unsichtbar, bis er wirklich ein Kommentar posten möchte - daher wäre mir auch das riesen Captcha egal ;)
Deinen Link werde ich mir dennoch heute Abend mal anschauen - danke schon mal dafür! :)
EDIT 2: @Sebas Bonito: Danke für den Hinweis mit dem Administrator. Bei einem normalen User wird die Challenge korrekt abgefragt und ausgewertet! Dieses Mod arbeitet also mit dem Ajax Comment Mod zusammen! Allerdings gibt es noch einen kleinen Tweak für diese Kombination, den ich bei dem Ajax Comment Mod hinterlegt habe: http://www.4homepages.de/forum/index.php?topic=23866.msg140156#msg140156
Viele Grüße,
Bash-T
-
Thanks for posting this mod V@no!!
I made a change for this mod to work on all my subdomains.
no, www.mysite.com and mysite.com are two different domains. they might point to the same server, but they are different.
add both domains in you recaptcha account.
When you register a domain on Recaptcha, you can set it to global. This way it will work for any subdomain you may have, and not have to register them all.
With global set you can have this work for http://www.test.com, http://test.com, http://gallery.test.com, http://gallery2.test.com, etc...
Setup like this
$recaptcha_domains['test.com'] = array("Enter your public key", "Enter your private key");
Then make this change to V@no's script
In global.php
Find:
if ($captcha_enable && $captcha_recaptcha
&& (isset($recaptcha_domains[$captcha_recaptcha])
|| isset($recaptcha_domains[strtolower($_SERVER["HTTP_HOST"])])))
{
$captcha_recaptcha = (isset($recaptcha_domains[$captcha_recaptcha]))
? $recaptcha_domains[$captcha_recaptcha]
: $recaptcha_domains[strtolower($_SERVER["HTTP_HOST"])];
}
else
{
$captcha_recaptcha = 0;
}
Replace With:
preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/', $_SERVER['HTTP_HOST'],$domaincatch);
if ($captcha_enable && $captcha_recaptcha
&& (isset($recaptcha_domains[$captcha_recaptcha])
|| isset($recaptcha_domains[strtolower($domaincatch[0])])))
{
$captcha_recaptcha = (isset($recaptcha_domains[$captcha_recaptcha]))
? $recaptcha_domains[$captcha_recaptcha]
: $recaptcha_domains[strtolower($domaincatch[0])];
}
else
{
$captcha_recaptcha = 0;
}
}
-
Das Feld mit dem Bestätigungs-Code muss ausgefüllt werden.
Diese Fehlermeldung bekomme ich NUR im Firefox, habe mal versucht mit dem reCaptche testuser zu registrieren. im Internetexplorer OHNE Probleme, Firefox muckt mal wieder rum.... ;-( (blödes Viech)
Step 5
Solltest du Probleme mit dem hier drüber besagten Code haben, versuche diese beiden Codes zu verwenden. Frag mich nicht warum, aber es ist so
{recaptcha_public}
{recaptcha_private}
brachte auch kein Erfolg
brauch mal Rat und Hilfe,
Grüße
Tobias
-
can I test it?
-
yes you can,
http://www.tram-und-bahnbilder.de/register.php
can you tell me if you had finish??
but the recaptcha for registrations isn't so important,because in two years aren t some spam registrations, but many spam comments .... comments are allowed to guests
the recaptcha in comments is working with all browsers, aks me why, but i can't give some answer what the reason ...
-
Vano this is amazing, ive been searching for this, ive integrated this,
But i have tested it so what i did was entered in the comments section the subject title and then the body and then click post comment, without putting any repatcha inside the reCaptcha but it succesfully saved the comment,
I did everything right, but i think it was the domain name, when u said entere domain name , did u mean www.mysite.com or www.mysite.com/4images.
Thanks I LOVE THIS MOD
-
Make sure you test it as regular member or guest, not as administrator.
-
hallo
habe ReCaptcha eingebaut. Nur Zeigt er mir nur die "alten" Captcha's an, wieso?
wie baue ich {recaptcha} ein?
z.B. in register_form.html?
english.
hello
i bulid in ReCaptcha (in 1.78). But on my Site i Only shows the "old" Captcha, why?
Where i have to bulid in {recaptcha} in register_form.html?
-
First make sure that recaptcha is enabled in step 2.
Second make sure that recaptcha is properly setup in step 2
Your domain that you put in step 2 must match to what $_SERVER["HTTP_HOST"] has, to make sure that they match search for HTTP_HOST in ACP -> phpinfo()
the {recaptcha} tag must be placed anywhere inside the templates mentioned in step 5. (or replace {captcha} tag)
-
Kann man auch eine Funktion einbauen die es ermöglicht, wenn das originale captcha ausgeschaltet ist, dass das recaptcha angezeigt wird?
Original Cpatcha AUS = reCaptcha AN
reCaptcha AUS = Original Captcha AN
---
Can I use a function that allows the original if captcha is off, that the recaptcha is displayed?
Original Cpatcha OFF = reCaptcha ON
reCaptcha OFF = Original Captcha ON
-
What's the point? you can use both of them at the same time...which means you can use either.
-
Yes, that I am aware.
But it is really not possible? Would like to include this feature, but I know not only how to link it.
-
In templates uses conditional tags:
{ifno recaptcha}....code for regular captcha....{endifno recaptcha}
{if recaptcha}....code for re-captcha....{endif recaptcha}
After that you can control it via $captcha_recaptcha variable
-
This mod not work with this http://www.4homepages.de/forum/index.php?topic=8987.0 (http://www.4homepages.de/forum/index.php?topic=8987.0)
When i send a message with blank {recaptcha} field, it send message without problems... In my global.php have this line $captcha_enable_contact = 1;
What is the prob?
-
resolved with default captha!!! :D
-
HI,
I am using this mod.. but its bit surprising that.. still some spammer can add spam comments on my website..
V@no .. Do you have any idea why its happening ??
Thank you
batu
-
Thanks for this great MOD ^_^.
-
I have seen a few people asking how to modify the template file to make this work.
I am wondering the same thing...
Currently, my template file looks like this:
<table width="100%" border="0" cellspacing="0" cellpadding="1" align="center">
<tr>
<td valign="top" class="head1">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td valign="top" class="head1">{lang_post_comment}</td>
</tr>
<tr>
<td valign="top" class="row1">
<form name="commentform" action="{self}" method="post" onsubmit="postbutton.disabled=true;">
<table cellpadding="4" cellspacing="0" border="0">
<tr>
<td width="90"><b>{lang_name}</b></td>
<td><input type="text" name="user_name" size="30" value="{user_name}" class="commentinput" /></td>
</tr>
<tr>
<td width="90"><b>{lang_headline}</b></td>
<td><input type="text" name="comment_headline" size="30" value="{comment_headline}" class="commentinput" /></td>
</tr>
<tr>
<td width="140" valign="top"><b>{lang_comment}</b></td>
<td><textarea name="comment_text" cols="35" rows="10" class="commenttextarea">{comment_text}</textarea></td>
</tr>
<tr>
<td width="90" valign="top"> </td>
<td>{bbcode}</td>
</tr>
<tr>
<td>{if captcha_comments}</td>
<td></td>
</tr>
<tr>
<td width="90" valign="top"><b>{lang_captcha}</b></td>
<td>
<a href="javascript:new_captcha_image();"><img src="{url_captcha_image}" border="0" id="captcha_image" alt="" /></a>
<br />
<input type="text" name="captcha" size="30" value="" class="captchainput" id="captcha_input" />
<br />
<table cellpadding="0" cellspacing="0" width="210">
<tr>
<td width="258"> {lang_captcha_desc}</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>{endif captcha_comments}</td>
<td></td>
</tr>
<tr>
<td width="90" valign="top"> </td>
<td>
<input type="hidden" name="action" value="postcomment" />
<input type="hidden" name="id" value="{image_id}" />
<input type="submit" name="postbutton" value="{lang_post_comment}" class="button" />
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
I have tried replacing the phrase "captcha" with "recaptcha" and I don't get an image on my comments page.
How, exactly, do I incorporate the {recaptcha} into this html coding?
Thank you so much,
lilal