Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opencart, OC 1.5.1.3, captcha error

OC 1.5.1.3, the Captcha image doesn't show on none of these pages:

  1. product / review section
  2. contact page
  3. by accessing this http://www.directmall.co.uk/index.php?route=information/contact/captcha (the direct link which should generate the image)

I can't see any errors (Apache logs / error.txt file). I can't see any spaces within the language files - in fact I've redownloaded the entire EN package just to make sure..

I suspect a broken dependency (even if I have GD.. there must be something else..); disabled entirely caching - need assistance!

Back in 2009 I've found trails of such errors on forums but it seems there was a language-file problem, meaning trails of spaces were sending the page headers earlier than normal - but I've checked most of the files I thought to be involved and I've cleaned all the extra spaces - with no result.

Thanks, Bogdan

like image 587
Bogdan Ciocoiu Avatar asked Dec 01 '22 01:12

Bogdan Ciocoiu


2 Answers

FYI I had this same problem and this solution (change to system\library\captcha.php) did make the captcha image display successfully and the form passes validation:

function getCode(){
$out = ob_get_contents();
$out = str_replace(array("\n", "\r", "\t", " "), "", $this->code);
ob_end_clean();

    return $out;
}
like image 101
Jon Ewing Avatar answered Dec 04 '22 04:12

Jon Ewing


For OC 1.5.* Go to

system\library\captcha.php

Find function getCode() Replace this function to

function getCode(){
$code= ob_get_contents();
$code= str_replace(array("\n", "\r", "\t", " "), "", $this->code);
ob_end_clean()    return $code; }

Now For OC 2.1.* Go to

Catalog/controller/captcha/basic-captcha

Find $this->session->data['captcha'] = substr(sha1(mt_rand()), 17, 6);

place below code after this

    $code= ob_get_contents();
    $code= str_replace(array("\n", "\r", "\t", " "), "",$this->session->data['captcha']);
    ob_end_clean();
    $this->session->data['captcha'] = $code;

And For OC 2.3.* Go to

Catalog/controller/Extension/captcha/basic-captcha.php Find $this->session->data['captcha'] = substr(sha1(mt_rand()), 17, 6); Place below code after this

    $code= ob_get_contents();
    $code= str_replace(array("\n", "\r", "\t", " "), "",$this->session->data['captcha']);
    ob_end_clean();
    $this->session->data['captcha'] = $code;

Its helpfull !

like image 31
Pavan Avatar answered Dec 04 '22 04:12

Pavan