Post by RockMeBaby » Sun Sep 18, 2011 3:18 am

Here is my first modification contribution to implement the OpenCart captcha to the registration form in 1.5.1...

SEE EXAMPLE HERE: https://www.rockmebabyclothing.com/stor ... t/register

Note: You must enter the codes below at the end of the code I am telling you to find.
(To easily find code, press control f on a pc, or command f on a mac)
------------------------------------------------------------------------------------------------------------
1st.

GO TO: catalog/view/theme/"default or your custom theme folder"/template/account/register.tpl (after newsletter code, around line 200)

*FIND THIS CODE:

Code: Select all

<h2><?php echo $text_newsletter; ?></h2>
    <div class="content">
      <table class="form">
        <tr>
          <td><?php echo $entry_newsletter; ?></td>
          <td><?php if ($newsletter == 1) { ?>
            <input type="radio" name="newsletter" value="1" checked="checked" />
            <?php echo $text_yes; ?>
            <input type="radio" name="newsletter" value="0" />
            <?php echo $text_no; ?>
            <?php } else { ?>
            <input type="radio" name="newsletter" value="1" />
            <?php echo $text_yes; ?>
            <input type="radio" name="newsletter" value="0" checked="checked" />
            <?php echo $text_no; ?>
            <?php } ?></td>
        </tr>
</table>
</div>
*ENTER THIS ON THE NEXT LINE BELOW:

Code: Select all

<div class="content">
&nbsp;<span class="required">*</span>   <b><?php echo $entry_captcha; ?></b><br />
    <input type="text" name="captcha" value="<?php echo $captcha; ?>" />
    <br />
    <img src="index.php?route=information/contact/captcha" alt="" />
    <?php if ($error_captcha) { ?>
    <span class="error"><?php echo $error_captcha; ?></span>
    <?php } ?>
</div>
If you refresh the page, you'll notice there are undefined variables we need to address!

LETS GET'ER DONE!
------------------------------------------------------------------------------------------------------------
2nd.

GO TO: catalog/language/english/account.register.php

*FIND THIS CODE:

Code: Select all

$_['entry_confirm']        = 'Password Confirm:';
*ENTER THIS ON THE NEXT LINE BELOW:

Code: Select all

$_['entry_captcha']        = 'Enter the code in the box below:';
*THEN FIND THIS CODE:

Code: Select all

$_['error_agree']          = 'Warning: You must agree to the %s!';
*ENTER THIS ON THE NEXT LINE BELOW:

Code: Select all

$_['error_captcha']        = 'The captcha code was entered incorrectly, please try again!';
------------------------------------------------------------------------------------------------------------
3rd.

GO TO: catalog/controller/account/register.php

*FIND THIS CODE:

Code: Select all

$this->data['button_continue'] = $this->language->get('button_continue');
*ENTER THIS ON THE NEXT LINE BELOW:

Code: Select all

$this->data['entry_captcha'] = $this->language->get('entry_captcha');
*NEXT FIND THIS CODE:

Code: Select all

if (isset($this->error['zone'])) {
			$this->data['error_zone'] = $this->error['zone'];
		} else {
			$this->data['error_zone'] = '';
		}
*ENTER THIS ON THE NEXT LINE BELOW:

Code: Select all

if (isset($this->error['captcha'])) {
			$this->data['error_captcha'] = $this->error['captcha'];
		} else {
			$this->data['error_captcha'] = '';
		}


*NEXT FIND THIS CODE:

Code: Select all

if (isset($this->request->post['newsletter'])) {
    		$this->data['newsletter'] = $this->request->post['newsletter'];
		} else {
			$this->data['newsletter'] = '';
		}
*ENTER THIS ON THE NEXT LINE BELOW:

Code: Select all

if (isset($this->request->post['captcha'])) {
			$this->data['captcha'] = $this->request->post['captcha'];
		} else {
			$this->data['captcha'] = '';
		}
*NEXT FIND THIS CODE:

Code: Select all

