Zebra_Form
Zebra_Form copied to clipboard
Captcha img not showing
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 ?