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

Captcha img not showing #31

Open
imasubmarine opened this issue Aug 25, 2016 · 0 comments
Open

Captcha img not showing #31

imasubmarine opened this issue Aug 25, 2016 · 0 comments

Comments

@imasubmarine
Copy link

There are cases where the generated captcha image url is wrong hence the captcha img not showing.
The form_properties['assets_url'] which is used to construct the url might be broken.

In some environments, $_SERVER['DOCUMENT_ROOT'] might be resolved using realpath in order to match the directory root path returned by dirname(FILE).

Below is an example on 1&1 shared hosting .

$_SERVER['DOCUMENT_ROOT']  : /kunden/homepages/2/d518563529/htdocs/yourappfolder/
dirname(__FILE__) : /homepages/2/d518563529/htdocs/yourappfolder/zebraform

Resulting on returning a broken path in assets_url (Zebra_Form.php line 179)

rtrim(str_replace('\\', '/', 'http' . (isset($_SERVER['HTTPS']) || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ? 's' : '') . '://' . rtrim($_SERVER['HTTP_HOST'], '\\/') . '/' . substr(rtrim(dirname(__FILE__), '\\/'), strlen($_SERVER['DOCUMENT_ROOT']))), '\\/') . '/'

Replacing $_SERVER['DOCUMENT_ROOT'] by realpath($_SERVER['DOCUMENT_ROOT'])."/"
in the expression above fixed the problem for me.

If someone have a better idea ?

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

1 participant