Back to DFS's Workshop Page
Back to Agenda Page
Navigating Directories Problem
This problem is part of the larger Creating a Picture Website project. It will allow navigation of a subdirectory tree so that the user can select a specific directory to work on.
For this problem, you are to cannibalize any available code and write a single script to navigate through the user's public_html directory tree.
Obviously, this will need to be a recursively called script. It will have to do the following.
- Using popen(), determine the path to the user's public_html directory; use a process call to pwd to access the information.
- Check the current directory path that was passed to the script; if it is empty(), set it to the full path to the user's public_html directory (e.g., /home/userid/public_html/).
- If the directory path was typed into the URL and is out-of-bounds, terminate the script.
- Determine the path of the current directory's parent directory.
- Create a form with a Select Box to allow the directory navigation.
- If the path to the user's public_html directory is the start of the parent directory, include an Option to it, showing ../ in the Select Box.
- Using popen(), get a listing of the current directory.
- If an item is a directory, show the name with a / appended to it and use the full path string as the value of the option.
- If the item is a file, show the name and use the full path to the current directory as the value of the option (just in case the user chooses a file name).
Notes
- Use explode() and concatenation to work with the directory paths.
- Use print_r() to check on values generated by explode().
© 2005 DFStermole
Created 30 Nov 05
Last Modified 9 Dec 05