Dirlisting & filemanaging

Dirlisting & filemanaging

am 08.01.2008 21:01:02 von frizzle

Hi there,

I'm buidling a php-app for online (ftp-based) file management. So far,
so good.
Now i've come to a point where i need to be able to copy / move
folders and files.
I have a function (below this post) that gives me an array of the
directory structure, luke the one below the message.

To jump to the problem:
I'd like to display the folders in a dropdown. What i'd like is to
have the following structure:
- scripts
- scripts / javascripts
- photos
- photos / black_white
- photos / black_white / sepia
- photos / illustrations
etc.

I'd like to convert the array below the message into the one above,
where each new line is a new array key.

After that, i need to be sure people don't move/copy folders to the
same folder in a higher level like copying "photos" to "photos /
black_white". How do i make sure current and all deeper levels are
disabled / removed from the list.

Thanks a lot!!



****** FUNCTION BELOW ******
function do_dirs($dir = '.', $loop = 0)
{

$handle = @opendir($dir);

while(($file=readdir($handle)) !== false ){

if($file != '.' && $file != '..'){

$point = $dir."/".$file;

if(is_dir($point)){
$info[$file] = do_dirs($point, $loop+1);
};
}
}
return $info;
}

print_r(do_dirs())


*** OUTPUT ***
Array
(
[scripts] => Array
(
[javascripts] =>
)
[images] => Array
(
[photos] => Array
(
[black_white] => Array
(
[sepia] =>
)
[color] =>
)
[illustrations] =>
[renderings] => Array
(
[3dmax] =>
)
)
)

Re: Dirlisting & filemanaging

am 09.01.2008 10:50:42 von Rob

On Jan 8, 8:01=A0pm, frizzle wrote:
> Hi there,
>
> I'm buidling a php-app for online (ftp-based) file management. So far,
> so good.
> Now i've come to a point where i need to be able to copy / move
> folders and files.
> I have a function (below this post) that gives me an array of the
> directory structure, luke the one below the message.
>
> To jump to the problem:
> I'd like to display the folders in a dropdown. What i'd like is to
> have the following structure:
> - scripts
> - scripts / javascripts
> - photos
> - photos / black_white
> - photos / black_white / sepia
> - photos / illustrations
> etc.
>
> I'd like to convert the array below the message into the one above,
> where each new line is a new array key.
>
> After that, i need to be sure people don't move/copy folders to the
> same folder in a higher level like copying "photos" to "photos /
> black_white". How do i make sure current and all deeper levels are
> disabled / removed from the list.
>
> Thanks a lot!!
>
> ****** FUNCTION BELOW ******
> function do_dirs($dir =3D '.', $loop =3D 0)
> {
>
> =A0 $handle =3D @opendir($dir);
>
> =A0 while(($file=3Dreaddir($handle)) !== false ){
>
> =A0 =A0 if($file !=3D '.' && $file !=3D '..'){
>
> =A0 =A0 =A0 $point =3D $dir."/".$file;
>
> =A0 =A0 =A0 =A0 =A0 =A0 if(is_dir($point)){
> =A0 =A0 =A0 =A0 =A0 =A0 $info[$file] =3D do_dirs($point, $loop+1);
> =A0 =A0 =A0 };
> =A0 =A0 =A0 =A0 }
> =A0 =A0 }
> =A0 return $info;
>
> }
>
> print_r(do_dirs())
>
> *** OUTPUT ***
> Array
> (
> =A0 [scripts] =3D> Array
> =A0 =A0 (
> =A0 =A0 =A0 [javascripts] =3D>
> =A0 =A0 )
> =A0 [images] =3D> Array
> =A0 =A0 (
> =A0 =A0 =A0 [photos] =3D> Array
> =A0 =A0 =A0 =A0 (
> =A0 =A0 =A0 =A0 =A0 [black_white] =3D> Array
> =A0 =A0 =A0 =A0 =A0 =A0 (
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 [sepia] =3D>
> =A0 =A0 =A0 =A0 =A0 =A0 )
> =A0 =A0 =A0 =A0 =A0 [color] =3D>
> =A0 =A0 =A0 =A0 )
> =A0 =A0 =A0 [illustrations] =3D>
> =A0 =A0 =A0 [renderings] =3D> Array
> =A0 =A0 =A0 =A0 (
> =A0 =A0 =A0 =A0 =A0 [3dmax] =3D>
> =A0 =A0 =A0 =A0 )
> =A0 =A0 )
> )

For this particular task, I would using this piece of software :-

http://extplorer.sourceforge.net/

I'm sure it will probably do everything you need, including FTP
connections.

Rob.

BTW, I have no affiliation with the author - it's just a good piece of
software

Re: Dirlisting & filemanaging

am 09.01.2008 11:40:43 von frizzle

On Jan 9, 10:50 am, Rob wrote:
> On Jan 8, 8:01 pm, frizzle wrote:
>
>
>
> > Hi there,
>
> > I'm buidling a php-app for online (ftp-based) file management. So far,
> > so good.
> > Now i've come to a point where i need to be able to copy / move
> > folders and files.
> > I have a function (below this post) that gives me an array of the
> > directory structure, luke the one below the message.
>
> > To jump to the problem:
> > I'd like to display the folders in a dropdown. What i'd like is to
> > have the following structure:
> > - scripts
> > - scripts / javascripts
> > - photos
> > - photos / black_white
> > - photos / black_white / sepia
> > - photos / illustrations
> > etc.
>
> > I'd like to convert the array below the message into the one above,
> > where each new line is a new array key.
>
> > After that, i need to be sure people don't move/copy folders to the
> > same folder in a higher level like copying "photos" to "photos /
> > black_white". How do i make sure current and all deeper levels are
> > disabled / removed from the list.
>
> > Thanks a lot!!
>
> > ****** FUNCTION BELOW ******
> > function do_dirs($dir = '.', $loop = 0)
> > {
>
> > $handle = @opendir($dir);
>
> > while(($file=readdir($handle)) !== false ){
>
> > if($file != '.' && $file != '..'){
>
> > $point = $dir."/".$file;
>
> > if(is_dir($point)){
> > $info[$file] = do_dirs($point, $loop+1);
> > };
> > }
> > }
> > return $info;
>
> > }
>
> > print_r(do_dirs())
>
> > *** OUTPUT ***
> > Array
> > (
> > [scripts] => Array
> > (
> > [javascripts] =>
> > )
> > [images] => Array
> > (
> > [photos] => Array
> > (
> > [black_white] => Array
> > (
> > [sepia] =>
> > )
> > [color] =>
> > )
> > [illustrations] =>
> > [renderings] => Array
> > (
> > [3dmax] =>
> > )
> > )
> > )
>
> For this particular task, I would using this piece of software :-
>
> http://extplorer.sourceforge.net/
>
> I'm sure it will probably do everything you need, including FTP
> connections.
>
> Rob.
>
> BTW, I have no affiliation with the author - it's just a good piece of
> software

Thanks Rob for your tip, but i'm actually starting on building quite
the same thing myself, as a part of a bigger CMS.
That's why i was looking for the aforementioned. Nevertheless, i'll
have a look at your option.

Regards, Frizzle.