-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alvaro Zuniga wrote:

| Hi Everyone: A fried visited me today and we had a few drinks. He
| listened to some of my music and asked me if I could possibly
| display it online for him to download. After he left, I wrote this
| algorithm that is very short thanks to the power of recursion. I
| just wanted to shae it.
|
| For the computer scientists out there, yes I know about the
| recursion so show your alternative :-)


Why not use apaches internal directory indexing?
I do this,    

Alias /music/ "/var/space/public/mp3/"

~    <Directory "/var/space/public/mp3/">
~        AllowOverride None
~        Options Indexes IncludesNoExec
~        AddHandler type-map var
~        Order allow,deny
~        Allow from all
~    </Directory>


browseing http://www.me.com/music/
will give me a hyperlink'd list of everything in that directory unless
I add an index file.
It also recurses the directory tree Indexing.
Often I just softlink things here I want to give access to, apache
spews errors about links not being allowed but since it works and is
only temporary for me I ignore the errors.

|
| enjoy,
|
| Alvaro Zuniga
|
| <?php global $path; $path = ''; rec_index( $file ); function
| rec_index( $file ) { global $path; if( is_file( $file ) ) { $mp3 =
| explode( '.', $file ); if( $mp3[count( $mp3 ) - 1] == 'mp3' ) {
| echo '<a href="' . $path . $file . '">' . $file . '</a><br>'; } }
| elseif( ( is_dir( $file ) && $file != '.' && $file != '..' ) ||
| $file == '' ) { $path .= $file . '/'; if( $file ) chdir( $file );
| echo '<b>' . $file . '</b><br><blockquote>'; $handle = opendir( '.'
| ); while( ( $file = readdir( $handle ) ) !== false ) { rec_index(
| $file ); } chdir( '..' ); echo '</blockquote>'; } } ?>
|
|
| _______________________________________________ General mailing
| list [email protected]
| http://brlug.net/mailman/listinfo/general_brlug.net


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFAWcgu6JFKsKsJemQRAkEqAKCYQbbqJtOUqcOsQ/c1aCMk/3pLEACeLwQF
AMa2A2CGfFSK6pO7bT8aI+4=
=uKAO
-----END PGP SIGNATURE-----

Reply via email to