SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Checking all files

    Hey,

    OK, this is what I want. I want to check every file on my DocumentRoot, including files nested in directories, for a certain variable to define that it should be a part of a menu and which menu it is to be a part of. I could do it no worries if it was in one directory and I could probably even figure it out now but I'm hoping there is an easier way than a whole lot of dynamic calls to dir()

    Any ideas?

    Thanks

  2. #2
    As the name suggests... trickie's Avatar
    Join Date
    Jul 2002
    Location
    Melbourne, Australia
    Posts
    678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What form is the variable?

    I can give you a simple recursive directory function, but what exactely do you want to do?

    Maybe i'm just dumb...

  3. #3
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by trickie
    Maybe i'm just dumb...
    Nar, I'm shocking at explaining.

    Say this is my directory layout
    Code:
    D:\www\root\
    -D:\www\root\db\
    -D:\www\root\phpMyAdmin\
    --D:\www\root\phpMyAdmin\CVS\
    --D:\www\root\phpMyAdmin\lang\
    -D:\www\root\images\
    -D:\www\root\objects\
    -D:\www\root\forum\
    --D:\www\root\forum\admin\
    --D:\www\root\forum\contrib
    -D:\www\root\errors\
    -D:\www\root\CSS\
    -D:\www\root\admin\
    --D:\www\root\admin\auth
    I want to browse all of those directories and whatever subdirectories there might be so I can scan each file (I will probably find a more efficient way of doing this [maybe md5()]) to determine if it should include a link in a menu system I'm creating for a site.

    That easier to understand?

  4. #4
    As the name suggests... trickie's Avatar
    Join Date
    Jul 2002
    Location
    Melbourne, Australia
    Posts
    678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    something like this...

    PHP Code:
    <?php
    function scan_dir($path, &$menuItemList)
    {
        if (
    $handle opendir($path)) 
        {
            while (
    false !== ($filename readdir($handle))) 
            {
                if (
    $filename!="." && $filename!=".." )
                {
                    if (
    is_file($path.'/'.$filename))
                    {
                        
    //scan file - probably a function
                        //add to $menuItemList if needed
                    
    }
                    if (
    is_dir($path.'/'.$filename))
                    {
                        
    scan_dir($path.'/'.$filename$menuItemList);
                    }
                    
                }
            }
        
            
    closedir($handle); 
        }
    }
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •