diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-07-05 15:36:45 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-07-05 15:36:45 +0000 |
commit | a095a02e45d81e159c491cf93d8666ece8450347 (patch) | |
tree | 182f8047ecb125047055023d407d7ca090caefb5 | |
parent | 17ab54d284c6d82f96a5543fa5b5f8ee65e20307 (diff) | |
download | ampache-a095a02e45d81e159c491cf93d8666ece8450347.tar.gz ampache-a095a02e45d81e159c491cf93d8666ece8450347.tar.bz2 ampache-a095a02e45d81e159c491cf93d8666ece8450347.zip |
updated to the newest versino of getid3
-rwxr-xr-x | docs/CHANGELOG | 1 | ||||
-rw-r--r-- | modules/id3/getid3/getid3.lib.php | 26 | ||||
-rw-r--r-- | modules/id3/getid3/getid3.php | 2 | ||||
-rw-r--r-- | modules/id3/getid3/module.archive.gzip.php | 117 | ||||
-rw-r--r-- | modules/id3/getid3/module.archive.tar.php | 68 | ||||
-rw-r--r-- | modules/id3/getid3/module.audio-video.quicktime.php | 8 | ||||
-rw-r--r-- | modules/id3/getid3/module.audio-video.riff.php | 12 | ||||
-rw-r--r-- | modules/id3/getid3/module.audio.mpc.php | 2 | ||||
-rw-r--r-- | modules/id3/getid3/write.id3v2.php | 1 | ||||
-rw-r--r-- | modules/id3/getid3/write.php | 3 |
10 files changed, 149 insertions, 91 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 67a19191..4c02abef 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -15,6 +15,7 @@ - Added Improved MPD interface (Thx Sigger) - Updated XMLRPC lib to 1.1.1 due to security issues with previous versions + - Updated Getid3() library to 1.7.4 -------------------------------------------------------------------------- v.3.3.1 06/21/2005: diff --git a/modules/id3/getid3/getid3.lib.php b/modules/id3/getid3/getid3.lib.php index be7b113f..26c474db 100644 --- a/modules/id3/getid3/getid3.lib.php +++ b/modules/id3/getid3/getid3.lib.php @@ -513,7 +513,7 @@ class getid3_lib // $foo = array('path'=>array('to'=>'array('my'=>array('file.txt')))); // or // $foo['path']['to']['my'] = 'file.txt'; - while ($ArrayPath{0} == $Separator) { + while ($ArrayPath && ($ArrayPath{0} == $Separator)) { $ArrayPath = substr($ArrayPath, 1); } if (($pos = strpos($ArrayPath, $Separator)) !== false) { @@ -789,25 +789,25 @@ class getid3_lib $offset = 0; $stringlength = strlen($string); while ($offset < $stringlength) { - if ((ord($string{$offset}) & 0x07) == 0xF7) { + if ((ord($string{$offset}) | 0x07) == 0xF7) { // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) & ((ord($string{($offset + 1)}) & 0x3F) << 12) & ((ord($string{($offset + 2)}) & 0x3F) << 6) & (ord($string{($offset + 3)}) & 0x3F); $offset += 4; - } elseif ((ord($string{$offset}) & 0x0F) == 0xEF) { + } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) { // 1110bbbb 10bbbbbb 10bbbbbb $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) & ((ord($string{($offset + 1)}) & 0x3F) << 6) & (ord($string{($offset + 2)}) & 0x3F); $offset += 3; - } elseif ((ord($string{$offset}) & 0x1F) == 0xDF) { + } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) { // 110bbbbb 10bbbbbb $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) & (ord($string{($offset + 1)}) & 0x3F); $offset += 2; - } elseif ((ord($string{$offset}) & 0x7F) == 0x7F) { + } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) { // 0bbbbbbb $charval = ord($string{$offset}); $offset += 1; @@ -832,25 +832,25 @@ class getid3_lib $offset = 0; $stringlength = strlen($string); while ($offset < $stringlength) { - if ((ord($string{$offset}) & 0x07) == 0xF7) { + if ((ord($string{$offset}) | 0x07) == 0xF7) { // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) & ((ord($string{($offset + 1)}) & 0x3F) << 12) & ((ord($string{($offset + 2)}) & 0x3F) << 6) & (ord($string{($offset + 3)}) & 0x3F); $offset += 4; - } elseif ((ord($string{$offset}) & 0x0F) == 0xEF) { + } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) { // 1110bbbb 10bbbbbb 10bbbbbb $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) & ((ord($string{($offset + 1)}) & 0x3F) << 6) & (ord($string{($offset + 2)}) & 0x3F); $offset += 3; - } elseif ((ord($string{$offset}) & 0x1F) == 0xDF) { + } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) { // 110bbbbb 10bbbbbb $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) & (ord($string{($offset + 1)}) & 0x3F); $offset += 2; - } elseif ((ord($string{$offset}) & 0x7F) == 0x7F) { + } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) { // 0bbbbbbb $charval = ord($string{$offset}); $offset += 1; @@ -875,25 +875,25 @@ class getid3_lib $offset = 0; $stringlength = strlen($string); while ($offset < $stringlength) { - if ((ord($string{$offset}) & 0x07) == 0xF7) { + if ((ord($string{$offset}) | 0x07) == 0xF7) { // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) & ((ord($string{($offset + 1)}) & 0x3F) << 12) & ((ord($string{($offset + 2)}) & 0x3F) << 6) & (ord($string{($offset + 3)}) & 0x3F); $offset += 4; - } elseif ((ord($string{$offset}) & 0x0F) == 0xEF) { + } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) { // 1110bbbb 10bbbbbb 10bbbbbb $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) & ((ord($string{($offset + 1)}) & 0x3F) << 6) & (ord($string{($offset + 2)}) & 0x3F); $offset += 3; - } elseif ((ord($string{$offset}) & 0x1F) == 0xDF) { + } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) { // 110bbbbb 10bbbbbb $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) & (ord($string{($offset + 1)}) & 0x3F); $offset += 2; - } elseif ((ord($string{$offset}) & 0x7F) == 0x7F) { + } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) { // 0bbbbbbb $charval = ord($string{$offset}); $offset += 1; diff --git a/modules/id3/getid3/getid3.php b/modules/id3/getid3/getid3.php index 2cbd5002..e87fcfb6 100644 --- a/modules/id3/getid3/getid3.php +++ b/modules/id3/getid3/getid3.php @@ -10,7 +10,7 @@ ///////////////////////////////////////////////////////////////// // Defines -define('GETID3_VERSION', '1.7.3'); +define('GETID3_VERSION', '1.7.4'); define('GETID3_FREAD_BUFFER_SIZE', 16384); // read buffer size in bytes diff --git a/modules/id3/getid3/module.archive.gzip.php b/modules/id3/getid3/module.archive.gzip.php index db18c329..a494e4d0 100644 --- a/modules/id3/getid3/module.archive.gzip.php +++ b/modules/id3/getid3/module.archive.gzip.php @@ -8,7 +8,7 @@ ///////////////////////////////////////////////////////////////// // // // module.archive.gzip.php // -// written by Mike Mozolin <mmozolinØavk*ru> // +// written by Mike Mozolin <teddybearØmail*ru> // // module for analyzing GZIP files // // dependencies: NONE // // /// @@ -16,10 +16,12 @@ class getid3_gzip { + // public: Optional file list - disable for speed. + var $option_gzip_parse_contents = true; // decode gzipped files, if possible, and parse recursively (.tar.gz for example) + function getid3_gzip(&$fd, &$ThisFileInfo) { $ThisFileInfo['fileformat'] = 'gzip'; - $this->read_gzip($fd, $ThisFileInfo); - return false; + return $this->read_gzip($fd, $ThisFileInfo); } // Reads the gzip-file @@ -34,52 +36,57 @@ class getid3_gzip { $buffer = @fread($fd, $ThisFileInfo['filesize']); $arr_members = explode("\x1F\x8B\x08", $buffer); - $num_members = intval(count($arr_members)); - for ($i = 0; $i < $num_members; $i++) { - if (strlen($arr_members[$i]) == 0) { - continue; + while (true) { + $is_wrong_members = false; + $num_members = intval(count($arr_members)); + for ($i = 0; $i < $num_members; $i++) { + if (strlen($arr_members[$i]) == 0) { + continue; + } + $buf = "\x1F\x8B\x08".$arr_members[$i]; + + $attr = unpack($unpack_header, substr($buf, 0, $start_length)); + if (!$this->get_os_type(ord($attr['os']))) { + // Merge member with previous if wrong OS type + $arr_members[$i - 1] .= $buf; + $arr_members[$i] = ''; + $is_wrong_members = true; + continue; + } } - $thisThisFileInfo = &$ThisFileInfo['gzip']['member_header'][$i]; - - $buf = "\x1F\x8B\x08".$arr_members[$i]; - - $attr = unpack($unpack_header, substr($buf, 0, $start_length)); - if (!$this->get_os_type(ord($attr['os']))) { - // Split member with previous if wrong OS type - $arr_members[$i - 1] .= $buf; - $arr_members[$i] = ''; - continue; + if (!$is_wrong_members) { + break; } } $ThisFileInfo['gzip']['files'] = array(); $fpointer = 0; + $idx = 0; for ($i = 0; $i < $num_members; $i++) { - if (strlen($arr_members[$i]) == 0) { continue; } - $thisThisFileInfo = &$ThisFileInfo['gzip']['member_header'][$i]; + $thisThisFileInfo = &$ThisFileInfo['gzip']['member_header'][++$idx]; $buff = "\x1F\x8B\x08".$arr_members[$i]; $attr = unpack($unpack_header, substr($buff, 0, $start_length)); - //$id1 = ord($attr['id1']); - //$id2 = ord($attr['id2']); - $cmethod = ord($attr['cmethod']); - $thisThisFileInfo['raw']['flags'] = ord($attr['flags']); + $thisThisFileInfo['filemtime'] = getid3_lib::LittleEndian2Int($attr['mtime']); + $thisThisFileInfo['raw']['id1'] = ord($attr['cmethod']); + $thisThisFileInfo['raw']['id2'] = ord($attr['cmethod']); + $thisThisFileInfo['raw']['cmethod'] = ord($attr['cmethod']); + $thisThisFileInfo['raw']['os'] = ord($attr['os']); + $thisThisFileInfo['raw']['xflags'] = ord($attr['xflags']); + $thisThisFileInfo['raw']['flags'] = ord($attr['flags']); + $thisThisFileInfo['flags']['crc16'] = (bool) ($thisThisFileInfo['raw']['flags'] & 0x02); $thisThisFileInfo['flags']['extra'] = (bool) ($thisThisFileInfo['raw']['flags'] & 0x04); $thisThisFileInfo['flags']['filename'] = (bool) ($thisThisFileInfo['raw']['flags'] & 0x08); $thisThisFileInfo['flags']['comment'] = (bool) ($thisThisFileInfo['raw']['flags'] & 0x10); - $thisThisFileInfo['raw']['xflag'] = ord($attr['xflags']); - $thisThisFileInfo['compression'] = $this->get_xflag_type($thisThisFileInfo['raw']['xflag']); - - $thisThisFileInfo['filemtime'] = getid3_lib::LittleEndian2Int($attr['mtime']); + $thisThisFileInfo['compression'] = $this->get_xflag_type($thisThisFileInfo['raw']['xflags']); - $thisThisFileInfo['raw']['os'] = ord($attr['os']); $thisThisFileInfo['os'] = $this->get_os_type($thisThisFileInfo['raw']['os']); if (!$thisThisFileInfo['os']) { $ThisFileInfo['error'][] = 'Read error on gzip file'; @@ -96,6 +103,7 @@ class getid3_gzip { $w_xlen = substr($buff, $fpointer, 2); $xlen = getid3_lib::LittleEndian2Int($w_xlen); $fpointer += 2; + $thisThisFileInfo['raw']['xfield'] = substr($buff, $fpointer, $xlen); // Extra SubFields //+---+---+---+---+==================================+ @@ -106,10 +114,8 @@ class getid3_gzip { if ($idx >= $xlen) { break; } - $si1 = ord(substr($buff, $fpointer+$idx, 1)); - $idx++; - $si2 = ord(substr($buff, $fpointer+$idx, 1)); - $idx++; + $si1 = ord(substr($buff, $fpointer + $idx++, 1)); + $si2 = ord(substr($buff, $fpointer + $idx++, 1)); if (($si1 == 0x41) && ($si2 == 0x70)) { $w_xsublen = substr($buff, $fpointer+$idx, 2); $xsublen = getid3_lib::LittleEndian2Int($w_xsublen); @@ -126,9 +132,10 @@ class getid3_gzip { //+=========================================+ //|...original file name, zero-terminated...| //+=========================================+ - $thisThisFileInfo['filename'] = ''; + // GZIP files may have only one file, with no filename, so assume original filename is current filename without .gz + $thisThisFileInfo['filename'] = eregi_replace('.gz$', '', $ThisFileInfo['filename']); if ($thisThisFileInfo['flags']['filename']) { - while(true) { + while (true) { if (ord($buff[$fpointer]) == 0) { $fpointer++; break; @@ -142,7 +149,7 @@ class getid3_gzip { //|...file comment, zero-terminated...| //+===================================+ if ($thisThisFileInfo['flags']['comment']) { - while(true) { + while (true) { if (ord($buff[$fpointer]) == 0) { $fpointer++; break; @@ -162,7 +169,7 @@ class getid3_gzip { } // bit 0 - FLG.FTEXT //if ($thisThisFileInfo['raw']['flags'] & 0x01) { - // echo 'FTEXT<br>'; + // Ignored... //} // bits 5, 6, 7 - reserved @@ -170,7 +177,45 @@ class getid3_gzip { $thisThisFileInfo['filesize'] = getid3_lib::LittleEndian2Int(substr($buff, strlen($buff) - 4)); $ThisFileInfo['gzip']['files'] = getid3_lib::array_merge_clobber($ThisFileInfo['gzip']['files'], getid3_lib::CreateDeepArray($thisThisFileInfo['filename'], '/', $thisThisFileInfo['filesize'])); + + if ($this->option_gzip_parse_contents) { + // Try to inflate GZip + $csize = 0; + $inflated = ''; + $chkcrc32 = ''; + if (function_exists('gzinflate')) { + $cdata = substr($buff, $fpointer); + $cdata = substr($cdata, 0, strlen($cdata) - 8); + $csize = strlen($cdata); + $inflated = gzinflate($cdata); + + // Calculate CRC32 for inflated content + $thisThisFileInfo['crc32_valid'] = (bool) (sprintf('%u', crc32($inflated)) == $thisThisFileInfo['crc32']); + + // determine format + $formattest = substr($inflated, 0, 32774); + $newgetID3 = new getID3(); + $determined_format = $newgetID3->GetFileFormat($formattest); + unset($newgetID3); + + // file format is determined + switch (@$determined_format['module']) { + case 'tar': + // view TAR-file info + if (file_exists(GETID3_INCLUDEPATH.$determined_format['include']) && @include_once(GETID3_INCLUDEPATH.$determined_format['include'])) { + getid3_tar::read_tar($inflated, $ThisFileInfo['gzip']['member_header'][$idx]); + } + break; + + case '': + default: + // unknown or unhandled format + break; + } + } + } } + return true; } // Converts the OS type diff --git a/modules/id3/getid3/module.archive.tar.php b/modules/id3/getid3/module.archive.tar.php index 8ba31ed1..df2753f2 100644 --- a/modules/id3/getid3/module.archive.tar.php +++ b/modules/id3/getid3/module.archive.tar.php @@ -8,7 +8,7 @@ ///////////////////////////////////////////////////////////////// // // // module.archive.tar.php // -// written by Mike Mozolin <mmozolinØavk*ru> // +// written by Mike Mozolin <teddybearØmail*ru> // // module for analyzing TAR files // // dependencies: NONE // // /// @@ -18,12 +18,14 @@ class getid3_tar { function getid3_tar(&$fd, &$ThisFileInfo) { $ThisFileInfo['fileformat'] = 'tar'; - $this->read_tar($fd, $ThisFileInfo); - return false; + + @fseek($fd, 0); + $filebuffer = @fread($fd, $ThisFileInfo['filesize']); + return $this->read_tar($filebuffer, $ThisFileInfo); } // Reads the tar-file - function read_tar($fd, &$ThisFileInfo) { + function read_tar(&$filebuffer, &$ThisFileInfo) { $header_length = 512; $unpack_header = 'a100fname/a8mode/a8uid/a8gid/a12size/a12mtime/a8chksum/a1typflag/a100lnkname/a6magic/a2ver/a32uname/a32gname/a8devmaj/a8devmin/a155/prefix'; @@ -32,9 +34,9 @@ class getid3_tar { $ThisFileInfo['tar']['files'] = array(); - @fseek($fd, 0); - while (!@feof($fd)) { - $buffer = @fread($fd, $header_length); + while(strlen($filebuffer) != 0) { + $buffer = substr($filebuffer, 0, $header_length); + $filebuffer = substr($filebuffer, strlen($buffer)); // check the block $checksum = 0; for ($i = 0; $i < 148; $i++) { @@ -47,21 +49,21 @@ class getid3_tar { $checksum += ord(substr($buffer, $i, 1)); } $attr = unpack($unpack_header, $buffer); - $name = trim($attr['fname']); - $mode = octdec(trim($attr['mode'])); - $uid = octdec(trim($attr['uid'])); - $gid = octdec(trim($attr['gid'])); - $size = octdec(trim($attr['size'])); - $mtime = octdec(trim($attr['mtime'])); - $chksum = octdec(trim($attr['chksum'])); - $typflag = trim($attr['typflag']); - $lnkname = trim($attr['lnkname']); - $magic = trim($attr['magic']); - $ver = trim($attr['ver']); - $uname = trim($attr['uname']); - $gname = trim($attr['gname']); - $devmaj = octdec(trim($attr['devmaj'])); - $devmin = octdec(trim($attr['devmin'])); + $name = trim(@$attr['fname']); + $mode = octdec(trim(@$attr['mode'])); + $uid = octdec(trim(@$attr['uid'])); + $gid = octdec(trim(@$attr['gid'])); + $size = octdec(trim(@$attr['size'])); + $mtime = octdec(trim(@$attr['mtime'])); + $chksum = octdec(trim(@$attr['chksum'])); + $typflag = trim(@$attr['typflag']); + $lnkname = trim(@$attr['lnkname']); + $magic = trim(@$attr['magic']); + $ver = trim(@$attr['ver']); + $uname = trim(@$attr['uname']); + $gname = trim(@$attr['gname']); + $devmaj = octdec(trim(@$attr['devmaj'])); + $devmin = octdec(trim(@$attr['devmin'])); $prefix = trim(@$attr['prefix']); // EOF Found if (($checksum == 256) && ($chksum == 0)) { @@ -78,16 +80,17 @@ class getid3_tar { break; } // Read the next chunk - $data = @fread( $fd, $size ); + $data = substr($filebuffer, 0, $size); + $filebuffer = substr($filebuffer, strlen($data)); if (strlen($data) != $size) { - @fclose($fd); - $ThisFileInfo['error'][] = 'Read error on TAR file'; + $ThisFileInfo['error'][] = 'Read error on tar file'; return false; } $diff = $size % 512; if ($diff != 0) { // Padding, throw away - @fread($fd, (512 - $diff)); + $buff = substr($filebuffer, 0, (512 - $diff)); + $filebuffer = substr($filebuffer, strlen($buff)); } // Protect against tar-files with garbage at the end if ($name == '') { @@ -96,13 +99,13 @@ class getid3_tar { $ThisFileInfo['tar']['file_details'][$name] = array ( 'name' => $name, 'mode_raw' => $mode, - 'mode' => $this->display_perms($mode), + 'mode' => getid3_tar::display_perms($mode), 'uid' => $uid, 'gid' => $gid, 'size' => $size, 'mtime' => $mtime, 'chksum' => $chksum, - 'typeflag' => $this->get_flag_type($typflag), + 'typeflag' => getid3_tar::get_flag_type($typflag), 'linkname' => $lnkname, 'magic' => $magic, 'version' => $ver, @@ -114,7 +117,6 @@ class getid3_tar { $ThisFileInfo['tar']['files'] = getid3_lib::array_merge_clobber($ThisFileInfo['tar']['files'], getid3_lib::CreateDeepArray($ThisFileInfo['tar']['file_details'][$name]['name'], '/', $size)); } return true; - } // Parses the file mode to file permissions @@ -145,10 +147,10 @@ class getid3_tar { if ($mode & 0x400) $group['execute'] = ($group['execute'] == 'x') ? 's' : 'S'; if ($mode & 0x200) $world['execute'] = ($world['execute'] == 'x') ? 't' : 'T'; - $s = sprintf("%1s", $type); - $s .= sprintf("%1s%1s%1s", $owner['read'], $owner['write'], $owner['execute']); - $s .= sprintf("%1s%1s%1s", $group['read'], $group['write'], $group['execute']); - $s .= sprintf("%1s%1s%1s\n", $world['read'], $world['write'], $world['execute']); + $s = sprintf('%1s', $type); + $s .= sprintf('%1s%1s%1s', $owner['read'], $owner['write'], $owner['execute']); + $s .= sprintf('%1s%1s%1s', $group['read'], $group['write'], $group['execute']); + $s .= sprintf('%1s%1s%1s'."\n", $world['read'], $world['write'], $world['execute']); return $s; } diff --git a/modules/id3/getid3/module.audio-video.quicktime.php b/modules/id3/getid3/module.audio-video.quicktime.php index 3b93d81a..9be09011 100644 --- a/modules/id3/getid3/module.audio-video.quicktime.php +++ b/modules/id3/getid3/module.audio-video.quicktime.php @@ -21,6 +21,7 @@ class getid3_quicktime function getid3_quicktime(&$fd, &$ThisFileInfo, $ReturnAtomData=true, $ParseAllPossibleAtoms=false) { $ThisFileInfo['fileformat'] = 'quicktime'; + $ThisFileInfo['quicktime']['hinting'] = false; fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET); @@ -927,6 +928,13 @@ class getid3_quicktime $atomstructure['pano'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 4)); break; + case 'hint': // HINT track + case 'hinf': // + case 'hinv': // + case 'hnti': // + $ThisFileInfo['quicktime']['hinting'] = true; + break; + case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR) for ($i = 0; $i < ($atomstructure['size'] - 8); $i += 4) { $atomstructure['imgt'][] = getid3_lib::BigEndian2Int(substr($atomdata, $i, 4)); diff --git a/modules/id3/getid3/module.audio-video.riff.php b/modules/id3/getid3/module.audio-video.riff.php index 30db6db9..ebe3ee77 100644 --- a/modules/id3/getid3/module.audio-video.riff.php +++ b/modules/id3/getid3/module.audio-video.riff.php @@ -111,8 +111,8 @@ class getid3_riff $ThisFileInfo['playtime_seconds'] = (float) ((($thisfile_avdataend - $thisfile_avdataoffset) * 8) / $thisfile_audio['bitrate']); + $thisfile_audio['lossless'] = false; if (isset($thisfile_riff_WAVE['data'][0]['offset']) && isset($thisfile_riff_raw['fmt ']['wFormatTag'])) { - $thisfile_audio['lossless'] = false; switch ($thisfile_riff_raw['fmt ']['wFormatTag']) { case 0x0001: // PCM @@ -1064,16 +1064,16 @@ class getid3_riff $maxoffset = min($maxoffset, $ThisFileInfo['avdataend']); $RIFFchunk = false; - + fseek($fd, $startoffset, SEEK_SET); - + while (ftell($fd) < $maxoffset) { $chunkname = fread($fd, 4); if (strlen($chunkname) < 4) { $ThisFileInfo['error'][] = 'Expecting chunk name at offset '.(ftell($fd) - 4).' but found nothing. Aborting RIFF parsing.'; break; } - + $chunksize = getid3_riff::EitherEndian2Int($ThisFileInfo, fread($fd, 4)); if ($chunksize == 0) { $ThisFileInfo['error'][] = 'Chunk size at offset '.(ftell($fd) - 4).' is zero. Aborting RIFF parsing.'; @@ -1309,7 +1309,7 @@ class getid3_riff function ParseRIFFdata(&$RIFFdata, &$ThisFileInfo) { if ($RIFFdata) { - + $tempfile = tempnam('*', 'getID3'); $fp_temp = fopen($tempfile, "wb"); $RIFFdataLength = strlen($RIFFdata); @@ -1319,7 +1319,7 @@ class getid3_riff } fwrite($fp_temp, $RIFFdata); fclose($fp_temp); - + $fp_temp = fopen($tempfile, "rb"); $dummy = array('filesize'=>$RIFFdataLength, 'filenamepath'=>$ThisFileInfo['filenamepath'], 'tags'=>$ThisFileInfo['tags'], 'avdataoffset'=>0, 'avdataend'=>$RIFFdataLength, 'warning'=>$ThisFileInfo['warning'], 'error'=>$ThisFileInfo['error'], 'comments'=>$ThisFileInfo['comments'], 'audio'=>(isset($ThisFileInfo['audio']) ? $ThisFileInfo['audio'] : array()), 'video'=>(isset($ThisFileInfo['video']) ? $ThisFileInfo['video'] : array())); $riff = new getid3_riff($fp_temp, $dummy); diff --git a/modules/id3/getid3/module.audio.mpc.php b/modules/id3/getid3/module.audio.mpc.php index 7d5d33c5..d0a7202f 100644 --- a/modules/id3/getid3/module.audio.mpc.php +++ b/modules/id3/getid3/module.audio.mpc.php @@ -201,7 +201,7 @@ class getid3_mpc if ($thisfile_mpc_header['raw']['album_gain'] < 0) { $thisfile_mpc_header['album_gain_db'] = (float) (32768 + $thisfile_mpc_header['raw']['album_gain']) / -100; } else { - $thisfile_mpc_header['album_gain_db'] = (float) $thisfile_mpc_header['raw']['album_gain'] / 100; + $thisfile_mpc_header['album_gain_db'] = (float) $thisfile_mpc_header['raw']['album_gain'] / 100;; } $thisfile_mpc_header['encoder_version'] = $this->MPCencoderVersionLookup($thisfile_mpc_header['raw']['encoder_version']); diff --git a/modules/id3/getid3/write.id3v2.php b/modules/id3/getid3/write.id3v2.php index 4f15a722..a575f20b 100644 --- a/modules/id3/getid3/write.id3v2.php +++ b/modules/id3/getid3/write.id3v2.php @@ -49,6 +49,7 @@ class getid3_write_id3v2 $this->paddedlength = max(@$OldThisFileInfo['id3v2']['headerlength'], $this->paddedlength); if ($NewID3v2Tag = $this->GenerateID3v2Tag()) { + if (file_exists($this->filename) && is_writeable($this->filename) && isset($OldThisFileInfo['id3v2']['headerlength']) && ($OldThisFileInfo['id3v2']['headerlength'] == strlen($NewID3v2Tag))) { // best and fastest method - insert-overwrite existing tag (padded to length of old tag if neccesary) diff --git a/modules/id3/getid3/write.php b/modules/id3/getid3/write.php index 04c0226e..40a79e9e 100644 --- a/modules/id3/getid3/write.php +++ b/modules/id3/getid3/write.php @@ -280,7 +280,7 @@ class getid3_writetags case 'id3v2.3': case 'id3v2.4': $id3v2_writer = new getid3_write_id3v2; - $id3v2_writer->majorversion = (int) substr($tagformat, -1); + $id3v2_writer->majorversion = intval(substr($tagformat, -1)); $id3v2_writer->paddedlength = $this->id3v2_paddedlength; if (($id3v2_writer->tag_data = $this->FormatDataForID3v2($id3v2_writer->majorversion)) !== false) { $id3v2_writer->filename = $this->filename; @@ -514,6 +514,7 @@ class getid3_writetags // convert data from other encoding to UTF-16 $tag_data_id3v2[$ID3v2_framename][$key]['encodingid'] = 1; $tag_data_id3v2[$ID3v2_framename][$key]['data'] = getid3_lib::iconv_fallback($this->tag_encoding, 'UTF-16', $value); + } else { // convert data from other encoding to UTF-8 $tag_data_id3v2[$ID3v2_framename][$key]['encodingid'] = 3; |