public static function download_file_xsendfile($file_path, $filename)
{
$parsed_file_path = self::parse_file_path($file_path);
if (function_exists('apache_get_modules') && in_array('mod_xsendfile', apache_get_modules())) {
self::download_headers($parsed_file_path['file_path'], $filename);
header("X-Sendfile: " . $parsed_file_path['file_path']);
exit;
} elseif (stristr(getenv('SERVER_SOFTWARE'), 'lighttpd')) {
self::download_headers($parsed_file_path['file_path'], $filename);
header("X-Lighttpd-Sendfile: " . $parsed_file_path['file_path']);
exit;
} elseif (stristr(getenv('SERVER_SOFTWARE'), 'nginx') || stristr(getenv('SERVER_SOFTWARE'), 'cherokee')) {
self::download_headers($parsed_file_path['file_path'], $filename);
$xsendfile_path = trim(preg_replace('`^' . str_replace('\\', '/', getcwd()) . '`', '', $parsed_file_path['file_path']), '/');
header("X-Accel-Redirect: /{$xsendfile_path}");
exit;
}
// Fallback
self::download_file_force($file_path, $filename);
}