Location: PHPKode > projects > Brunhilde Media Server > brunhilde/recurse.php
<?php

### recurse.php ###
// plays all songs in current directory, and all subdirectories recursively

include("global.php");
include("function.php");

$cdir = stripslashes($cdir);

// These lines are ESSENTIAL for the brunhilde server remain secure
// They keep a client from entering "../" to gain access to files
// outside of your web tree
if((substr_count($cdir, "../") > 0) || (substr_count($cdir, "..\\") > 0)) {
  include("security.php");
  }

$song_list = recurse_songs("$cdir");

// turns the song list into and m3u playlist file
header("Content-Type: audio/x-mpegurl");
header("Content-Disposition: filename=\"Brunhilde.m3u\"");

// adds each song to the playlist
for($i = 0; $i < sizeof($song_list); $i++) {
  $song_url = rawurlencode($song_list[$i]);
  if($i == sizeof($song_list) - 1) {
    if($PLAY_DIR == "") { echo "$SCRIPT_URL/play.php?play=$song_url&base=$base"; }
    else { echo "$DOMAIN$PLAY_DIR"."play.php?play=$song_url&base=$base"; }
    }
  else {
    if($PLAY_DIR == "") { echo "$SCRIPT_URL/play.php?play=$song_url&base=$base\n"; }
    else { echo "$DOMAIN$PLAY_DIR"."play.php?play=$song_url&base=$base\n"; }
    }
  }

exit;

?>
Return current item: Brunhilde Media Server