Omnimaga

General Discussion => Technology and Development => Web Programming and Design => Topic started by: Sorunome on March 31, 2012, 05:07:15 am

Title: PHP opendir() of an external page
Post by: Sorunome on March 31, 2012, 05:07:15 am
Hey, I wanted to know if, and if how, it is possible to opendir() of an external page, e.g. http://www.google.com
Title: Re: PHP opendir() of an external page
Post by: cooliojazz on March 31, 2012, 08:45:52 am
No, it is not.
Title: Re: PHP opendir() of an external page
Post by: Netham45 on March 31, 2012, 11:30:53 am
You could use file_get_contents() to get the html of google, but you couldn't use opendir on it. Opendir only works on a locally-mounted filesystem.
Title: Re: PHP opendir() of an external page
Post by: Deep Toaster on March 31, 2012, 11:32:35 am
Nope. In fact, your PHP script can't tell at all if something on another server is a directory at all, any more than you (as a user) can (for example, is http://example.com/page1 a directory or a file?).

All you can know is the content that server returns to you. In some places, a site might return a plain-text listing of the directory's contents (such as http://eeems.omnimaga.org/files/), while in other places it might return 403 Forbidden, in order not to show you what's inside. And if there's a file called index.html or default.html or anything like that, of course, that's exactly what the server will show you when you try to open that directory.
Title: Re: PHP opendir() of an external page
Post by: Sorunome on March 31, 2012, 04:34:41 pm
Ah, ok, thanks for your help, it seems all-logical :)