Zen Cart Logo
Forums / All Other Contributions/Addons / Adding reCAPTCHA to Contact Us Form

Adding reCAPTCHA to Contact Us Form

Views: 38,811

Results 161 to 180 of 186
31 Mar 2012, 7:43 PM
#161
pickupman avatar

pickupman

New Zenner

Join Date:
Jun 2009
Posts:
83
Plugin Contributions:
2

Adding reCAPTCHA to Contact Us Form

In that file you need to put the function_exists around that line as well. So in includes/classes/recaptchalib.php, change around line 63 to:

if ( !function_exists('_recaptcha_http_post') )
{
  /**
 * Submits an HTTP POST to a reCAPTCHA server
 * @param string $host
 * @param string $path
 * @param array $data
 * @param int port
 * @return array response
 */
   function _recaptcha_http_post($host, $path, $data, $port = 80)
   {

        $req = _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( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
                die ('Could not open socket');
        }

        fwrite($fs, $http_request);

        while ( !feof($fs) )
                $response .= fgets($fs, 1160); // One TCP-IP packet
        fclose($fs);
        $response = explode("\r\n\r\n", $response, 2);

        return $response;
   }
}
31 Mar 2012, 8:30 PM
#162
cp_river avatar

cp_river

New Zenner

Join Date:
Aug 2008
Posts:
25
Plugin Contributions:
0

Re: Adding reCAPTCHA to Contact Us Form

Hello Pickupman

I copied the above code and replaced the section on the /inludes/classes/recaptchlib.php but the problem is the same the error code:

[31-Mar-2012 14:04:08] PHP Fatal error: Cannot redeclare _recaptcha_qsencode() (previously declared in ../includes/classes/recaptchalib.php:47) in ../includes/classes/recaptchalib.php on line 55

I pull my hairs off.

:bangin:

CP

31 Mar 2012, 8:50 PM
#163
pickupman avatar

pickupman

New Zenner

Join Date:
Jun 2009
Posts:
83
Plugin Contributions:
2

Re: Adding reCAPTCHA to Contact Us Form

I have updated your file for you. Try enabling it now and see what happens.

1 Apr 2012, 6:20 AM
#164
cp_river avatar

cp_river

New Zenner

Join Date:
Aug 2008
Posts:
25
Plugin Contributions:
0

Re: Adding reCAPTCHA to Contact Us Form

Hello pickupman

Appreciate your help. I get the new error code now:

[01-Apr-2012 00:06:36] PHP Fatal error: Cannot redeclare recaptcha_check_answer() (previously declared in ../includes/classes/recaptchalib.php:156) in ../includes/classes/recaptchalib.php on line 197

:dontgetit

CP

1 Apr 2012, 8:53 PM
#165
pickupman avatar

pickupman

New Zenner

Join Date:
Jun 2009
Posts:
83
Plugin Contributions:
2

Re: Adding reCAPTCHA to Contact Us Form

Hello CP_River,
Not sure why this code is getting loaded twice, but anyways I have wrapped all of those functions for you to prevent those errors from appearing. I have re uploaded the file to your site for you.

I can see the reCaptcha on the contact us page on your site.

2 Apr 2012, 10:00 AM
#166
cp_river avatar

cp_river

New Zenner

Join Date:
Aug 2008
Posts:
25
Plugin Contributions:
0

Re: Adding reCAPTCHA to Contact Us Form

Hello Pickupman

I feel sorry to spend lots of your time on this. However the site "search" still not work. I believe the reCaptcha seems ok and it appeared on contact us page etc, but just that if I do any site search, the blank page appeared, the the error logs indicate that something to do with the ReCaptcha. This time the error code as bellow:

[02-Apr-2012 02:00:57] PHP Fatal error: Cannot redeclare class ReCaptchaResponse in ../includes/classes/recaptchalib.php on line 141

Also these is another log file:

installerConfigKeys|a:1:{s:8:"language";s:7:"english";}logfilename|s:27:"Jan-16-2012_09-40-58-o64i2Q";installerConfigInfo|a:0:{}

Cheers

CP

3 Apr 2012, 12:01 AM
#167
pickupman avatar

pickupman

New Zenner

