phprint.php
// Back up/copy this file first.
1. Save this script in the root of the site for simplicity.
2. Place
somewhere in your HTML page where you consider it to be the start of printer friendly content, and
goes at the end of that same content. 3. You place a link to phprint.php anywhere on the HTML page (preferably
outside the printed content, like this: Print this page
<---->
- or however you like, just as long as you link to this script. */ // If you've already tested, you can
remove the text from here up to the other: 8 //Do you want to strip images from the printable output?
// If no, change to "no". Otherwise, images are stripped by default. $stripImages = "yes";
//what's the base domain name of your site, without trailing slash? // Just the domain itself, so we can
fix any relative image and link problems. $baseURL="http://www.auntrunnersrecipes.com"; // That's
it! No need to go below here. Upload it and test by going to yoursite.com/page.php // (The page containing
the two tags and a link to this script) // ----------------------------------------------------- $startingpoint
= ""; $endingpoint = ""; // let's turn off any
ugly errors for a sec so we can use our own if necessary... error_reporting(0); // $read = fopen($HTTP_REFERER,
"rb") ... this line may work better if you're using NT, or even FreeBSD $read = fopen($HTTP_REFERER,
"r") or die("
Sorry! There is no access to this file directly. You must follow a link.
Please click your browser's back button.
");
// let's turn errors back on so we can debug if necessary error_reporting(1); $value = ""; while(!feof($read)){
$value .= fread($read, 10000); // reduce number to save server load } fclose($read); $start= strpos($value,
"$startingpoint"); $finish= strpos($value, "$endingpoint"); $length= $finish-$start;
$value=substr($value, $start, $length); function i_denude($variable) { return(eregi_replace(" ]*>",
"", $variable)); } function i_denudef($variable) { return(eregi_replace("]*>",
"", $variable)); } $PHPrint = ("$value"); if ($stripImages == "yes") { $PHPrint
= i_denude("$PHPrint"); } $PHPrint = i_denudef("$PHPrint"); $PHPrint = str_replace(
"", "", $PHPrint ); $PHPrint = stripslashes("$PHPrint"); echo "";
echo $PHPrint; // Next line is invisible except to SE crawlers, please don't remove. Thanks! :) echo "
";
echo "
This page printed from: $HTTP_REFERER";
flush ();
?>
|