Hi,
I have been working on a printer-friendly script which will allow me to produce printer-friendly pages for those pages which are produced dynamically (i.e. that don't actually exist on the server).
It is almost working except that I get two problems, which may be related.
1) The script is slow
2) It displays the following:
- c3 fd0
- 52 59d
in the page's contents.
I have no idea where they have come from. To see what I mean take a look here:
http://www.ski-info-online.com/skiResort-print1.php
and click on the "Print Review" button.
Does anyone have any ideas how these numbers are being generated to the page?
Thanks
Torrent
Below is a copy of the print.php script.
<?
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modifieed: ". gmdate("D, d M Y H:i:s"). " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: post-check=0,pre-check=0");
header("Cache-Control: max-age=0");
header("Pragma: no-cache");
if ($HTTP_REFERER){
$myURL = $HTTP_REFERER;
} else {
$myURL = "http://www.ski-info-online.com/";
}
$START_CONT = "<!-- CONTENT STARTS -->";
$END_CONT = "<!-- CONTENT ENDS -->";
$parsed_url = parse_url($myURL);
$myServer = $parsed_url['host'];
$document = $parsed_url['path'];
$query = $parsed_url['query'];
if($document[strlen($document)-1]=='/'){
$document = "$document/index.php";
$base_url = dirname($document);
}
$fp=fsockopen($myServer,80,&$errno,&$errstr,30);
$request = "GET $document"."?"."$query"." HTTP/1.1\r\n";
$request .= "Host: $myServer\r\n\r\n";
if(!$fp) {
echo "Unable to open socket connection to $myServer<br>\n";
echo "Error String = \"$errstr\"<br>\n";
echo "Error Number = \"($errno)\"<br>\n";
echo "Referrer = \"$myURL\"<br><br>\n";
echo "Script Vars:<br>\n";
echo "START_CONT = $START_CONT<br>\n";
echo "END_CONT = $END_CONT<br>\n";
echo "File Pointer = $fp<br>\n";
echo "Request = $request<br>\n";
} else {
fputs($fp,$request);
$content=0;
$in_title=0;
?>
<HEAD>
<BASE HREF="<? echo "http://$myServer$base_url/"; ?>">
<link rel="stylesheet" href="printable.css">
<?
while(!feof($fp)) {
$line=fgets($fp,4096);
if(ereg($START_CONT,$line)) {
$content=1;
}
if(ereg($END_CONT,$line)) $content=0;
if($content==1)echo $line;
}
fclose($fp);
?>
<HR>
<CENTER>
<SMALL>Copyright © <U>Ski-Info-Online.com</U>. All rights reserved.</SMALL><BR>
<?echo "<A HREF=\"$myURL\"><SMALL><I>$myURL</I></SMALL></A>\n";?>
</CENTER>
</BODY>
<?
}
?>