Witam napisałem sobie własną funkcję do wyciągania tagów ID3v2 z plików mp3, ale mam pewien problem z niektórymi plikami. Zdarza się że czasem źle odczytuje rozmiar tagu i bądź też ramki (głównie przy GEOB oraz APIC). Podczas robienia podpierałem się trochę istniejącymi skryptami a strukturę tagu mam ze strony
http://www.id3.org/. Poniżej przesyłam kod. Może gdzieś popełniłem błąd przy przetwarzaniu tagu. Mógłby ktoś na to spojrzeć

case 'APIC':
$id3frame['encoding']=coding_table
("coding",be2bin
(substr($framedata,0
,1
))); $nullpos=strpos($framedata,chr
(0
),1
); $id3frame['mime_type']=be2str
(substr($framedata,1
,$nullpos-1
)); $id3frame['mime_type']=@iconv(iconv_get_encoding($id3frame['mime_type']),"UTF-8",$id3frame['mime_type']);
$id3frame['picture_type']=select_from_file_table
(binhex
(be2bin
(substr($framedata,$nullpos+1,1))),"picture_type"); $terminator=coding_table
("terminator",be2bin
(substr($framedata,0
,1
))); $terpos=strpos($framedata,$terminator,$nullpos+2
); $id3frame['description']=be2str
(substr($framedata,$nullpos+2
,$terpos-$nullpos-2
)); $coding=be2bin
(substr($framedata,0
,1
)); if($coding==0x00)
{
$id3frame['description']=@iconv("ISO-8859-2","UTF-8",$id3frame['description']);
}
else
{
$id3frame['description']=@iconv($id3frame['encoding'],"UTF-8",$id3frame['description']);
}
$id3frame['picture_data']=substr($framedata,$terpos+strlen($terminator));
break;
case 'GEOB':
$id3frame['encoding']=coding_table
("coding",be2bin
(substr($framedata,0
,1
))); $nullpos=strpos($framedata,chr
(0
),1
); $id3frame['mime_type']=be2str
(substr($framedata,1
,$nullpos)); $id3frame['mime_type']=@iconv("ISO-8859-2","UTF-8",$id3frame['mime_type']);
$terminator=coding_table
("terminator",be2bin
(substr($framedata,0
,1
))); $terpos=strpos($framedata,$terminator,$nullpos+1
); $id3frame['filename']=be2str
(substr($framedata,$nullpos+1
,$terpos-$nullpos-1
)); $coding=be2bin
(substr($framedata,0
,1
)); if($coding==0x00)
{
$id3frame['filename']=@iconv("ISO-8859-2","UTF-8",$id3frame['filename']);
}
else
{
$id3frame['filename']=@iconv($id3frame['encoding'],"UTF-8",$id3frame['filename']);
}
$terpos2=strpos($framedata,$terminator,$terpos+strlen($terminator)); $id3frame['content_description']=be2str
(substr($framedata,$terpos+strlen($terminator),$terpos2-$terpos-strlen($terminator))); if($coding==0x00)
{
$id3frame['filename']=@iconv("ISO-8859-2","UTF-8",$id3frame['filename']);
}
else
{
$id3frame['filename']=@iconv($id3frame['encoding'],"UTF-8",$id3frame['filename']);
}
$id3frame['encapsuled_object']=substr($framedata,$terpos2+strlen($terminator)); break;