Forum Moderators: coopster

Message Too Old, No Replies

Printer-Friendly Version generation problem

         

Lynk_Former

4:38 pm on Jul 29, 2005 (gmt 0)

10+ Year Member



Here's the code I'm using...

<?php

$print_grab = fread(fopen($HTTP_REFERER, 'r'), 100000);

if ($print_grab) {
$print_start = strpos($print_grab, '<!-- CONTENT START -->');
$print_finish = strpos($print_grab, '<!-- CONTENT END -->');
$print_length = $print_finish-$print_start;
$print_code = Substr($print_grab, $print_start, $print_length);
}

?>

It's supposed to grab code from a referer page and put it into the printer friendly version. It works... well half the time. So far it only works on certain smaller pages but NOT on larger pages.

Got any ideas why that is?...

[edited by: jatar_k at 5:42 pm (utc) on July 29, 2005]
[edit reason] no urls thanks [/edit]

dcrombie

10:05 am on Jul 30, 2005 (gmt 0)



Have you tried increasing the 100000-byte limit?

Lynk_Former

1:21 pm on Jul 30, 2005 (gmt 0)

10+ Year Member



yes I have tried that but it has no affect.

coopster

1:25 am on Aug 3, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Lynk_Former.

Another problem may be the variable itself. HTTP_REFERER is not a reliable variable as it can be spoofed and it is not always present.

chrisjoha

6:25 am on Aug 3, 2005 (gmt 0)

10+ Year Member



You could get away with the whole problem using (x)html/css. This way you can specify a dedicated stylesheet for print using the @media directive ;)