Simple Machines Community Forum

General Community => Scripting Help => Topic started by: Cadish on August 15, 2003, 03:23:32 AM

Title: Index folder on other server
Post by: Cadish on August 15, 2003, 03:23:32 AM
Hi,
I want to index a folder on another server. How can i do this?

(with indexing a folder, i mean get a list of all the files in that folder)

Thx
Title: Re:Index folder on other server
Post by: [Unknown] on August 15, 2003, 03:25:15 AM
There's no way really, without internet access.

One way is to just harvest links, and try to find all the links... but that doesn't work to well.

Of course, this is if you don't get a listing when you try to access the folder... but then, why would you be asking?

-[Unknown]
Title: Re:Index folder on other server
Post by: Cadish on August 15, 2003, 03:43:48 AM
Is it possible in cgi?
Title: Re:Index folder on other server
Post by: Chris Cromer on August 15, 2003, 04:27:38 AM
As [Unknown] said, why are you asking how to do it? Give us a ligit reason and you might be helped... otherwise it just sounds like your trying to hack someone.
Title: Re:Index folder on other server
Post by: Cadish on August 15, 2003, 04:51:36 AM
I have a php script (self-made) running on my server that allows users to view pictures more easily. I want to allow users to add their pictures too, but not on my server (because i don't have much space (50mb)).
I'm at a university (like all of my users), so each user has some space on a server of the university. So the users can upload their pictures on that server. If they give a link of the folder to me, i can index the folder to get all the pictures in it. And so display all of them with my script on my server.

One thing to do, is that they put a .txt file (with all the names of the pictures) in the folder, and that i use fopen and fread to get the names. But then the users have to make such a file, which is not very user-friendly ;)

So that's the reason i want to index some folders...

PS The university doesn't allow scripting, like php or cgi.
Title: Re:Index folder on other server
Post by: Chris Cromer on August 15, 2003, 05:00:20 AM
Well if the university's server is on the net, and your server has access to the internet, then you can use file(); or fopen(); to retreive the html, then parse the html to figure out what files are in the folder.

And just a note, fopen does not work for retreiving a url on windows servers in older versions of php. So it might be wiser to use file();

But I can't give you an exact script because different web servers return different indexes with different html. So you will have to base it on what is returned from file or fopen.
Title: Re:Index folder on other server
Post by: Cadish on August 15, 2003, 05:05:21 AM
What do you mean with 'the html'? Just the url of the folder? (like : http://www.university.com/user4531/images/ ?)

Is it possible to get the image size from the images too? Like: "img45.jpg: 400x300" ?

[edit]I've found a way to get the image size: getimagesize ( string filename [, array imageinfo])[/edit]
Title: Re:Index folder on other server
Post by: Chris Cromer on August 15, 2003, 07:44:45 AM
When you access the url you will get the output of either the server or the index file which is usualy html that contains that names of the files.

The list of files in the url is written in HTML, click view source to see the source... that's what file() will return, the source code of the page, which is html.
Title: Re:Index folder on other server
Post by: Cadish on August 15, 2003, 07:59:52 AM
ok, thanks a lot!!