Support » Plugin: Cerber Security, Antispam & Malware Scan » Call to undefined function getallheaders()

  • Resolved Nazar Hotsa

    (@bugnumber9)


    Hi Gioni,

    I’ve enabled “Save request headers”, “Save $ SERVER” and “Save request cookies” options in Traffic Inspector and the following error pops up in error log:

    PHP Fatal error:  Uncaught Error: Call to undefined function getallheaders() in .../wp-content/plugins/wp-cerber/cerber-load.php:4933
    Stack trace:
    #0 [internal function]: cerber_traffic_log()
    #1 {main}
      thrown in .../wp-content/plugins/wp-cerber/cerber-load.php on line 4933

    Judging from https://www.popmartian.com/tipsntricks/2015/07/14/howto-use-php-getallheaders-under-fastcgi-php-fpm-nginx-etc/ the problem is here:

    If you use Nginx, PHP-FPM or any other FastCGI method of running PHP you’ve probably noticed that the function getallheaders() does not exist.

    Indeed, the website that has this issue runs under PHP-FPM. A simple fix from the above article:

    if (!function_exists('getallheaders')) {
        function getallheaders() {
        $headers = [];
        foreach ($_SERVER as $name => $value) {
            if (substr($name, 0, 5) == 'HTTP_') {
                $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
            }
        }
        return $headers;
        }
    }

    Hope this helps 🙂

Viewing 1 replies (of 1 total)
  • Plugin Author Gioni

    (@gioni)

    Hi Nazar! Thanks for telling me! I think I’ll implement this fix in the next version.

Viewing 1 replies (of 1 total)
  • The topic ‘Call to undefined function getallheaders()’ is closed to new replies.