Ver Mensaje Individual
  #4 (permalink)  
Antiguo 22/10/2013, 11:02
nksn
 
Fecha de Ingreso: mayo-2009
Ubicación: Japon
Mensajes: 60
Antigüedad: 14 años, 11 meses
Puntos: 12
Respuesta: Listar archivos de Sub directorios

simplemente leer los sub-direcctorios y cargarlos al xml, es exactamente lo que hace ese script

ya esta chequeado, ahora intenta remplazarlo

Código PHP:
<?php
function get_music_arr($directory$filter '.mp3')
{
    
$items = array();

    if(
$dir dir($directory))
    {
        while(
$entry $dir->read()) 
        {
            
$ps strpos(strtolower($entry), $filter); 
            if(
$ps !== false)
            {
                
$items[] = $entry;
            }

            if(
$entry != '.' && $entry != '..' && is_dir($directory.'/'.$entry))
            {
                
$items[$entry] = get_music_arr($directory.'/'.$entry);
            }
        }  
    }

    
$dir->close(); 


    return 
$items;
}

$items get_music_arr($_GET['music']); 

$anotation 0;

function 
print_data($data,  $path)
{
    global 
$anotation;

    foreach(
$data as $key => $value)
    {
        if(
is_array($value))
        {
            
print_data($value$path.'/'.$key);
        }
        else
        {
            
$anotation++;
            
            echo 
"        <track>\n"
            echo 
"            <annotation>".$anotation.". ".end(explode(".mp3"$value,-1))."</annotation>\n"
            echo 
"            <location>".$path.'/'.$value."</location>\n"
            echo 
"            <info></info>\n"
            echo 
"        </track>\n";
        }
    }


header("content-type:text/xml;charset=utf-8"); 

echo 
"<?xml version='1.0' encoding='UTF-8' ?>\n"
echo 
"<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n"
echo 
"    <title>Sample PHP Generated Playlist</title>\n"
echo 
"    <info>http://www.jeroenwijering.com/</info>\n"
echo 
"    <trackList>\n"

print_data($items$_GET['music']);

// .. and last we add the closing tags 
echo "    </trackList>\n"
echo 
"</playlist>\n";

Última edición por nksn; 22/10/2013 a las 11:16 Razón: correccion del codigo