• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

i can't find this

megacool

New Member
I am looking for a PHP or Perl script that will let me output certain part of a current HTML page (stripping out unneccessary stuff like banners, menus etc) so that it will be "Printer-Friendly". So far i checkout hotscripts and resource index.. found two script which don't seem to work. Does anyone know of sucha script?
 
I'm not certain exactly what you're looking for. Here's a script that will take a file and print anything in it between <!--print--> and <!--/print--> tags, ignoring the rest. To use it just provide a link like:

<a href="/url/to/script.pl?/path/to/file">Show printable version</a>

Code:
#!perl

print "Content-type: text/html\n\n";
open(FILE,"<".$ENV{'QUERY_STRING'});
while(<FILE>){
	$line=$_;
	if($line=~/<!--print-->(.+?)$/){
		$line=$1;
		$p=1;
	}elsif($line=~/<!--print-->/){
		$p=1;
	}
	if($p==1){
		if($line=~/^<!--\/print-->/){
			$p=0;
		}elsif($line=~/^(.+?)<!--\/print-->/){
			print $1;
			$p=0;
		}else{
			print $line;
		}
	}
}
close(FILE);
 
Back
Top