Originally posted by matt_4013
Could you post the file? It should, in theory, work, however if it's using something like $_SERVER['HTTP_REFERER'] to get the page to make printer-friendly, the <link> tag wont work. May be able to fix it up without too much effort 🙂
Please take a look and see if you can figure this out...
Here is a test page on our site:
www.suumationtechnology.com/5400_test.html
Here is the php script called printit.php:
<?
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");
/
|| Takes the referrer document, only prints the content
|| works only with documents on the same server. good enough :-)
|| V.Satheesh Babu (vsbabu-removethis@vsbabu.org).
||
|| I put an HTML comment called "document_starts_here" before
|| content starts and another one "document_ends_here" after
|| the content. If you have been following some standard like
|| that, it could be useful.
||
|| Installation instructions
|| 1. Copy paste the code here to your favourite editor, and save it as some php3 file
|| 2. The file name doesn't matter. I call it printit.php3
|| 3. From your other web pages make a link to printit.php3
|| 4. Test it out by clicking on the links in those pages
||
/
if ($HTTP_REFERER)
$myURL = $HTTP_REFERER;
else
$myURL = "http://vsbabu.csoft.net/";
// here is the starting comment for your content
$START_CONT="document_starts_here";
// here is the ending comment for your content
$END_CONT = "document_ends_here";
$parsed_url = parse_url($myURL);
$myServer = $parsed_url['host'];
$document = $parsed_url['path'];
if($document[strlen($document)-1]=='/') $document = "$document/index.html";
$base_url = dirname($document);
$fp=fsockopen($myServer,80,&$errno,&$errstr,30);
// if you've name based virtual hosting
$request = "GET $document HTTP/1.1\r\n";
$request .= "Host: $myServer\r\n\r\n";
/ if you've normal old type servers,
comment out the previous two lines and
use the next line instead
/
//$request = "GET $document HTTP/1.0\r\n\r\n";
if(!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
fputs($fp,$request);
$content=0;
$in_title=0;
?>
<HTML>
<HEAD>
<BASE HREF="<? echo "http://$myServer$base_url/"; ?>">
<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>
<?
while(!feof($fp)) {
$line=fgets($fp,4096);
// this is the stupid part - get the title
// python makes this so easy :-)
if(eregi("<title>",$line)){ $in_title=1; }
if ($in_title==1) $title.=$line;
if(eregi("</title>",$line)){
$in_title=0;
if(!eregi("<title>",$line))
$title.=$line;
}
if(ereg($START_CONT,$line)) {
$title = eregi_replace("</title>","",eregi_replace("<title>","",$title));
echo "<TITLE>$title</TITLE>\n</HEAD>\n<BODY>\n";
$content=1;
}
if(ereg($END_CONT,$line)) $content=0;
if($content==1)echo $line;
}
fclose($fp);
?>
</BODY>
</HTML>
<?
}
?>