How to make KoolReport run in Virtual Directories

KoolReport does not look up its root path correctly. Here's a fix.

I was wondering why the path lookup in KoolReport (see also this) doesn't work. Turns out, in examples/helpers/common.php, I had to change

return $root_url;

into this:

$protocol   = empty($_SERVER['HTTPS'])? 'http' : 'https';
    $servername = $_SERVER['SERVER_NAME'];
    $serverport = $_SERVER['SERVER_PORT']=='80'? '' : ':' . $_SERVER['SERVER_PORT'];
    $path       = str_replace('\\', '/', substr(dirname(__FILE__), strlen($_SERVER['DOCUMENT_ROOT'])));

    $root_url = $protocol . '://' . $servername . $serverport . $root_url;

    // error_log(print_r("Root Url: " . $root_url, TRUE));

    return $root_url;

Plus, in koolreport/core/src/core/Utility.php, I had to comment in

if (isset($_SERVER["DOCUMENT_ROOT"])) return $_SERVER["DOCUMENT_ROOT"];

at the top of public static function getDocumentRoot().