Date: 11/30/99
- Next message: Tim Zickus: "Re: [PHP3] PHP3 to check for correct URL"
- Previous message: Cruz, Miguel (OD/ORS): "RE: [PHP3] Writing to file - somebody other than nobody"
- Maybe in reply to: Derek from CD Baby: "[PHP3] PHP3 to check for correct URL"
- Next in thread: Tim Zickus: "Re: [PHP3] PHP3 to check for correct URL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
ahh well i did actually explore this long ago for A LONG time
here is a function using fsockopen it will see if the file exists on the
server given
it returns $status FALSE or TRUE
if TRUE then file exists
function get_headers($URL)
{
$URL2 = eregi_replace("http://","",$URL);
$splitURL = split("/",$URL2,2);
$host = $splitURL[0];
$path = $splitURL[1];
if((eregi("\.",$host)))
{
$gh = fsockopen ("$host", 80, &$errnr, &$errstr) or die("$errno: $errstr");
$hpath = "/".$path;
fputs($gh,"HEAD $hpath HTTP/1.0\n\n");
$line = fgets($gh, 15);
if(eregi("200 OK",$line))
{
$status=TRUE;
return $status;
}
else
{
$status=FALSE;
return $status;
}
}
}
-----Original Message-----
From: Derek from CD Baby <derek <email protected>>
To: php3 <email protected> <php3 <email protected>>
Date: Tuesday, November 30, 1999 12:45 PM
Subject: [PHP3] PHP3 to check for correct URL
>Is there a way to use PHP3 to check if a URL that someone's entering is
>correct?
>
>I don't mean the REGEX checking - I mean actually sending out a little
>"bot" - or trying to open the URL - and seeing if it returns a "1" or a "0" ?
>
>Also would this work for other types of files?
>
>We ask people to give us the exact URL to find their MP3 files on the
>web. I would love pHP3 to check to make sure that's a URL that actually
>goes to an MP3 file.
>
>Lemme know whatcha think!
>
>
>Thanks!
>
>Derek Sivers
>linuxbaby <email protected>
>
>
>--
>PHP 3 Mailing List <http://www.php.net/>
>To unsubscribe, send an empty message to php3-unsubscribe <email protected>
>To subscribe to the digest, e-mail: php3-digest-subscribe <email protected>
>To search the mailing list archive, go to: http://www.php.net/mailsearch.php3
>To contact the list administrators, e-mail: php-list-admin <email protected>
>
>
-- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to php3-unsubscribe <email protected> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Tim Zickus: "Re: [PHP3] PHP3 to check for correct URL"
- Previous message: Cruz, Miguel (OD/ORS): "RE: [PHP3] Writing to file - somebody other than nobody"
- Maybe in reply to: Derek from CD Baby: "[PHP3] PHP3 to check for correct URL"
- Next in thread: Tim Zickus: "Re: [PHP3] PHP3 to check for correct URL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

