Glad I did not, because its not quite resolved yet. Glob() works great, but my host runs PHP in "safe" mode.

Part of the reason I wanted to build a custom index page was so that I could list the directory name, and also list a short summary of all the files that are inside that directory next to the dirtectory name (basically the first 10 characters of the names, as a link to the file).

But with PHP in safe mode, index.php can't use glob() to look down into the sub-directories of the directory it resides in to find the file names- it can only get info about the single directory it resides in.

Is there an alternate method I could use for this task? FTP maybe? If so, how? Anybody have code for a function that will do the same task as glob() can do on arbitrary directory paths directories, but using a safe-mode friendly method?

    Does readdir work in safe mode? It seems odd that readdir would work when glob doesn't. In my case, its not that glob is disabled, I just get a path error whenever I try using it on any directory except the one the script is in. (Its perhaps possible I was using a bad path, and glob isn't at fault.) Guess I'll give the above function a shot and see if the results differ.

      Remember that glob() or readdir() expect relative or absolute filesystem paths, not web server document root paths, just in case that might be the problem. E.g.: if your web root directory is /home/username/public_html/, then to glob all files in your web root you would use glob('/home/username/public_html/'), not glob('/'). Or, to be more portable: glob($_SERVER['DOCUMENT_ROOT'].'/*').

        I'm using relative paths for jobs like that. For example, when I wanted to look at whats inside a sub-directory of the one my index.php program is sitting in, I tried to use glob('/subdirectoryNAME/*')

          But relative paths don't begin with a '/'. If you begin with a '/', you're specifying an absolute path.

            LOL. That may be my problem then...

              Okay... well, after removing the initial '/', let us know if that solves your problem. If it does, don't forget to mark this thread resolved.

                Removing the extra / did indeed make glob work. However, I still get the error message:

                Warning: glob() [function.glob]: open_basedir restriction in effect. File(/aquota.user) is not within the allowed path(s): (/home/sebwiers/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/sebwiers/public_html/iwrecords/TESTindex7-4E.php on line 95

                Warning: Invalid argument supplied for foreach() in /home/sebwiers/public_html/iwrecords/TESTindex7-4E.php on line 97

                Which is odd, because other than having those ugly error messages, the page works GREAT.
                BTW, line 95 is the one that makes the glob() call, and line 97 uses its result.

                  SWiers wrote:

                  File(/aquota.user)

                  Looks like there's still a leading forward slash in there somewhere.

                    I don't even know what file that is- its not one that I'm looking for or expecting to see, that's for sure. Like I said, all the ones I AM looking for, glob finds perfectly well, and lets me use the result too. I don't see how I could get rid of any slashes and have that still be the case, eh?

                    Here's a link to the page in question as hosted in my site, which might make it clearer what is happening.
                    http://www.urbandead.info/iwrecords/7-5%20A%20IN%20PROGRESS.php

                      Write a Reply...