Verificación de URL
| From: | Victor Ricardo Diaz | Date: | Fri, 25 Jan 2002 15:05:23 +0000 |
| Subject: | Verificación de URL | ||
| References: | 1 2 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-18419@lists.php.net to get a copy of this message | ||
Listeros yo estoy utilizando el sgte script para verificar si un URL existe.
El problema me surge cuando defino la variable
$path incorrectamente por ejemplo:
"/ads/click0796k5jfdzx.php?bannnnnnerID=119" la función sige retornado el
valor de TRUE diciendome que el URL existe cuando no es verdad porque yo
intencionalmente introduje un valor incorrecto del camino. Que ustedes creen
que puede ser?. Alquien tiene una forma mas segura de verificar URL con PHP.
<?php
# funcion http check
function http_fopen ($host, $path, $port = 80) {
#has the user set $proxy_host?
if (empty($this->proxy_host)) {
# we access the server directly
$conn_host = $host;
$conn_port = $port;
} else {
# we use the proxy
$conn_host = $this->proxy_host;
$conn_port = $this->proxy_port;
}
# build the absolute URL
$abs_url = "http://$host:$port$path";
# Now we build our query
$query = "GET $abs_url HTTP/1.0\r\n".
"Host: $host:$port\r\n".
"User-agent: PHP/class http 0.1\r\n".
"\r\n";
# Open a connection to the server
$fp = fsockopen($conn_host, $conn_port);
# if the connection failed, return false
if (!$fp)
return false;
# send our query
fputs($fp, $query);
# Discard the HTTP header
while(trim(fgets($fp, 1024)) != "");
# return the active files pointer
return $fp;
}
$host = "www.webestilo.com";
$path = "/ads/click.php?bannerID=119";
$fp = http_fopen ($host , $path);
if (!$fp) {
echo "URL no se pudo abrir";
} else {
echo "URL se pudo abrir";
}
?>
Saludos