Foros del Web » Programando para Internet » PHP »

Version Imprimible

Estas en el tema de Version Imprimible en el foro de PHP en Foros del Web. 1. El ejemplo de las FAQ'S usa $HTTP_REFERER No funciona en mi servidor porque pasa la url completa con http:// y todo. Numero dos la ...
  #1 (permalink)  
Antiguo 10/03/2004, 04:33
 
Fecha de Ingreso: noviembre-2003
Mensajes: 114
Antigüedad: 20 años, 5 meses
Puntos: 0
Version Imprimible

1. El ejemplo de las FAQ'S usa $HTTP_REFERER

No funciona en mi servidor porque pasa la url completa con http:// y todo.

Numero dos la url a imprimir es y debe ser del tipo:

pagina.php?subpagina=html&otra&otra&otra.htm

En local (Windows) $HTTP_REFERER funciona, pero en servidor (UNIX/LINUX) no.

¿Alguna sugerencia para generar versiones imprimibles?
__________________
Soporte y Creaciones PHP-Nuke:
NukeProjects.Net

if($Necesitas=="Ayuda"){
echo "No dudes en pedirla";
}
  #2 (permalink)  
Antiguo 10/03/2004, 06:03
O_O
 
Fecha de Ingreso: enero-2002
Ubicación: Santiago - Chile
Mensajes: 34.417
Antigüedad: 22 años, 3 meses
Puntos: 129
Revisa primero si el problema de acceder a esa variable de servidor es por el uso de register_globals que usa tu servidor (linux) o es que realmente no se está entregando dicho valor a tu servidor (sobre todo si pasas por un proxy, firewall o similar)

$_SERVER['HTTP_REFERER']

------

Si de un URL (o URI se dice?) obtienes http:// etc . .que no te interesa .. tienes la función:

parse_url() para quedarte con lo que te interese de ese URL ..

También tienes otras variabels de servidor tipo: 'QUERY_STRING' para obtener toda variable que se le pasó al script y de ahí componer tu URI a tu pinta ..

Un saludo,
__________________
Por motivos personales ya no puedo estar con Uds. Fue grato haber compartido todos estos años. Igualmente los seguiré leyendo.
  #3 (permalink)  
Antiguo 10/03/2004, 07:29
 
Fecha de Ingreso: noviembre-2003
Mensajes: 114
Antigüedad: 20 años, 5 meses
Puntos: 0
El problema no es optener la url, esa url se la puedo pasar por url etc.

El caso es que estuve usando el ejemplo de las FAQ'S

y me parece que aqui esta el problema:
en ese parametro del ejemplo.

$read = fopen($HTTP_REFERER, "r") or die("No se pudo");

Esto lee/abre la url desde donde se ha pulsado "Imprimir"
He intentado pasarle una ruta relativa o absoluta.
Pero nada.

El caso es imprimir una parte de un documento (así lo hace el ejemplo), pero no funciona en el servidor.

En fin digo "una parte del documento" por decirlo pero en realidad es un documento al cual le hago un include que luego para imprimirlo solo he de cargar el documento.
__________________
Soporte y Creaciones PHP-Nuke:
NukeProjects.Net

if($Necesitas=="Ayuda"){
echo "No dudes en pedirla";
}
  #4 (permalink)  
Antiguo 10/03/2004, 07:43
Ex Colaborador
 
Fecha de Ingreso: junio-2002
Mensajes: 9.091
Antigüedad: 21 años, 10 meses
Puntos: 16
Hola,

¿Que valor tiene la directiva alow_url_fopen? Porque si esta a off no puede usar url absolutas con fopen(). Y si no usas url absolutas con fopen() no puedes obtener el HTML generado por un script. Porque si le pasas una url relativa intentara abrir un fichero que se llame literalmente pagina.php?a=4 en el directorio.

Saludos.
__________________
Josemi

Aprendiz de mucho, maestro de poco.
  #5 (permalink)  
Antiguo 10/03/2004, 08:20
 
Fecha de Ingreso: noviembre-2003
Mensajes: 114
Antigüedad: 20 años, 5 meses
Puntos: 0
Dije que uso el ejemplo de las FAQ'S, pero si aparece algo mejor pues que venga.

Código PHP:
<?php 

/*PHPrint - This file is phprint.php
Make any Page Printer Friendly! Version 2.0 - With error handling
Copyright by MikeNew.Net, Notice must stay intact
Any improvements to this script are welcome: <a href="/out.php?http%3A%2F%2Fwww.mikenew.net%2Fcontact.asp" target="_blank">[url]www.mikenew.net/contact.asp[/url]</a> 
************
Legal: MikeNew.Net is not responsible for any damages caused
by use of this script. (Not likely that it will. Hasn't yet.)
This script will make your pages printer friendly. 
Optionally, it will strip images as well. (Instructions for that below)

// After installation, you can remove text from here down to the next: 8< ---->
// Back up/copy this file first.

1. Save this script in the root of the site for simplicity.
2. Place <!-- startprint --> somewhere in your HTML page where you consider 
it to be the start of printer friendly content, and <!-- stopprint --> 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: <a href="/phprint.php">Print this page</a>
- 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.yoursite.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 "<!-- startprint -->";
$endingpoint "<!-- stopprint -->";
// 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("<br /><font face=\"Verdana\">Sorry! There is no access to this file directly. You must follow a link. <br /><br />Please click your browser's back button. </font><br><br><a href=\"http://miracle2.net/\"><img src=\"http://miracle2.net/i.gif\" alt=\"miracle 2\" border=\"0\"></a>");
// let's turn errors back on so we can debug if necessary
error_reporting(1);

$value "";
while(!
feof($read)){
$value .= fread($read10000); // reduce number to save server load
}
fclose($read);
$startstrpos($value"$startingpoint"); 
$finishstrpos($value"$endingpoint"); 
$length$finish-$start;
$value=substr($value$start$length);

function 
i_denude($variable) {
return(
eregi_replace("<img src=[^>]*>"""$variable));
}
function 
i_denudef($variable) {
return(
eregi_replace("<font[^>]*>"""$variable));
}

$PHPrint = ("$value");
if (
$stripImages == "yes") {
$PHPrint i_denude("$PHPrint");
}

$PHPrint i_denudef("$PHPrint");
$PHPrint str_replace"</font>"""$PHPrint );
$PHPrint stripslashes("$PHPrint"); 

echo 
"<base href=\"$baseURL\">";

echo 
$PHPrint
// Next line is invisible except to SE crawlers, please don't remove. Thanks! :)
echo "<br><a href=\"http://miracle2.net/\"><img src=\"http://miracle2.net/i.gif\" ";
echo 
"alt=\"miracle 2\" border=\"0\"></a>";
echo 
"<br/><br/>This page printed from: $HTTP_REFERER";
flush (); 
?>
El asunto es que hago un include de una pagina html

<!-- startprint -->
include('carpeta/pagina.tal');
<!-- stopprint -->

en windows la lee muy bien la url, pero en el servido no.
__________________
Soporte y Creaciones PHP-Nuke:
NukeProjects.Net

if($Necesitas=="Ayuda"){
echo "No dudes en pedirla";
}
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:16.