This issue is a recap of this thread on forums.webdeveloper.com
You guys are so active here, perhaps, you can help me!
CANNOT FIGURE OUT THE PROBLEM:
same html page, same php script uploaded to different domains on the same server: one is working, the other one is not:
WORKING ON THE FIRST DOMAIN - brings the pfv page beautifully
NOT WORKING ON THE SECOND DOMAIN - echoes the referer url, so it's not totally failing, but just doesn't grab the <!-- CONTENT--><!-- /CONTENT-->.
WORKING EXPERIMENT WITH CROSS-DOMAINS- html page reside on first domain, referring to php code on second domain (same domain I can't get to working in example 2)
(ignore "dirty" html page, it's an inherited site, I'll get to cleaning when I can)
I don't understand, why same thing will work on one domain and wouldn't work on the other, and work again if cross-domained. Files were all uploaded in the same mode, all the server settings are applicable to both domains.... I just don't get it!
Somebody, give me a clue! I kinda need to resolve it ASAP, since I'll have to clean over 400 pages and make them all printer-friendly-enabled before week's end...
here is the php code (taken and adapted from HotScripts):
<?php
$fd= fread(fopen($HTTP_REFERER, "r"), 100000);
if ($fd)
{
$start= strpos($fd, "<!-- CONTENT -->");
$finish= strpos($fd, "<!-- /CONTENT -->");
$length= $finish-$start;
$code=Substr($fd, $start, $length);
}
echo '<html>
<head>
<title>CRI: Printer-Friendly Version</title>
</head>
<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
'.$code.'
<br>
<hr noshade size="1">
<div style="font-family:Verdana,Arial; font-size:10px; color:#999999">'.$HTTP_REFERER.'<br> </div>
<hr noshade size="1">
</body>
</html>';
?>
adding $HTTP_REFERER = $_SERVER['HTTP_SERVER']; makes no difference.
here is a little sample html:
<html>
<head>
<title>pfv test</title>
<meta>
</head>
<body>
<a href="cri_pfv.php">Printer-friendly version</a>
<p>this text should not be visible</p>
<!-- CONTENT --><p>and now printer-friendly version</p><!-- /CONTENT -->
</body>
</html>
I also tried different php code (for example, from mikenew.net)
Somebody, help me figure this out!!! Thanks!