Join Date:
Jun 2009
Posts:
83
Plugin Contributions:
2

Re: Adding reCAPTCHA to Contact Us Form

CP,
I got the problem figured out for you finally. You can't have more than one header_php file in the /includes/modules/pages folders. It looks like you were renaming backups. However, zencart runs each of those files. So it was executing the header_php files multiple times creating the redeclare errors. I have removed those file from the folders, and now it is running properly.

If you want to have a backup just do not use header_php in the file name.

Running WinCacheGrind, I could see zencart loading:
index.php
--->require: application_top.php
--->require: header_php.php
--->require: header_php_original.php

3 Apr 2012, 10:31 AM
#168
cp_river avatar

cp_river

New Zenner

Join Date:
Aug 2008
Posts:
25
Plugin Contributions:
0

Re: Adding reCAPTCHA to Contact Us Form

Hello Pickupman

That works perfectly now. Thank you very much again for your effort, patience and time. :clap:

Cheers

CP

18 Apr 2012, 7:44 AM
#169
revitupmedia avatar

revitupmedia

New Zenner

Join Date:
Sep 2009
Posts:
8
Plugin Contributions:
0

Re: Adding reCAPTCHA to Contact Us Form

Hi Pickupman,
I'm having trouble on the create account page. It will not check to see if the recaptcha is entered. It only checks the usual required fields. It is working on the contact page. I'm running 1.3.9h.

Any idea?

Thanks,
Rich

pickupman:

CP,
I got the problem figured out for you finally. You can't have more than one header_php file in the /includes/modules/pages folders. It looks like you were renaming backups. However, zencart runs each of those files. So it was executing the header_php files multiple times creating the redeclare errors. I have removed those file from the folders, and now it is running properly.

If you want to have a backup just do not use header_php in the file name.

Running WinCacheGrind, I could see zencart loading:
index.php
--->require: application_top.php
--->require: header_php.php
--->require: header_php_original.php

18 Apr 2012, 2:00 PM
#170
pickupman avatar

pickupman

New Zenner

Join Date:
Jun 2009
Posts:
83
Plugin Contributions:
2

Re: Adding reCAPTCHA to Contact Us Form

revitupmedia:

Hi Pickupman,
I'm having trouble on the create account page. It will not check to see if the recaptcha is entered. It only checks the usual required fields. It is working on the contact page. I'm running 1.3.9h.

Any idea?

Thanks,
Rich

Hey Rich,
I just replied to your PM. Check it and let me know. You may already have a custom create_account.php page that may override this mod. This should be easy to fix.

19 Apr 2012, 4:25 AM
#171
revitupmedia avatar

revitupmedia

New Zenner

Join Date:
Sep 2009
Posts:
8
Plugin Contributions:
0

Re: Adding reCAPTCHA to Contact Us Form

Hi Pickupman,
You were correct about having a create_account.php file in the template folder overriding your file. Thanks again for pointing it out.

rich

26 Apr 2012, 10:51 AM
#172
cp_river avatar

cp_river

New Zenner

Join Date:
Aug 2008
Posts:
25
Plugin Contributions:
0

Re: Adding reCAPTCHA to Contact Us Form

Hello Pickupman

When I testing the check out and selected a project and clicked checkout, on the top of the next page (signin or register to checkout) it also appeared Bitbucket's page - pickupman is sharing code with you. Do you know what's wrong with my code? I haven't done anything since last time.

Cheers

CP

26 Apr 2012, 1:48 PM
#173
pickupman avatar

pickupman

New Zenner

Join Date:
Jun 2009
Posts:
83
Plugin Contributions:
2

Re: Adding reCAPTCHA to Contact Us Form

CP_River:

Hello Pickupman

When I testing the check out and selected a project and clicked checkout, on the top of the next page (signin or register to checkout) it also appeared Bitbucket's page - pickupman is sharing code with you. Do you know what's wrong with my code? I haven't done anything since last time.

Cheers

CP
Hey CP,
Look in the file /includes/modules/pages/login/header_php.php and see if that text appears anywhere because it is not in the source files. Also, remember from the last issues, make sure you don't have any extra header_php files, not even renamed.

I looked at your page, and to be quite honest, I don't know how you did this. :huh:

