#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Posts
    15
    Rep Power
    0
    does someone know how to
    get a sites dir-structure in an array?
    like:
    /pages
    /pages/images
    /pages/images/coffe
    /drugs
    /drugs/crack
    etc..
    it's to be used in a filemanagers
    copy-function =)
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Chicago
    Posts
    6
    Rep Power
    0
    I just wrote a small script to
    do exactly this. I used a exec()
    perl script. This may not be the
    most elequent of solutions, but it
    worked.

    begin psuedo-code (read i'm not
    typing the exact code in, but it's
    the best I can remember):

    BeginPHP
    function printDir($item) {
    print "D: ".$item;
    }

    $dirroot = "/home/web/html";
    $directory[];

    exec("perl ./directory.pl $dirroot", directory[]);

    array_walk($directory, 'printDir');
    EndPHP

    BeginPERL:
    use File::Find;
    $root = $ARGV[0];

    find(&wanted, $root);
    @findList = grep(/the file types you want/, @fileList);
    print @findList;

    sub wanted {
    push(@findList, "$File::Find::name"."n");
    }
    EndPERL

    Hope this helps...

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by kvack:
    does someone know how to
    get a sites dir-structure in an array?
    like:
    /pages
    /pages/images
    /pages/images/coffe
    /drugs
    /drugs/crack
    etc..
    it's to be used in a filemanagers
    copy-function =)
    [/quote]

  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Posts
    15
    Rep Power
    0
    Your way of doing it is even working in
    safe_mode ..hmm .. I'll use that if
    some evil guy changes php.ini

    i figured out how to use unix 'find':

    $path_org="/www/root/somedir/otherdir";

    exec("find "SDFslkj34Isdox" ".$path_org, $dirs);
    $d=dir(trim($dirs[0]));
    error_reporting(4);

    print "<select name=copydir>";
    $i=0;
    while(list($key,$val)=each($dirs)){

    if(chdir(trim($val))){
    print "<option value=".$val.">";
    $test=str_replace("$path_org","",$val);
    if($test==""){ print "/"; }
    else{
    print str_replace("$path_org","",$val);
    print "n";
    }
    }
    $i++;
    }
    error_reporting(2);

Similar Threads

  1. php directory structure problem
    By KhalidAli in forum PHP Development
    Replies: 2
    Last Post: January 1st, 2004, 10:22 AM
  2. question concerning the directory structure of apache server
    By tenaka in forum Apache Development
    Replies: 7
    Last Post: December 28th, 2003, 04:00 PM
  3. Backing up directory
    By purplegrum in forum Linux Help
    Replies: 5
    Last Post: December 18th, 2003, 03:57 AM
  4. Can't copy the next chunk of files into new directory?
    By Diyar in forum Perl Programming
    Replies: 1
    Last Post: September 22nd, 2003, 12:52 AM
  5. Replies: 0
    Last Post: September 18th, 2003, 06:42 PM

IMN logo majestic logo threadwatch logo seochat tools logo