Sheesh do I have to do everything for you? ;-) Just kidding, here're some thoughts that might help, but no actual code, you should be able to write that yourself.
Take substr()'s ( www.php.net/substr ) or the first character, the first 6 characters, and the first seven characters. There are pretty much four ( aight, theres more, but I'll leave those up to you to find ) cases here we'll deal with.
[url]http://[/url] ( first seven chars )
[url]ftp://[/url] ( first six chars )
/ ( first one character )
[ anything else ]
If stristr ("http://", $first_seven_chars) {
it's already absolute, dont do anythign with it
If stristr ("ftp://", $first_six_chars) {
its an ftp site
If stristr ("/", $first_one_character) {
this is a url which just needs the domain name appended to the beginning
Else
Append the current path up to the last / to it.
$domainame = "http://mydomainname.com/path/to/file.html";
$temp = strrev ($domainname);
while (stristr ("/", $temp) {
$temp = stristr ("/", $temp);
$temp = substr ($temp);
}
$path_that_file_is_in = $temp;
Also:
www.php.net/parse_url