Jump to content
JcMagpie

Support thread for JcM Google reCAPTCHA V2 & Terms Phoenix

Recommended Posts

A simple add-on to let add the Google reCAPTCHA V2 and accept terms to any form in Phoenix 1.0.4.0 that has the hooks added to it.

It is a no core change add-on and uses site-wide hooks. Simply copy all the files over.

You will need your Google reCAPTCHA so you can add them to the following file

includes/languages/english/hooks/shop/siteWide/jcm_google_recaptcha.php

Just open it in your editor and add the comment and keys into it

//google

define('MODULE_CONTENT_RECAPTCHA_ERROR','Sorry you need to prove you are human first please complete the google captcha');

define('MODULE_CONTENT_RECAPTCHA_SITEKEY','Place your site key here');

define('MODULE_CONTENT_RECAPTCHA_SECRETKEY','Place your Secret key here');

You can also define which pages it is shown on by editing the hook file.

$good_pages = ['contact_us.php', 'create_account.php'];

This is done in both the capatcha hook file JcMgoogleCapatcha.php and the accept terms file JcMaTerms.php

That’s it it should just work. When you go to your contact_us page you should see the Google reCAPTCHA and if installed the accept terms.

This will only work on Phoenix.

Enjoy.

Can be see working on this site

image.thumb.png.960f09a9b532e8f963178b29e337768c.png


 

Share this post


Link to post
Share on other sites

One of the best addons available !!! THANK YOU Zahid !!!


Please do not falsify my words. Are you interested in knowing who does it? Send me a PM.

The Phoenix Club won't allow me to join - why not?

Setting up a new Frozen site with so many nice addons available on the market. 

:heart: Community Oscommerce fan :heart:

 

Share this post


Link to post
Share on other sites

Yes just a silly mistake on my part, when I combined the hooks in to one file I forgot that I updated the language file to place it into the correct path. Simple fix, in

public_html/includes/classes/recaptcha.php   find line 22 and replace with this line.

require('includes/languages/' . $language . '/hooks/shop/siteWide/jcm_google_recaptcha.php');

Should then work.

Will upload the add-on shortly.


 

Share this post


Link to post
Share on other sites

@JcMagpie

Thank you for creating this hook:

In my installation it works as long as the link is as followed:
https://www.attias.ch/ishop/contact_us.php

But when the link comes with the ceid: 
https://www.attias.ch/ishop/contact_us.php/ceid/098b722e19620edff2b1bcecd03d55ed
the recaptcha item will not be shown.


I had to deactivate this hook by renaming the $good_page values in pages which dont exist.

Maybe the hook JcMgoogleCapatcha.php does not find the page with the ceid in $good_page and needs to be substringed before.

Any proposal? 

 

 

Share this post


Link to post
Share on other sites

Sorry no idea why it should be like that. It's one for one of the developers. If your using Phoenix then I belive the club has it's own Google reCpatcha may be try that? it's made by a developer and probably works better.


 

Share this post


Link to post
Share on other sites

@JcMagpie

Aha, I do not develop php programs yet… But i have installed a new test Environment and played a little bit with various settings in Phoenix. 

I found out that turning off the Use Search-Engine Safe URLs (set to false) in admin section / configuration menu / My Store
solves the Problem above.

Now the link shows like this and it will be recognized by the hook in JcMgoogleCapatcha.php properly.
https://www.attias.ch/ishop/contact_us.php?language=de&ceid=b762592bb02c1d2ca8938c328b92e63f

Maybe also this has an impact to google search which i will control this in the next future.
Thanks for your answer and for your hook!

Edited by Philo2005

Share this post


Link to post
Share on other sites

Glad you got it sorted.

1 hour ago, Philo2005 said:

I found out that turning off the Use Search-Engine Safe URLs (set to false) in admin section / configuration menu / My Store
solves the Problem above.

This should not be required but it will depend on your server setup and how you are configuring your store and .htaccess.

The test site has Use Search-Engine Safe URLs set to true

image.png.f7eb036ea3b0a06f58fb8f405e7dcaff.png

and it all works as expected.

image.png.71b9f7c3ee396de2a60b5f0180a78d2c.png

All my links are simple links like

https:kuuza.co.uk/contact_us.php

