Opencart, OC 1.5.1.3, captcha error

OC 1.5.1.3, the Captcha image is not displayed on any of these pages:

I do not see errors (Apache file / error.txt file). I do not see any spaces in the language files - in fact, I completely downloaded the entire EN package to verify this.

I suspect that I have a broken dependency (even if I have GD .. there must be something else ...); Disabled fully caching - need help!

Back in 2009, I found trails of such errors on forums, but it seemed that the problem with language files meant that the space trails sent page headers earlier than usual, but I checked most of the files I thought it was involved and I cleared all the extra spaces - no result.

Thank you Bogdan

+4
source share
7 answers

FYI I had the same problem and this solution (change in system \ library \ captcha.php) really successfully completed the display of the captcha image, and the form passed the test:

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

For OC 1.5. * Go to

System \ Library \ captcha.php

Find function getCode() Replace this function with

 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. * Switch to

Directory / controller / CAPTCHA, / base CAPTCHA,

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

enter the code below after that

  $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. * Switch to

Directory / controller / Extension / CAPTCHA, / base captcha.php Locate $this->session->data['captcha'] = substr(sha1(mt_rand()), 17, 6); Put 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; 

Useful!

+2
source

Running view-source:http://www.directmall.co.uk/index.php?route=information/contact/captcha in Google Chrome showed me that there is a space before the image content.

Perhaps you accidentally chose "\n" somewhere in your code before <?php or after ?> ,

+1
source

you must add this code after the getcode function (captcha.php in the library)

 $out = ob_get_contents(); $out = str_replace(array("\n", "\r", "\t", " "), "", $input); ob_end_clean(); 
+1
source

Just to make it clear who needs it. system /library/captcha.php

change function line 11 getCode ()

:

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

That should do it.

+1
source

I had the same problem, and in my particular case it was a solution. Perhaps when fixing product.php, empty lines were introduced that are extremely difficult to debug. In any case, this code:

 $out = ob_get_contents(); $out = str_replace(array("\n", "\r", "\t", " "), "", $input); ob_end_clean(); return $out; 

fixed it, as it cleans everything that should not be there.

Hope this helps anyone.

0
source

I recently ran into this problem and this general solution (which worked for me before) did not work:

 $out = ob_get_contents(); $out = str_replace(array("\n", "\r", "\t", " "), "", $input); ob_end_clean(); return $out; 

I noticed that the showImage () method in /system/library/captcha.php accesses the $ this-> code directly, and not its getter, getCode (). This means that it skips the function to separate spaces.

However, a modification of such a constructor did the trick:

 function __construct() { $this->code = substr(sha1(mt_rand()), 17, 6); $this->code = str_replace(array("\n", "\r", "\t", " "), "", $this->code); } 

Additional information and the vQmod extension for applying this hotfix can be found here: http://www.antropy.co.uk/blog/opencart-captcha-not-working-jfif/

0
source

Source: https://habr.com/ru/post/1382973/


All Articles