Page 1 of 1

[SOLVED] ETAG junk after HTML body, but where from?

Posted: Wed Mar 15, 2006 4:39 am
by dasantillo
I've suddenly started getting various messages after the </html> tag on my webpage, which appends various things such as:

"ETag: "2524a75 HTTP/1.1 304 Not Modified Date: Wed, 15 Mar 2006 10:28:27 GMT Server: Apache/1.3.33 ETag: "2524a77 HTTP/1.1 304 Not Modified Date: Wed, 15 Mar 2006 10:28:27 GMT Server: Apache/1.3.33 (Unix) Connection: Keep-Alive, Keep-Alive Keep-Alive: timeout=2, max=196 ETag: "2524a78-6f2-44117e05" HTTP/1.1 304 Not Modified Date: WedServer: Apache/1.3.33ETag: "2524a7a HTTP/1.1 304 Not Modified Date: Wed, 15 Mar 2006 10:28:ETag: "2524a7b"

The webpage is generated from php and passes validation by W3C - it happens on both my local Apache server I used for testing and also when remotely on my service provider's servers.

It's never happened on my other website, also in PHP. I've only seen it in Opera on Windows, but I use that all the time and only occasionally check it on IE, Firefox and Netscape.

I have a .htaccess file to provide password access as it's for a customer, but that's only on my remote site and not my local server.

It looks like a server thing rather than my code, but I would appreciate any suggestions if anyone has seen this before - I've searched here and google but haven't found anything similar.

Just to make things awkward, it doesn't always happen...

Many Thanks in advance.

KR

Dan.

Posted: Wed Mar 15, 2006 8:11 am
by feyd
If you've written your code such that you insert your page response into the headers, it's your code.

The output you are getting are supposed to be apart of the headers sent to the browser prior to the page content.

Posted: Wed Mar 15, 2006 8:12 am
by anjanesh
Its either a PHP bug or someone managed to attacked your server.

Posted: Wed Mar 15, 2006 8:41 am
by dasantillo
feyd wrote:If you've written your code such that you insert your page response into the headers, it's your code.

The output you are getting are supposed to be apart of the headers sent to the browser prior to the page content.
Thanks for replying. My code, to my knowledge, doesn't do anything with page responses - just draws a standard web page. My code ends at the </html> tag, but this comes after it.

It could be the browser (Opera) throwing a bit of a wobbly for some reason and writing its response on the page. If I discover anything else, or the reason, I'll post it here.
anjanesh wrote:Its either a PHP bug or someone managed to attacked your server.
Thanks for replying. As it appears on both my local (protected by Symantec Firewall) and remote server (run by 1 and 1) I would say the chances of it being attacked are slim. PHP 4.4.2 is being run both on my local Apache 2.0.55(Win32) server and also by 1 and 1 on their Apache 1.3.33(Unix) server.

KR

Dan.

Posted: Wed Mar 15, 2006 10:08 am
by Weirdan
It seems it has something to do with Http persistent connections... try to turn this option off in your browser

Posted: Wed Mar 15, 2006 10:41 am
by Roja
Show the code, or we can do nothing more than guess. :)

