shrift - 2008-07-31

I have run into a problem using awstats when called from a php script. Basically on some browsers (Firefox and IE that I know of) the header seems to not be sent when loading the script, this makes the evaluate this function:

sub http_head {
if (! $HeaderHTTPSent) {

as false. That makes it print out an http header. This is probably well and good normally, but when this is being inserted into my php page it causes the awstats page to not show up correctly. The source code looks like this when that happens:

Content-type: text/html; charset=
Cache-Control: public
Last-Modified: Thu Jul 31 12:14:22 2008
Expires: Thu Jul 31 12:14:22 2008

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html lang='en'>
<meta name="generator" content="AWStats 6.5 (build 1.857) from config file (">
<meta name="robots" content="noindex,nofollow">
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta http-equiv="description" content="Awstats - Advanced Web Statistics for (2008-07)">
<title>Statistics for (2008-07)</title>

<frameset cols="240,*">
<frame name="mainleft" src="" noresize="noresize" frameborder="0" />
<frame name="mainright" src="" noresize="noresize" scrolling="yes" frameborder="0" />
<noframes><body>Your browser does not support frames.<br />
You must set AWStats UseFramesWhenCGI parameter to 0
to see your reports.<br />



So my proposal is to add a line into awstats that would allow us to tell that this header has already been set. I added this line and it works, but that doesn't mean this is the best way to do this... I would love to hear if anyone has a better idea. Especially if anyone knows how I can fix this WITHOUT editing

if ($ENV{'HeaderHTTPSent'}) {
$HeaderHTTPSent = $ENV{'HeaderHTTPSent'};

I put that right before:

Here charset is defined, so we can send the http header (Need BuildReportFormat,PageCode)

if (! $HeaderHTTPSent && $ENV{'GATEWAY_INTERFACE'}) { http_head(); } # Run from a browser as CGI

And this works well for me.

As I mentioned, this is a bit hackish and I would prefer to be able to not edit my, but as the $HeaderHTTPSent is an internal variable, I am not sure how else to do that?