4

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

4

7 回答 7

14

仅供参考,我遇到了同样的问题,这个解决方案(更改为 system\library\captcha.php)确实使验证码图像显示成功并且表单通过了验证:

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

    return $out;
}
于 2012-12-11T13:13:03.553 回答
2

对于 OC 1.5.* 转到

系统\库\captcha.php

Findfunction getCode()将此函数替换为

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

现在对于 OC 2.1.* 转到

目录/控制器/验证码/基本验证码

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

在此之后放置以下代码

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

对于 OC 2.3.* 转到

Catalog/controller/Extension/captcha/basic-captcha.php$this->session->data['captcha'] = substr(sha1(mt_rand()), 17, 6); 在此之后的代码下面找到地方

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

它有帮助!

于 2017-05-16T06:53:10.323 回答
1

您应该在 getcode 函数之后添加此代码(库中的 captcha.php)

$out = ob_get_contents();
$out = str_replace(array("\n", "\r", "\t", " "), "", $input);
ob_end_clean();
于 2012-01-30T16:05:45.927 回答
1

Doing a view-source:http://www.directmall.co.uk/index.php?route=information/contact/captcha on Google Chrome showed me that there's a whitespace at the front of the content of the image.

You might have accidentally outputted "\n" somewhere in your code before <?php or after ?>,

于 2011-11-24T23:32:01.893 回答
1

只是为了澄清任何寻找这个的人。系统/库/captcha.php

更改函数第 11 行 getCode()

对此:

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

            return $out;
}

这个应该可以的。

于 2013-07-05T13:22:08.310 回答
0

我最近遇到了这个问题,这个常见的解决方案(以前对我有用)不起作用:

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

我注意到 /system/library/captcha.php 中的 showImage() 方法直接访问 $this->code 而不是使用它的 getter getCode()。这意味着它绕过了去除空格的功能。

但是,像这样修改构造函数就可以了:

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

可以在此处找到更多信息和应用此修复的 vQmod 扩展: http ://www.antropy.co.uk/blog/opencart-captcha-not-working-jfif/

于 2014-11-26T14:46:19.123 回答
0

我有同样的问题,我的特殊情况,这就是解决方案。可能是在修复 product.php 时引入了一些空行,非常难以调试。无论如何,这段代码:

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

return $out;

确实修复了它,因为它清除了任何不应该存在的东西。

希望它可以帮助任何人。

于 2013-07-03T02:52:08.157 回答