private function validate() {
    	if ((strlen(utf8_decode($this->request->post['firstname'])) < 1) || (strlen(utf8_decode($this->request->post['firstname'])) > 32)) {
      		$this->error['firstname'] = $this->language->get('error_firstname');
    	}
*ENTER THIS ON THE NEXT LINE BELOW:

Code: Select all

if (!isset($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {
      		$this->error['captcha'] = $this->language->get('error_captcha');
    	}
*NEXT FIND THIS CODE:

Code: Select all

if (!$this->error) {
      		return true;
    	} else {
      		return false;
    	}
  	}
*ENTER THIS ON THE NEXT LINE BELOW:

Code: Select all

public function captcha() {
		$this->load->library('captcha');
		
		$captcha = new Captcha();
		
		$this->session->data['captcha'] = $captcha->getCode();
		
		$captcha->showImage();
	}
------------------------------------------------------------------------------------------------------------

THATS IT!!!

Now you can empty your cache then refresh your browser on your websites registration page.

YOU SHOULD BE GOOD TO GO...

PM me if you have any questions...

Daniel

http://www.whateverhealth.com (My 240 Page Health Book "The Synergy Diet Blueprint")
http://www.rockmebabyclothing.com (Custom Rock Kids Clothes Site)
http://www.christianindustries.com (Web Development Contact)

User avatar
Newbie

Posts

Joined
Fri Sep 09, 2011 2:24 am

Post by rize » Thu Oct 20, 2011 1:06 pm

great, share, thanks!

Newbie

Posts

Joined
Fri Jul 15, 2011 11:29 am

Post by wigatno » Sat Nov 05, 2011 12:05 pm

Sorry, ia'm is newbi using Version 1.5.1.3, I was following the instruction....otherwise I have many problems...looklike this
Parse error: syntax error, unexpected $end in /home/muslimia/public_html/musliminia.com/catalog/controller/account/register.php on line 1
May U help Me..

Best Regards
Hamdani Wigatno

Code: Select all

[url]musliminia.com[/url]

Newbie

Posts

Joined
Wed Oct 12, 2011 1:41 pm

Post by BobHL » Thu Nov 24, 2011 8:51 pm

Thanks for sharing!

Just found this captcha approach has a potential issue, please see this post for details:
http://forum.opencart.com/viewtopic.php?f=161&t=46775

Also, possibly no need to copy function captcha(), as "information/contact/captcha" is used in the view.

Newbie

Posts

Joined
Thu Nov 10, 2011 8:55 pm

Post by fido-x » Thu Nov 24, 2011 9:15 pm

BobHL wrote:Thanks for sharing!

Just found this captcha approach has a potential issue, please see this post for details:
http://forum.opencart.com/viewtopic.php?f=161&t=46775

Also, possibly no need to copy function captcha(), as "information/contact/captcha" is used in the view.
And that is possibly where your "security hole" lies. The captcha that should be loaded is the one that has been inserted into the register controller.

In the code above, what should be placed in "catalog/view/theme/default/account/register.tpl" is:

Code: Select all

<div class="content">
&nbsp;<span class="required">*</span>   <b><?php echo $entry_captcha; ?></b><br />
    <input type="text" name="captcha" value="<?php echo $captcha; ?>" />
    <br />
    <img src="index.php?route=account/register/captcha" alt="" />
    <?php if ($error_captcha) { ?>
    <span class="error"><?php echo $error_captcha; ?></span>
    <?php } ?>
</div>

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Newbie

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by utomo » Tue Nov 29, 2011 10:22 pm

spamming are common now, including the registration spamming.
by having Captcha can reduce of the spamming.
I hope it can be considered to be part of new version core

just my 2c

Newbie

Posts

Joined
Sat Nov 26, 2011 12:55 pm

Post by coolguy » Tue Dec 27, 2011 6:23 am

You are the best. Saved lot of work and money!

Newbie

Posts

Joined
Fri Nov 25, 2011 8:46 pm

Post by SunehraTech » Wed Jul 25, 2012 6:53 am

Works fine for me right now.. Thanks dude..

Newbie

Posts

Joined
Sun Jun 24, 2012 1:19 am

Post by debil » Fri Sep 14, 2012 9:02 pm

I would like to put this login page, authentication code
Please could you help thanks

Newbie

Posts

Joined
Fri Sep 14, 2012 7:11 pm

Post by botonakis » Wed Sep 26, 2012 8:17 pm

Guys, there is free ReCaptcha extension for OpenCart.
For all versions.

User avatar
Newbie

Posts

Joined
Tue Jan 24, 2012 7:55 pm
Location - Athens, Greece
Who is online

Users browsing this forum: No registered users and 6 guests