I'm not an expert in these url configs but you may need to check how cookies are set in your config. The ceid should only show once if set properly or get rid of it all together....

But as allways check with an expert first.


 

Share this post


Link to post
Share on other sites

@JcMagpie

I sorted out the Problem and found it in your hook file JcMgoogleCaptcha.php.

1. Basically I added first the
$PHP_SELF
to the globals for each function:
listen_injectFormVerify, 
listen_injectFormDisplay, 
listen_injectSiteEnd.

2. Your compare Statements are not correct! 

(in_array(basename($_SERVER['PHP_SELF']), $this->good_pages)) 

has been corrected to a proper comparison

(in_array(basename($PHP_SELF), $this->good_pages))

3. also I made code cleaning to view nice.

Now i fixed the previous issue and all works fine,

This new code solves the Problem how user enters the url:
www.attias.ch/ishop/contact_us.php
www.attias.ch/ishop/contact:_us.php/language/en
www.attias.ch/ishop/contact_us.php?language=en
All types of entering URLs now work!


Feel free to see it on my live shop www.attias.ch
and take over, if you like it.
see attached file

JcMgoogleCapatcha.php

Share this post


Link to post
Share on other sites
12 hours ago, Philo2005 said:

2. Your compare Statements are not correct! 

😊 Intresting! it works fine on all the other sites that have used it? But as I said before you can do as you like on your site, use whatever works for you.

FYI

" $PHP_SELF

$PHP_SELF is deprecated and should not be used because it will not work without register_globals being enabled. As of PHP 4.2.0 the default for the PHP directive register_globals went from on to off.  Again however, the server configuration is in play."

"

$_SERVER['PHP_SELF']

This is the filename of the currently executing script, relative to the document root. However, unlike $_SERVER['SCRIPT_NAME'], it provides additional path information like $_SERVER['REQUEST_URI'] when the actual php file is present in the path. So when the $_SERVER['REQUEST_URI'] is /index.php/big/directory/ then $_SERVER['PHP_SELF'] will be /index.php/big/directory/.

However if all the URI’s under http://www.example.com/ is mapped to http://www.example.com/index.php, then, for example, http://www.example.com/abc/def will return /index.php like $_SERVER['SCRIPT_NAME']. Note that $_SERVER['REQUEST_URI'] data is ignored for this request.

$_SERVER['PHP_SELF'] is supported on all platforms."


 

Share this post


Link to post
Share on other sites

includes/application_top.php lines 42-44:

// set php_self in the local scope
  $req = parse_url($_SERVER['SCRIPT_NAME']);
  $PHP_SELF = substr($req['path'], ($request_type == 'NONSSL') ? strlen(DIR_WS_HTTP_CATALOG) : strlen(DIR_WS_HTTPS_CATALOG));

 

Share this post


Link to post
Share on other sites
6 hours ago, raiwa said:

includes/application_top.php lines 42-44:


// set php_self in the local scope
  $req = parse_url($_SERVER['SCRIPT_NAME']);
  $PHP_SELF = substr($req['path'], ($request_type == 'NONSSL') ? strlen(DIR_WS_HTTP_CATALOG) : strlen(DIR_WS_HTTPS_CATALOG));

 

So many other module in Phoenix uses $PHP_SELF and they all work fine, this show the acutal page Name e.q. "contact_us.php"!
Thanks @raiwa

Share this post


Link to post
Share on other sites
37 minutes ago, Philo2005 said:

this show the acutal page Name e.q. "contact_us.php"

😂 hey whatever rocks  your boat..... :thumbsup:

On 12/6/2019 at 9:29 PM, JcMagpie said:

Sorry no idea why it should be like that. It's one for one of the developers. If your using Phoenix then I belive the club has it's own Google reCpatcha may be try that? it's made by a developer and probably works better.

 

Edited by JcMagpie

 

Share this post


Link to post
Share on other sites

If you like an addon or the contribution of a person to the community it would be nice to give him a like or write some lines thanking him for his work, don't you think so?


Please do not falsify my words. Are you interested in knowing who does it? Send me a PM.

The Phoenix Club won't allow me to join - why not?

Setting up a new Frozen site with so many nice addons available on the market. 

:heart: Community Oscommerce fan :heart:

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×