Can't get remote files

What features would you like to see in future versions of getID3() ?
Post Reply
Sam

Can't get remote files

Post by Sam » Sun Jan 16, 2005 11:19 pm

In order to save me a lot of work, I looked for something like this and found it.
Unfortunately, this library can't get information from remote files.
This is actually the most important part.
I'm posting the below function to this form hoping that you would use it to extend the library to get information from remote files too.

function remote_file_exists ($url)
{
/*
Returning values:
TRUE = File Exists
1 = Invalid URL host
2 = Unable to connect to remote host

// example:
//$url = "http://www.google.it/intl/it_it/images/logo.gif";
$url = "http://motion4u.sytes.net/057movie04.rm";

if (remote_file_exists ($url))
{ print ($url . " file exists!"); }
else
{ print ($url . " file doesn't exist!"); }
*/

$head = "";
$url_p = parse_url ($url);

if (isset ($url_p["host"]))
{ $host = $url_p["host"]; }
else
{ return 1; }

if (isset ($url_p["path"]))
{ $path = $url_p["path"]; }
else
{ $path = ""; }

$fp = fsockopen ($host, 80, $errno, $errstr, 20);
if (!$fp)
{ return 2; }
else
{
$parse = parse_url($url);
$host = $parse['host'];

fputs($fp, "HEAD ".$url." HTTP/1.1\r\n");
fputs($fp, "HOST: ".$host."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
$headers = "";
while (!feof ($fp))
{ $headers .= fgets ($fp, 128); }
}
fclose ($fp);
$arr_headers = explode("\n", $headers);
$return = false;
if (isset ($arr_headers[0]))
{ $return = strpos ($arr_headers[0], "404") === false; }
return $return;
}

biosonik
User
Posts: 3
Joined: Fri Apr 29, 2005 5:33 am
Location: Scotland

Post by biosonik » Fri Apr 29, 2005 5:39 am

Remote fetching was took out of getID3 a while back.

There isn't any point putting it back in plus remote fetching functions/code is scattered all over this forum.

tony98
User
Posts: 23
Joined: Mon Feb 13, 2006 5:47 am

Post by tony98 » Fri Apr 28, 2006 12:08 pm

biosonik wrote:Remote fetching was took out of getID3 a while back.

There isn't any point putting it back in plus remote fetching functions/code is scattered all over this forum.
could u point me to a remote fetching functions i could not find one.Thanks

astemokoholic
User
Posts: 1
Joined: Mon May 22, 2006 8:58 am

Post by astemokoholic » Mon May 22, 2006 10:19 am

Totally agree with You :) Thumbs up

Post Reply