Hey, everyone.
Here's a bit of code that is supposed to check a referring page for <!--Text starts here--> and <!--Text ends here--> tags and return all the content so I can display it as a printer-friendly document, w/o any graphics etc.
It's called just by linking to it. Ignore the HTML, that's just to make it look somewhat pretty.
Wierd thing: works on my dev server and not on my webserver. Both run PHP 4.
Any explanations?
<HEAD>
<title>Premier :: Achievement :: Effectiveness</title>
<BASE HREF="<? echo "$HTTP_REFERER"; ?>">
<STYLE TYPE="TEXT/CSS">
<!--
body,p {
background: #FFFFFF;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10pt;
margin-left: 5px;
margin-top: 5px;
margin-right: 5px;
margin-bottom: 5px;
color: #000000;
text-align: justify;
}
TH.headerrow {
background-color: #CDC8B1;
font-family: verdana,courier;
font-size: 10pt;
color: black;
}
TD.datarow {
font-family: verdana,courier;
font-size: 10pt;
color: black;
}
//-->
</STYLE>
</HEAD>
<BODY>
<center>
<table border="0" cellpadding="0" cellspacing="10" width="600">
<tr>
<td width="150"></td>
<td>
<center>
<h2><b>PREMIER, A FRANKLIN COVEY COMPANY</b></h2><P>
<?echo "<CENTER><A HREF=\"$HTTP_REFERER\"><I>$HTTP_REFERER</I></A><CENTER>";?>
<h2><b>Printer Friendly Format</b></h2>
</center>
<br>
<?
/
|| Takes the referrer document, only prints the content
|| works only with documents on the same server. good enough :-)
/
$document=ereg_replace("http://$SERVER_NAME/","",$HTTP_REFERER);
$fp=fsockopen($SERVER_NAME,$SERVER_PORT,&$errno,&$errstr,30);
if(!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
fputs($fp,"GET /$document HTTP/1.0\n\n");
$content=0;
while(!feof($fp)) {
$line=fgets($fp,4096);
if(ereg("<title>",$line))
{
echo "$line";
}
if(ereg("<!--Text Starts Here-->",$line)) $content=1;
if(ereg("<!--Text Ends Here-->",$line)) $content=0;
if($content==1)echo $line;
}
fclose($fp);
?>
<HR>
<CENTER>
<SMALL>Copyright © 2000 Premier, a Franklin Covey Company. All rights reserved.</SMALL><BR>
<?echo "<A HREF=\"$HTTP_REFERER\"><SMALL><I>$HTTP_REFERER</I></SMALL></A>\n";?>
</CENTER>
</td>
</tr>
</table>
</center>
</BODY>
<?
}
?>