By webservant on
I am migrating a website for a radio station. Don't let that fool you. Every day, the automation computer creates a log file(example: 070119.lst). The file is uploaded each 5 minutes so that it can be viewed to see what has played up to the last 5 minutes.
Is it possible to have a node or module that will list the contents of the directory containing these files and allow the display of the file contents? There is no need to update the databases with these files as they will be manually archived. Also, it would be preferable that the files not be allowed to be public so the solution needs to take that into consideration.
Anyone want to lend a hand?
Thanks a million.
Comments
It may be possible
It would be pretty staight forward to create a module (no need for a node) to do what you want including the ability to control who can see the files. The one possbible "gotcha" is can the directories and files be read from the web site. Not everyfile on a computer running a webserver is readable by the software (in this case Drupal) running under a webserver (and that is a good thing). Besides being readable, the directories will need to be "listable" from the web site, the exact meaning of "listable" being dependent on the operating system. If "DirectoryIterator" is available (it is new and does list a version, see: http://us2.php.net/manual/en/function.directoryiterator-construct.php) the task would be real straight forward. otherwise there is opendir and related functions (see: http://us2.php.net/manual/en/function.opendir.php)
...
You don't even need a module. Of the files go to a specific directory, then you can write a php script to read the contents of that directory and display it in a node. Choose php type content and parse it.
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide
. . .
Sepeck,
Thank you for your awesome idea. I am not a php programmer, so I'm asking if there is anyone out there that has developed just such a script. Maybe also I didn't make my question as clear as I could have.
Not only do I want to view the directory contents, I also want to be able to click on the file name and view the contents of the file right in the browser. Every file has the .lst extension and I know that it can be displayed as a text file.
So, Any code you can give me would be greatly helpful.
As I said, I'm not a php programmer, and neither am I a drupal specialist. However, I've spent a couple hours playing around with code, and here is what I came up with. This code lists the contents of the directory, but I don't know how to make it so I can then view the contents of the file that I click on.
Keep in mind that this perticular installation of drupal is private so the file path is not inside the drupal root.
Thanks again for your suggestions, they have been most helpful.
cntrytwist