Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace default captcha script not working #4166

Open
jabberdquestions opened this issue Feb 26, 2024 · 2 comments
Open

Replace default captcha script not working #4166

jabberdquestions opened this issue Feb 26, 2024 · 2 comments

Comments

@jabberdquestions
Copy link

I have replaced the default script with a custom one but it is not working for now. Right now I am trying to replace the current script with one developed in PHP, this script takes the random number generated as argument, create a captcha based on that value and output a binary image as content

In my ejabberd configuration I have specified to use a different script in this way:

captcha_cmd: "php -f /usr/share/ejabberd/mycaptcha.php"

And this is how I am producing the binary image:

imagestring($this->image, 5, 3, 0, $this->text, $color);
imagepng($this->image);

If I execute the script directly from the terminal like this php -f /usr/share/ejabberd/mycaptcha.php 123456 > test.png The captcha is generated properly

But when I restart ejabberd is not working and I am getting the following output in the logs:

[error] <0.525.0>@ejabberd_captcha:do_create_image/2:431 Failed to process an output from "php -f /usr/share/ejabberd/mycaptcha.php 686389": efbig
[critical] <0.525.0>@ejabberd_captcha:check_captcha_setup/0:577 Captcha is enabled in the option captcha_cmd, but it can't generate images.

Am I missing something? Thanks

@licaon-kter
Copy link
Contributor

Where is your script saving the captcha?

@jabberdquestions
Copy link
Author

I was just directly outputing the binary image. But after reviewing more carefully the default captcha I see that conver/ImageMagick is using a pseudo-filename pipping the output using a standard stream STDOUT. I have modified my script as it follows:

imagestring($this->image, 5, 3, 0, $this->text, $color);
fwrite(STDOUT, imagepng($this->image));

But I still have the same output in the logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants