Ho un file .php che legge il contenuto di una directory (si tratta di file .ogg):
Codice PHP:
<?
$d = dir("./brani");
while ($e = $d->read()) {
if($e!="." && $e!="..") {
// Questa riga sotto stampa il nome dell'album (della directory(
// echo "
<b class=\"titolo\">$e[/b]";
$subd = dir("./brani/$e");
while ($f = $subd->read()) {
if($f!="." && $f!="..")
// Stampa il percorso del file
echo "$e/$f
";
$percorso = "$e/$f";
include ("estrai_dati.php");
}
}
}
?>
Dopo che si prende le variabili (nome file e nome directory) includo il file estrai_dati.php per prendere i tag dai file .ogg
Ecco il file incluso:
Codice PHP:
<?
//function ogg_info($filename) {
$filename = $f;
$fp = fopen( $filename, "r" );
$info = array();
$info['size'] = filesize( $filename );
$info['name'] = basename( $filename );
$info['path'] = dirname( $filename );
$done = false;
while( $done == false ) {
$working = fread( $fp, 1 );
if( $working == "l" ) {
$working .= fread( $fp, 8 );
if( $working == "libVorbis" ) {
$done = true;
//echo ("sergio");
}
}
}
while( ord( $working ) > 31 ) {
$working = fread( $fp, 1 );
}
$tag = "";
while( $tag != "done" ) {
$working = "";
while( ( $working != "=" ) && ( $tag != "done" ) ) {
if( ord( $working ) > 31 ) {
$tag .= $working;
}
$working = fread( $fp, 1 );
if( $tag == "v" ) {
$tag .= "o".fread( $fp, 9 );
if( ( substr_count( $tag, "vorbis" ) == 1 ) && ( substr_count( $tag, "BCV" ) == 1 ) ) {
$tag = "done";
} else {
fseek( $fp, ( ftell( $fp ) - 10 ) );
}
}
}
if( $tag != "done" ) {
$working = fread( $fp, 1 );
while( ord( $working ) > 31 ) {
$title .= $working;
$working = fread( $fp, 1 );
}
$info[$tag] = $title;
$tag = "";
$title = "";
}
}
fclose( $fp );
//print_r($info);
return $info;
?>
Se "eseguo" il file il processore va al 100%, la pagina non si carica, insomma va in loop.
Perchè?
Se eseguo il file per estrarre i dati dandogli un file unico funziona...
Sergej