Re: Captcha using TTF & GD
Quote:
Originally Posted by
nikki72
Hello,
I wanted to add this option to my return authorization form. I have search for link with instructions..but couldn't find any... does anyone know how to get this to work with return authorization form? I tired but to no avail :(.
thanks nicole
If it's the Return Authorization by Clyde, then for tpl_returns_default.php add the following, I placed mine just above the submit button..
Code:
<?php
// BOF Captcha
if(is_object($captcha) && (!$_SESSION['customer_id'])) {
?>
<br class="clearBoth" />
<?php echo $captcha->img(); ?>
<?php echo $captcha->redraw_button(BUTTON_IMAGE_CAPTCHA_REDRAW, BUTTON_IMAGE_CAPTCHA_REDRAW_ALT); ?>
<br class="clearBoth" />
<label for="captcha"><?php echo TITLE_CAPTCHA; ?></label>
<?php echo $captcha->input_field('captcha', 'id="captcha"') . ' <span class="alert">' . TEXT_CAPTCHA . '</span>'; ?>
<br class="clearBoth" />
<?php
}
// BOF Captcha
?>
Then for the header file in >modules/pages/retuns/header_php.php you need to add it in two places, first anywhere near the top this section of code..
Code:
//BOF Captcha
if((CAPTCHA_RETURNS != 'false') && (!$_SESSION['customer_id'])) {
require(DIR_WS_CLASSES . 'captcha.php');
$captcha = new captcha();
}
// EOF Captcha
$error = false;
I did mine just above this line..
Quote:
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
Notice the CAPTCHA_RETURNS in the if statement, this turns it on or off through admin. if you don't do a SQL statement to add this, you'll need to change it to something else like CAPTCHA_CONTACT_US which has an admin control.
Look for this line
Quote:
if ($zc_validate_email and !empty($reason) and !empty($name)) {
replace it with the following code..
Code:
//BOF Captcha
if (is_object($captcha) && !$captcha->validateCaptchaCode()) {
$error = true;
$messageStack->add('returns', ERROR_CAPTCHA);
}
// if ($zc_validate_email and !empty($reason) and !empty($name)) {
if ($zc_validate_email and !empty($reason) and !empty($name) and !$error) {
//EOF Captcha
To turn it on or off in admin.. add a sql statement using the Zen-Cart Sql Patches tool. Please backup your database before doing this... you never know when something will go wrong..
Code:
SET @configuration_group_id=0;
SELECT (@configuration_group_id:=configuration_group_id) FROM configuration_group WHERE configuration_group_title= 'CAPTCHA' LIMIT 1;
INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function) VALUES
(NULL, 'Return Authorization', 'CAPTCHA_RETURNS', 'true', 'Activate Validation on Return Authorization', @configuration_group_id, 23, NOW(), NULL, 'zen_cfg_select_option(array(\'true\', \'false\'),');
Again... BACKUP before running the SQL statement.. I do my testing on a testing server before making any changes to a live site!
Re: Captcha using TTF & GD
worked like a charm! TY Nicole
Re: Captcha using TTF & GD
I usually make my Return Authorization form available only to registered users, but I have a current client who is insisting on Captcha even with this option activated.. So this is SWEEEEEEEEET!!! Thanks a bunch.. (BOOKMARKING THIS!!!)
Quote:
Originally Posted by
davewest
If it's the Return Authorization by Clyde, then for tpl_returns_default.php add the following, I placed mine just above the submit button..
Code:
<?php
// BOF Captcha
if(is_object($captcha) && (!$_SESSION['customer_id'])) {
?>
<br class="clearBoth" />
<?php echo $captcha->img(); ?>
<?php echo $captcha->redraw_button(BUTTON_IMAGE_CAPTCHA_REDRAW, BUTTON_IMAGE_CAPTCHA_REDRAW_ALT); ?>
<br class="clearBoth" />
<label for="captcha"><?php echo TITLE_CAPTCHA; ?></label>
<?php echo $captcha->input_field('captcha', 'id="captcha"') . ' <span class="alert">' . TEXT_CAPTCHA . '</span>'; ?>
<br class="clearBoth" />
<?php
}
// BOF Captcha
?>
Then for the header file in >modules/pages/retuns/header_php.php you need to add it in two places, first anywhere near the top this section of code..
Code:
//BOF Captcha
if((CAPTCHA_RETURNS != 'false') && (!$_SESSION['customer_id'])) {
require(DIR_WS_CLASSES . 'captcha.php');
$captcha = new captcha();
}
// EOF Captcha
$error = false;
I did mine just above this line..
Notice the CAPTCHA_RETURNS in the if statement, this turns it on or off through admin. if you don't do a SQL statement to add this, you'll need to change it to something else like CAPTCHA_CONTACT_US which has an admin control.
Look for this line
replace it with the following code..
Code:
//BOF Captcha
if (is_object($captcha) && !$captcha->validateCaptchaCode()) {
$error = true;
$messageStack->add('returns', ERROR_CAPTCHA);
}
// if ($zc_validate_email and !empty($reason) and !empty($name)) {
if ($zc_validate_email and !empty($reason) and !empty($name) and !$error) {
//EOF Captcha
To turn it on or off in admin.. add a sql statement using the Zen-Cart Sql Patches tool.
Please backup your database before doing this... you never know when something will go wrong..
Code:
SET @configuration_group_id=0;
SELECT (@configuration_group_id:=configuration_group_id) FROM configuration_group WHERE configuration_group_title= 'CAPTCHA' LIMIT 1;
INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function) VALUES
(NULL, 'Return Authorization', 'CAPTCHA_RETURNS', 'true', 'Activate Validation on Return Authorization', @configuration_group_id, 23, NOW(), NULL, 'zen_cfg_select_option(array(\'true\', \'false\'),');
Again...
BACKUP before running the SQL statement.. I do my testing on a testing server before making any changes to a live site!
Re: Captcha using TTF & GD
Keep in mind that this line turns it off for log in customers.
Quote:
if((CAPTCHA_RETURNS != 'false') && (!$_SESSION['customer_id'])) {
If you wish to run it for all customers even log in ones, change it to this..
Code:
if (CAPTCHA_RETURNS != 'false') {
Glade it helped!
Re: Captcha using TTF & GD
Hi,
I was testing this on a clean install on my local server, and all was going well until I installed the "Display Inc/Ex Tax or VAT Prices" module. Now I get the "enable this picture" text instead of the image. I ran the captcha_debug.php, but it may as well be chinese.
Code:
captcha::__set_state(array(
'captchaCode' => 'K97W',
'captchaCode_length' => 4,
'img_width' => 240,
'img_height' => 50,
'img_type' => 'jpeg',
'chars_min_size' => 0.6,
'chars_max_size' => 0.8,
'chars_shadow' => true,
'chars_rotation' => 23,
'noise' => 30,
'backgroundColor' =>
array (
0 =>
array (
0 => 220,
1 => 220,
2 => 220,
),
1 =>
array (
0 => 255,
1 => 255,
2 => 255,
),
),
'linesColor' =>
array (
0 =>
array (
0 => 150,
1 => 150,
2 => 150,
),
1 =>
array (
0 => 185,
1 => 185,
2 => 185,
),
),
'textColor' =>
array (
0 =>
array (
0 => 30,
1 => 30,
2 => 30,
),
1 =>
array (
0 => 199,
1 => 199,
2 => 199,
),
),
'dir_fs_fonts' => 'C:/wamp/www/CLEAN MODIFIED SITE/fonts/',
'ttf_list' =>
array (
0 => 'C:/wamp/www/CLEAN MODIFIED SITE/fonts/VERDANA.TTF',
),
'max_try' => 5,
'failure_proc' => '',
'quality' => 60,
'chars' =>
array (
0 => '1',
1 => '2',
2 => '3',
3 => '4',
4 => '5',
5 => '6',
6 => '7',
7 => '8',
8 => '9',
9 => 'A',
10 => 'B',
11 => 'C',
12 => 'D',
13 => 'E',
14 => 'F',
15 => 'G',
16 => 'H',
17 => 'I',
18 => 'J',
19 => 'K',
20 => 'L',
21 => 'M',
22 => 'N',
23 => 'O',
24 => 'P',
25 => 'Q',
26 => 'R',
27 => 'S',
28 => 'T',
29 => 'U',
30 => 'V',
31 => 'W',
32 => 'X',
33 => 'Y',
34 => 'Z',
),
'_background' => NULL,
'img' => NULL,
'_gd_version' =>
array (
'GD Version' => 'bundled (2.0.34 compatible)',
'FreeType Support' => true,
'FreeType Linkage' => 'with freetype',
'T1Lib Support' => true,
'GIF Read Support' => true,
'GIF Create Support' => true,
'JPG Support' => true,
'PNG Support' => true,
'WBMP Support' => true,
'XPM Support' => false,
'XBM Support' => true,
'JIS-mapped Japanese Font Support' => false,
'version' => '2',
),
'debug' => true,
'img_href' => 'http://localhost/CLEAN MODIFIED SITE/captcha_img.php?zenid=cjr7niaienpcclr2hb9hmqqdb0',
'imageColorFunc' => 'imagecolorallocate',
))
Any suggestions on what could be the problem?
TIA
Re: Captcha using TTF & GD
I'm also having the "enable this picture" issue. I've uninstalled and reinstalled multiple times. I've read all the pages. I've updated my .htaccess. I'm fairly confident it isn't a coding issue, as I've replaced the MYTEMPLATE/account code with my archived code after determining that I don't need it (just want the contact_us).
When I run captcha_debug.php it bounces me to my home page. Does that mean there are no errors?
When I look at the code in Firebug I see the image is secure (https). That is strange.
Thanks in advance for the help.
Re: Captcha using TTF & GD
I also had the "enable this picture" problem, read the posts, tried different things and then realized- the captcha_img.php file needs to be uploaded to the root directory (or the same directory as /includes). :bangin:
That may be obvious to some, but not to a layman like me. The readme file doesn't mention it and I thought it was part of the other non-upload files like install.slq, update, etc.
Robbie
Re: Captcha using TTF & GD
Nevermind, everyone. ... :oops:
I had renamed the captcha files in a way that the page was still loading them, and it broke it.
(more detailed explanation: I had made all of my edits but kept the original mod files, just renamed them as header_php.captcha.php etc. so I had the untouched mod files if I needed them, but this rename wasn't quite enough! I changed it to captcha.header_php.php or somesuch and now my page works again...)
Whew! :bigups:
I always seem to figure out my own problems RIGHT after I make a forum post about it... :)
Re: Captcha using TTF & GD
Quote:
Originally Posted by
misticloudz
I always seem to figure out my own problems RIGHT after I make a forum post about it... :)
Always helps to talk it through.... also, file renaming for backups. Best to remove them to a backup set of your store or just remove the extension '.php' change it to something like'.bak' or '.old'. leaving the '.php' even renaming the file can lead to more problems.