PDA

View Full Version : [mod] captcha on contact us page


Simon Gooffin
05-08-2006, 12:51 PM
Hi
Here is the mod to have captchas on contact us page:

*** open contacts.tpl and find the following code ***
<input type="submit" name="contact" value="{$lang.submit}" /></td>

*** insert the following code before ***
{if $config.captcha}
<p class="field"><img src="{$config.base}{$config.dir}plugins/captcha/image.php" />
<input type="text" name="security_code" /></p>
{/if}

*** save changes ***

*** open contacts.php and find the following code ***
/** requires common header file **/
require_once('header.php');

*** insert the following before ***
session_start();

*** find the following code ***
if (!$error)
{
$gDirDb->addContact(addslashes($fullname), addslashes($email), addslashes($body));
$msg = " {$gDirLang['contact_added']}";
}

*** add the following code before ***
/** check for captcha **/
if ($gDirConfig['captcha'])
{
$sc1 = $_POST['security_code'];
$sc2 = $_SESSION['pass'];
if (strcmp($sc1, $sc2))
{
$error = true;
$msg .= " {$gDirLang['error_captcha']}";
}
}

*** save changes ***

Please try now ;)

Loren
05-08-2006, 01:41 PM
Guess what!

I still cant see my captcha :wallbash:

Fed up today..think i will go back to bed :cry:

Simon Gooffin
05-08-2006, 01:44 PM
did you delete .htaccess file in your plugins directory?

Loren
05-08-2006, 01:54 PM
no hun i didn't because i didn't have .htaccess file in there but i have solved it! :yahoo:


For some reason i opened my config.inc.php folder and was looking down the list...in the vain hope i would see an anomaly and i happened to look at
$gDirConfig['captcha'] = '0'; so i thought that strange considering everything has been installed, and others had '1' so i changed the code to this

$gDirConfig['captcha'] = '1'; and blow me down...that was the problem! Why or how i don't know but if anyone else is having the same problem check that file and that line :good:

Simon Gooffin
05-08-2006, 02:04 PM
hmm, you should have the following option in your admin panel->configuration->general configuration

Captcha

You should have enabled captchas there :)
Anyhow I'm very glad you have solved that problem

Loren
05-08-2006, 02:05 PM
I had enabled it there :blink: thats the bizarre thing!

Simon Gooffin
05-09-2006, 05:43 AM
really strange :unsure:

uscasinos
07-01-2006, 08:20 AM
The codes inserted into contacts.tpl should be like this.

{if $config.captcha}
<p class="field"><img src="{$config.base}{$config.dir}plugins/captcha/image.php" alt="captcha" /><br /><input type="text" name="security_code" /></p>
{/if}

Loren
07-01-2006, 10:42 PM
Hi uscasinos Welcome to the forums! :)

Are you giving an answer or asking a question? ;)

faisal1
07-09-2006, 11:43 PM
Hi

I did exactly what you have said but i got this :


http://www.mydomain.com/plugins/captcha/image.php

beside the field while i have enabled captchas !

Simon Gooffin
07-11-2006, 06:56 AM
Hi uscasinos Welcome to the forums! :)

Are you giving an answer or asking a question? ;)
I suppose it's an answer thanks.. There is a problem with my modification. It seems code tag made some changes in it and the real code does not look correct.
uscasinos wrote correct code that should be added to contacts.tpl

2faisal1
please use the code uscasinos wrote above instead of other one.

safatweb
07-11-2006, 09:12 AM
Working Fine :)
Thanks simon, as i was suffering from it.

Simon Gooffin
07-11-2006, 09:15 AM
I'm glad to advise ;)

safatweb
07-11-2006, 09:19 AM
:) for me both worked.
yours --> simon & the other too.

but i took the second as the captcha pic is on top of the field & in u r s next to the field :)

but i appriciate this idea which is u r s

Simon Gooffin
07-11-2006, 09:45 AM
well I have modified my modification post and possibly that's why you have the mod working now. But there was a real mess in the post before. I suppose vBcode just messed my code

Bryan Ex
11-30-2006, 01:20 AM
Simon... is there a way to add this mod that will not conflict with the Alexa Thumbnail script as posted by Dave Baker in This Thread (http://www.esyndicat.com/forum/about6665-2.html)? The thumbs are working and captcha on the submit link works but if I add it to link comments, tell a friend, or contact us in the way you have described above it returns an error of;

Warning: session_start(): Cannot send session cache limiter - headers already sent

I either have to secure or remove the tell a friend page as it's currently wide open for spammers to use my email server... I'd prefer to keep it if there's a way to do it.

Bryan Ex
11-30-2006, 03:32 PM
Never mind... session start BEFORE the header include not after it... duh! Sometimes it does not pay to work all night.