Posted: Wed Mar 15, 2006 11:16 am
by dasantillo
Roja wrote:Show the code, or we can do nothing more than guess. :)
OK, here it is (sorry it's rather a long post):

Code: Select all

<?php 
include("../common.php");
include("readnews.php");
write_html_header();
?>

<body>
<?php write_NavBarJavaScript(); ?>

<?php write_PageBodyTop(NEWS); ?>

<!-- Page Data Start -->
<?php $newsStory = $_GET['news']; ?>

<table align="center" border="0" cellspacing="1" cellpadding="0" width="100%">
	<tr>
		<td valign="top">
		<table border="0" cellspacing="1" cellpadding="1" width="100%">
			<tr>

			<td valign="top">
<?php 
if (isset($newsStory))
   {
   echo '<p class="backtoheadlines"><a class="link" href='.$PHP_SELF.'?>Back to News Index</a></p>';
   if (file_exists('articles/'.$newsStory))
		include ('articles/'.$newsStory);
	else
		echo '<p class="error">The news story "'.$newsStory.'" doesn\'t exist!</p>';
	echo '<p>&nbsp;</p>';
   echo '<p class="backtoheadlines"><a class="link" href='.$PHP_SELF.'?>Back to News Index</a></p>';
	}
else
   {
	$headlines=readNews('news.xml');
	for ($x = 0; $x < count($headlines); $x++)
		{
		$storylink = $PHP_SELF.'?news='.$headlines[$x][FULLSTORY];
		echo '<p class="headline"><a class="partiallink" href="'.$storylink.'">'.$headlines[$x][HEADLINE].'</a></p>';
		echo '<p class="synopsis"><a class="hiddenlink" href="'.$storylink.'">'.$headlines[$x][SYNOPSIS].'</a></p>';
		echo '<p class="fullstory"><a class="link" href="'.$storylink.'">Full Story</a></p>';
		echo '<p>&nbsp;</p>';
		}
	}
?>
         </td>
<?php
if (isset($newsStory))
   echo '<td width="163" valign="top"> <p class="centered"><img src="side2.jpg" width="161" height="500" align="left" alt=""></p></td>';
else
   echo '<td width="50%" valign="top"> <p class="centered"><img src="side1.jpg" width="271" height="400" align="middle" alt=""></p></td>';
?>
			</tr>
		</table>
		</td>
	</tr>
</table>

<!-- Page Data End -->

<?php 
if (isset($newsStory))
   write_PageBodyBottom(); 
else
	{
	$file = parseTabbedFile('batting.dat');
	$marquee_batting = '';
   for ($x = 0; $x < count($file); $x++)
	   {
		if ($x > 0)
		   $marquee_batting .= ':: ';
		if (isset ($file[$x][2]) && $file[$x][2]{0} == '*')
		   $bold = true;
		else
			$bold = false;
		if ($bold)
		   $marquee_batting .= '<b>';
		for ($y = 0; $y < 2; $y++)
		   {
		   $marquee_batting .= $file[$x][$y].' ';
			}
		if ($bold)
		   $marquee_batting .= '</b>';
		}
	
	$file = parseTabbedFile('bowling.dat');
	$marquee_bowling = '';
   for ($x = 0; $x < count($file); $x++)
	   {
		if ($x > 0)
		   $marquee_bowling .= ':: ';
		for ($y = 0; $y < count($file[$x]); $y++)
		   $marquee_bowling .= $file[$x][$y].' ';
		}

   write_PageBodyBottom($marquee_batting, $marquee_bowling); 
	}
?>
	
</body>
</html>
write_html_header: writes the standard HTML header on every page
write_NavBarJavaScript: writes the roll-over button script
write_PageBodyTop: Write the top of the page, logo and buttons
readNews: parses an XML file to list the headlines and summary
write_PageBodyBottom: Finishes the page.
parseTabbedFile: Parses an Excel exported file for the marquee <embarrasment>

I apologise for the use of the marquee - the customer wants a scrolling list and I haven't done it in JavaScript yet.
I also apologise for the lack of comments in the code.

Here's the resultant HTML code:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="***DESCRIPTION HERE***">
<meta name="keywords" content="***KEYWORDS HERE***">
<title>CAZ Scores</title>
<link title="Style Sheet 1" rel=stylesheet href="/style_sheet.css">
</head>

<body>
<script language="JavaScript" type="text/javascript">
  if(document.images)
    {
    pics = new Array();

    // Architecture
    pics[1] = new Image();
    pics[1].src = "/nav_pics/news.gif";
    pics[2] = new Image();
    pics[2].src = "/nav_pics/news_hover.gif";
    pics[3] = new Image();
    pics[3].src = "/nav_pics/moreinfo.gif";
    pics[4] = new Image();
    pics[4].src = "/nav_pics/moreinfo_hover.gif";
    pics[5] = new Image();
    pics[5].src = "/nav_pics/archives.gif";
    pics[6] = new Image();
    pics[6].src = "/nav_pics/archives_hover.gif";
    pics[7] = new Image();
    pics[7].src = "/nav_pics/cyo.gif";
    pics[8] = new Image();
    pics[8].src = "/nav_pics/cyo_hover.gif";
    pics[9] = new Image();
    pics[9].src = "/nav_pics/dreamteam.gif";
    pics[10] = new Image();
    pics[10].src = "/nav_pics/dreamteam_hover.gif";
    pics[11] = new Image();
    pics[11].src = "/nav_pics/links.gif";
    pics[12] = new Image();
    pics[12].src = "/nav_pics/links_hover.gif";
    }

    function changer(from,to)
    {
    if(document.images)
      {
      document.images[from].src = pics[to].src;
      }
    }
</script>
<table class="main" align="center" border="0" cellspacing="0" cellpadding="0">
	<tr>
	   <td class="blankcell">&nbsp;</td>
	   <td class="blankline">&nbsp;</td>
	   <td class="blankcell">&nbsp;</td>
	</tr>
	<tr>
	   <td class="blankcell">&nbsp;</td>
	   <td class="blankline">&nbsp;</td>
	   <td class="blankcell">&nbsp;</td>
	</tr>
   <tr>
      <td colspan="3" class="logo"><p class="centered"><a href="/news/"><img src="/header.jpg" width="756" height="84" alt="" border=""></a></p></td>
   </tr>

	<tr>
	   <td class="blankcell">&nbsp;</td>
	   <td class="blankline">&nbsp;</td>
	   <td class="blankcell">&nbsp;</td>
	</tr><tr>
   	   <td class="blankcell">&nbsp;</td>
			<td class="nav"><table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr><td width="126"><p class="centered"><img id="img1" border="0" alt="" src="/nav_pics/news_sel.gif" width="120" height="20"></p></td>
<td width="126"><p class="centered"><a onMouseOver="changer('img3',4)" onMouseOut="changer('img3',3)" href="/moreinfo/"><img id="img3" border="0" alt="" src="/nav_pics/moreinfo.gif" width="120" height="20"></a></p></td>
<td width="126"><p class="centered"><a onMouseOver="changer('img5',6)" onMouseOut="changer('img5',5)" href="/archives/"><img id="img5" border="0" alt="" src="/nav_pics/archives.gif" width="120" height="20"></a></p></td>
<td width="126"><p class="centered"><a onMouseOver="changer('img7',8)" onMouseOut="changer('img7',7)" href="/cyo/"><img id="img7" border="0" alt="" src="/nav_pics/cyo.gif" width="120" height="20"></a></p></td>
<td width="126"><p class="centered"><a onMouseOver="changer('img9',10)" onMouseOut="changer('img9',9)" href="/dreamteam/"><img id="img9" border="0" alt="" src="/nav_pics/dreamteam.gif" width="120" height="20"></a></p></td>
<td width="126"><p class="centered"><a onMouseOver="changer('img11',12)" onMouseOut="changer('img11',11)" href="/links/"><img id="img11" border="0" alt="" src="/nav_pics/links.gif" width="120" height="20"></a></p></td>
</tr>
	</table></td>
		   <td class="blankcell">&nbsp;</td>
		</tr><tr>
	   <td class="blankcell">&nbsp;</td>
	   <td class="blankline">&nbsp;</td>
	   <td class="blankcell">&nbsp;</td>
   </tr>
	<tr>
	   <td class="blankcell">&nbsp;</td>
	   <td>
<!-- Page Data Start -->

<table align="center" border="0" cellspacing="1" cellpadding="0" width="100%">
	<tr>
		<td valign="top">
		<table border="0" cellspacing="1" cellpadding="1" width="100%">
			<tr>

			<td valign="top">
<p class="headline"><a class="partiallink" href="/news/index.php?news=news.html">This is the news headline</a></p><p class="synopsis"><a class="hiddenlink" href="/news/index.php?news=news.html">This is the short synopsis that will appear on the news page. It can be as short or as long as you like!</a></p><p class="fullstory"><a class="link" href="/news/index.php?news=news.html">Full Story</a></p><p>&nbsp;</p><p class="headline"><a class="partiallink" href="/news/index.php?news=news2.html">This is another news headline</a></p><p class="synopsis"><a class="hiddenlink" href="/news/index.php?news=news2.html">This is another short synopsis that will appear on the news page. As much text as you like can be typed here, but only text - no links, etc.</a></p><p class="fullstory"><a class="link" href="/news/index.php?news=news2.html">Full Story</a></p><p>&nbsp;</p>         </td>
<td width="50%" valign="top"> <p class="centered"><img src="side1.jpg" width="271" height="400" align="middle" alt=""></p></td>			</tr>
		</table>
		</td>
	</tr>
</table>

<!-- Page Data End -->

</td>
	   <td class="blankcell">&nbsp;</td>
		</tr>
	<tr>
	   <td class="blankcell">&nbsp;</td>
	   <td class="blankline">&nbsp;</td>
	   <td class="blankcell">&nbsp;</td>
	</tr>
		<tr>
	   <td class="blankcell">&nbsp;</td>
		<td>
		<table align="center" border="0" cellspacing="0" cellpadding="0" width="98%">
		   <tr>
      	<td class="marquee_title"><p>Batting:</p></td>
      	<td class="marquee"><marquee scrolldelay="150"><p><b>abdul razzaq 29 </b>:: abdur razzak 3
 :: aftab ahmed 13
 :: <b>agarkar.ab 16 </b>:: alok kapali 13
 :: anderson.jm 4
 :: arnold.rp 32
</p></marquee></td>
			</tr>
		</table>
		</td>
		   <td class="blankcell">&nbsp;</td>
</tr>
	<tr>
	   <td class="blankcell">&nbsp;</td>
	   <td class="blankline">&nbsp;</td>
	   <td class="blankcell">&nbsp;</td>
	</tr>
	<tr>
	   <td class="blankcell">&nbsp;</td>
		<td>
		<table align="center" border="0" cellspacing="0" cellpadding="0" width="98%">
		   <tr>
      	<td class="marquee_title"><p>Bowling:</p></td>
      	<td class="marquee"><marquee scrolldelay="150"><p>pollock.sm 42
 :: ponting.rt 7
 :: powell.db 9
 :: prince.ag 3
 :: prior.mj 3
</p></marquee></td>
			</tr>
		</table>
		</td>
		   <td class="blankcell">&nbsp;</td>
</tr>
	<tr>
	   <td class="blankcell">&nbsp;</td>
	   <td class="blankline">&nbsp;</td>
	   <td class="blankcell">&nbsp;</td>
	</tr>

		<tr>
			<td colspan="3" class="copyright">

      <p class="copyright">All images and site contents are protected by international copyright 
		and may not be<br>reproduced or used without the written permission of xxxxxxxxxx.</p>

</td>
</tr>
	<tr>
	   <td class="blankcell">&nbsp;</td>
	   <td class="blankline">&nbsp;</td>
	   <td class="blankcell">&nbsp;</td>
	</tr>
	<tr>
	   <td class="blankcell">&nbsp;</td>
	   <td class="blankline">&nbsp;</td>
	   <td class="blankcell">&nbsp;</td>
	</tr>

	</table>	
</body>
</html>
ETag: "2524a75
HTTP/1.1 304 Not Modified
Date: Wed, 15 Mar 2006 16:59:21 GMT
Server: Apache/1.3.33 ETag: "2524a7a
KR

Dan.

Posted: Mon Mar 27, 2006 5:23 am
by dasantillo
It seems to have been caused by the .htaccess file somehow - I've removed it and the problem has disappeared. Weird...