27 Apr 2012, 6:19 PM
#174
cp_river avatar

cp_river

New Zenner

Join Date:
Aug 2008
Posts:
25
Plugin Contributions:
0

Re: Adding reCAPTCHA to Contact Us Form

Hello Pickupman

you are right, I have removed all the duplicated files, in particular includes/modules/pages/login/jscript_jquery_.php. Now it works.

Thanks for you help as always.

about to do live. fingers across.

Cheers

CP

29 Apr 2012, 2:17 PM
#175
xxxslaoxxx avatar

xxxslaoxxx

New Zenner

Join Date:
Apr 2012
Posts:
1
Plugin Contributions:
0

Re: Adding reCAPTCHA to Contact Us Form

pickupman:

Hey Rich,
I just replied to your PM. Check it and let me know. You may already have a custom create_account.php page that may override this mod. This should be easy to fix.

Hi Pickupman,

I have the same problem with Rich. The captcha doesn't work on create account but in contact us page it works. Can you also help me this? :cool:

I'm running Zen Cart V1.5

Thanks

Donald

3 Aug 2012, 12:59 PM
#176
mani avatar

mani

New Zenner

Join Date:
Aug 2008
Location:
Abbottabad, Pakistan
Posts:
62
Plugin Contributions:
0

Re: Adding reCAPTCHA to Contact Us Form

[QUOTE=pickupman;1121621]

Hello pickupman,

I installed reCAPTCHA module but when I go to

http://mydomain.com/mysecretadmin it shows a blank white page

and when i go to
http://mydomain.com/mysecretadmin/login.php

It works fine, any idea how to fix it?

Usman

3 Aug 2012, 1:24 PM
#177
pickupman avatar

pickupman

New Zenner

Join Date:
Jun 2009
Posts:
83
Plugin Contributions:
2

Re: Adding reCAPTCHA to Contact Us Form

Hello pickupman,

I installed reCAPTCHA module but when I go to

http://mydomain.com/mysecretadmin it shows a blank white page
Sometimes the download will get a whitespace/line break issue in /admin/includes/init_includes/init_reloadedstack.php. Its seems to be a end of line issue. Make sure that the file should look like:

<?php
/**
* Custom message stack output to add on to messageStack variable
* @author Joe McFrederick
*/
if (isset($_SESSION) AND is_numeric($_SESSION['admin_id']) AND is_object($reloadedStack) )
{
        foreach ($reloadedStack->errors as $message)
        {
                $messageStack->errors[] = $message;
                $messageStack->size += 1;
        }
}
3 Aug 2012, 3:41 PM
#178
mani avatar

mani

New Zenner

Join Date:
Aug 2008
Location:
Abbottabad, Pakistan
Posts:
62
Plugin Contributions:
0

Re: Adding reCAPTCHA to Contact Us Form

I removed this file
/melian/includes/functions/extra_functions/recaptcha_functions.php

and this fixed the problem. I am not getting the blank screen plus recaptcha is working fine as well, your thoughts on this?

3 Aug 2012, 4:00 PM
#179
mani avatar

mani

New Zenner

Join Date:
Aug 2008
Location:
Abbottabad, Pakistan
Posts:
62
Plugin Contributions:
0

Re: Adding reCAPTCHA to Contact Us Form

pickupman:

Sometimes the download will get a whitespace/line break issue in /admin/includes/init_includes/init_reloadedstack.php. Its seems to be a end of line issue. Make sure that the file should look like:

<?php /** * Custom message stack output to add on to messageStack variable * @author Joe McFrederick */ if (isset($_SESSION) AND is_numeric($_SESSION['admin_id']) AND is_object($reloadedStack) ) { foreach ($reloadedStack->errors as $message) { $messageStack->errors[] = $message; $messageStack->size += 1; } } ``` I just checked /httpdocs/myadmin/includes/init_includes and there is no such file init_reloadedstack.php
3 Aug 2012, 4:17 PM
#180
pickupman avatar

pickupman

New Zenner

Join Date:
Jun 2009
Posts:
83
Plugin Contributions:
2

Re: Adding reCAPTCHA to Contact Us Form

@Mani,
That's fine to delete the file once the mod is running.