Asheeown Posted February 6, 2007 Share Posted February 6, 2007 What I need to do is give the php script a url to a certain website "http://www.website.com" Then I need it to find the contents of that directory...can php do that? Quote Link to comment Share on other sites More sharing options...
Asheeown Posted February 7, 2007 Author Share Posted February 7, 2007 So thats a no to my question? Quote Link to comment Share on other sites More sharing options...
Unholy Prayer Posted February 7, 2007 Share Posted February 7, 2007 You mean like a custom page for a directory that has no index page? Quote Link to comment Share on other sites More sharing options...
Asheeown Posted February 7, 2007 Author Share Posted February 7, 2007 No...I'm on one server, the files I need are on another, another file gets imported to the directory I'm looking at every 15 minutes...I need a function that can get the contents of that directory Quote Link to comment Share on other sites More sharing options...
Hypnos Posted February 7, 2007 Share Posted February 7, 2007 Is there an index file in the directory? If so, how would it know what files to get? This would be a lot easier over FTP with a console FTP client and a shell script/batch file. Do you have FTP access to the directory? Quote Link to comment Share on other sites More sharing options...
Asheeown Posted February 7, 2007 Author Share Posted February 7, 2007 No FTP access thats why im doing it this way Quote Link to comment Share on other sites More sharing options...
Asheeown Posted February 7, 2007 Author Share Posted February 7, 2007 Function is given an external website directory e.g. (www.example.com/test/) and returns the files in that directory I'm looking for a function to do that Quote Link to comment Share on other sites More sharing options...
Asheeown Posted February 7, 2007 Author Share Posted February 7, 2007 Is this even possible? Quote Link to comment Share on other sites More sharing options...
Hypnos Posted February 7, 2007 Share Posted February 7, 2007 You didn't answer my first question. PHP fsock with HTTP isn't any more special than your web browser. If you go to the url and see a webpage, then PHP will see a webpage. If there isn't an index file and you can see all the files in your browser, then PHP will see that file list. If there is an index, then you can not do this. Not unless you know the file names ahead of time (or you scrape the page for file names). Quote Link to comment Share on other sites More sharing options...
Asheeown Posted February 7, 2007 Author Share Posted February 7, 2007 Okay, it doesn't have an index page, how can i scape the page Quote Link to comment Share on other sites More sharing options...
Hypnos Posted February 7, 2007 Share Posted February 7, 2007 The index page that apache/IIS generates is a HTML document. Scrape it just like one. <?php $page = file_get_contents("http://www.kodb.info/patches/"); $page = strip_tags($page); echo $page; You can explode that by newline, then run through it and remove the stuff you don't want (anything other than file names). Once you get it down to an array of file names, then you can start working on the downloading part. Quote Link to comment Share on other sites More sharing options...
Asheeown Posted February 7, 2007 Author Share Posted February 7, 2007 I have a lot of extra stuff in that variable that isn't needed such as the Index of and server info at the bottom. Anyway I can get rid of that? Quote Link to comment Share on other sites More sharing options...
Hypnos Posted February 7, 2007 Share Posted February 7, 2007 Use the string functions. This would be a start to my example page: <?php $page = file_get_contents("http://www.kodb.info/patches/"); $page = substr($page, strpos($page, "<HR>")); $page = substr($page, strpos($page, " - ") + 4); $page = substr($page, 0, strpos($page, "Apache/1.3.37 Server at www.kodb.info Port 80")); $page = strip_tags($page); $page = trim($page); echo $page; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.