[pLog-svn] r2322 - plog/branches/plog-1.0.2/class/gallery/getid3

oscar at devel.plogworld.net oscar at devel.plogworld.net
Thu Jul 14 14:16:42 GMT 2005


Author: oscar
Date: 2005-07-14 14:16:41 +0000 (Thu, 14 Jul 2005)
New Revision: 2322

Added:
   plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.gzip.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.tar.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.wavpack.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.tiff.php
Modified:
   plog/branches/plog-1.0.2/class/gallery/getid3/getid3.lib.php
   plog/branches/plog-1.0.2/class/gallery/getid3/getid3.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.rar.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.szip.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.zip.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.asf.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.bink.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.matroska.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.mpeg.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.nsv.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.quicktime.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.real.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.riff.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.swf.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.aac.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.ac3.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.au.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.avr.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.bonk.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.flac.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.la.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.lpac.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.midi.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.mod.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.monkey.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.mp3.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.mpc.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.ogg.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.optimfrog.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.rkau.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.shorten.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.tta.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.voc.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.vqf.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.bmp.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.gif.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.jpg.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.pcd.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.png.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.misc.exe.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.misc.iso.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.apetag.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.id3v1.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.id3v2.php
   plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.lyrics3.php
Log:
updated the getid3 library to version 1.7.4, perhaps it will help to fix
http://bugs.plogworld.net/view.php?id=613


Modified: plog/branches/plog-1.0.2/class/gallery/getid3/getid3.lib.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/getid3.lib.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/getid3.lib.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -53,9 +53,8 @@
 define('GETID3_JPG_SOF15',   "\xCF");
 define('GETID3_JPG_EOI',     "\xD9"); // End Of Image (end of datastream)
 
-/**
- * \ingroup getid3
- */
+
+
 class getid3_lib
 {
 
@@ -95,7 +94,7 @@
 		} else {
 			$truncatednumber = 0;
 		}
-		if ($truncatednumber <= pow(2, 30)) {
+		if ($truncatednumber <= 1073741824) { // 2^30
 			$truncatednumber = (int) $truncatednumber;
 		}
 		return $truncatednumber;
@@ -109,7 +108,7 @@
 		// convert a float to type int, only if possible
 		if (getid3_lib::trunc($floatnum) == $floatnum) {
 			// it's not floating point
-			if ($floatnum <= pow(2, 30)) {
+			if ($floatnum <= 1073741824) { // 2^30
 				// it's within int range
 				$floatnum = (int) $floatnum;
 			}
@@ -457,7 +456,7 @@
 			$contentseconds -= 60;
 			$contentminutes++;
 		}
-		return number_format($contentminutes).':'.str_pad($contentseconds, 2, 0, STR_PAD_LEFT);
+		return intval($contentminutes).':'.str_pad($contentseconds, 2, 0, STR_PAD_LEFT);
 	}
 
 
@@ -503,7 +502,7 @@
 
 	function FixedPoint2_30($rawdata) {
 		$binarystring = getid3_lib::BigEndian2Bin($rawdata);
-		return getid3_lib::Bin2Dec(substr($binarystring, 0, 2)) + (float) (getid3_lib::Bin2Dec(substr($binarystring, 2, 30)) / pow(2, 30));
+		return getid3_lib::Bin2Dec(substr($binarystring, 0, 2)) + (float) (getid3_lib::Bin2Dec(substr($binarystring, 2, 30)) / 1073741824);
 	}
 
 
@@ -514,13 +513,13 @@
 		//   $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) {
 			$ReturnedArray[substr($ArrayPath, 0, $pos)] = getid3_lib::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
 		} else {
-			$ReturnedArray["$ArrayPath"] = $Value;
+			$ReturnedArray[$ArrayPath] = $Value;
 		}
 		return $ReturnedArray;
 	}
@@ -711,21 +710,342 @@
 	}
 
 
+	function iconv_fallback_int_utf8($charval) {
+		if ($charval < 128) {
+			// 0bbbbbbb
+			$newcharstring = chr($charval);
+		} elseif ($charval < 2048) {
+			// 110bbbbb 10bbbbbb
+			$newcharstring  = chr(($charval >> 6) | 0xC0);
+			$newcharstring .= chr(($charval & 0x3F) | 0x80);
+		} elseif ($charval < 65536) {
+			// 1110bbbb 10bbbbbb 10bbbbbb
+			$newcharstring  = chr(($charval >> 12) | 0xE0);
+			$newcharstring .= chr(($charval >>  6) | 0xC0);
+			$newcharstring .= chr(($charval & 0x3F) | 0x80);
+		} else {
+			// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
+			$newcharstring  = chr(($charval >> 18) | 0xF0);
+			$newcharstring .= chr(($charval >> 12) | 0xC0);
+			$newcharstring .= chr(($charval >>  6) | 0xC0);
+			$newcharstring .= chr(($charval & 0x3F) | 0x80);
+		}
+		return $newcharstring;
+	}
+
+	// ISO-8859-1 => UTF-8
+	function iconv_fallback_iso88591_utf8($string, $bom=false) {
+		if (function_exists('utf8_encode')) {
+			return utf8_encode($string);
+		}
+		// utf8_encode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
+		$newcharstring = '';
+		if ($bom) {
+			$newcharstring .= "\xEF\xBB\xBF";
+		}
+		for ($i = 0; $i < strlen($string); $i++) {
+			$charval = ord($string{$i});
+			$newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
+		}
+		return $newcharstring;
+	}
+
+	// ISO-8859-1 => UTF-16BE
+	function iconv_fallback_iso88591_utf16be($string, $bom=false) {
+		$newcharstring = '';
+		if ($bom) {
+			$newcharstring .= "\xFE\xFF";
+		}
+		for ($i = 0; $i < strlen($string); $i++) {
+			$newcharstring .= "\x00".$string{$i};
+		}
+		return $newcharstring;
+	}
+
+	// ISO-8859-1 => UTF-16LE
+	function iconv_fallback_iso88591_utf16le($string, $bom=false) {
+		$newcharstring = '';
+		if ($bom) {
+			$newcharstring .= "\xFF\xFE";
+		}
+		for ($i = 0; $i < strlen($string); $i++) {
+			$newcharstring .= $string{$i}."\x00";
+		}
+		return $newcharstring;
+	}
+
+	// ISO-8859-1 => UTF-16LE (BOM)
+	function iconv_fallback_iso88591_utf16($string) {
+		return getid3_lib::iconv_fallback_iso88591_utf16le($string, true);
+	}
+
+	// UTF-8 => ISO-8859-1
+	function iconv_fallback_utf8_iso88591($string) {
+		if (function_exists('utf8_decode')) {
+			return utf8_decode($string);
+		}
+		// utf8_decode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
+		$newcharstring = '';
+		$offset = 0;
+		$stringlength = strlen($string);
+		while ($offset < $stringlength) {
+			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) {
+				// 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) {
+				// 110bbbbb 10bbbbbb
+				$charval = ((ord($string{($offset + 0)}) & 0x1F) <<  6) &
+				            (ord($string{($offset + 1)}) & 0x3F);
+				$offset += 2;
+			} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
+				// 0bbbbbbb
+				$charval = ord($string{$offset});
+				$offset += 1;
+			} else {
+				// error? throw some kind of warning here?
+				$charval = false;
+				$offset += 1;
+			}
+			if ($charval !== false) {
+				$newcharstring .= (($charval < 256) ? chr($charval) : '?');
+			}
+		}
+		return $newcharstring;
+	}
+
+	// UTF-8 => UTF-16BE
+	function iconv_fallback_utf8_utf16be($string, $bom=false) {
+		$newcharstring = '';
+		if ($bom) {
+			$newcharstring .= "\xFE\xFF";
+		}
+		$offset = 0;
+		$stringlength = strlen($string);
+		while ($offset < $stringlength) {
+			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) {
+				// 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) {
+				// 110bbbbb 10bbbbbb
+				$charval = ((ord($string{($offset + 0)}) & 0x1F) <<  6) &
+				            (ord($string{($offset + 1)}) & 0x3F);
+				$offset += 2;
+			} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
+				// 0bbbbbbb
+				$charval = ord($string{$offset});
+				$offset += 1;
+			} else {
+				// error? throw some kind of warning here?
+				$charval = false;
+				$offset += 1;
+			}
+			if ($charval !== false) {
+				$newcharstring .= (($charval < 65536) ? getid3_lib::BigEndian2String($charval, 2) : "\x00".'?');
+			}
+		}
+		return $newcharstring;
+	}
+
+	// UTF-8 => UTF-16LE
+	function iconv_fallback_utf8_utf16le($string, $bom=false) {
+		$newcharstring = '';
+		if ($bom) {
+			$newcharstring .= "\xFF\xFE";
+		}
+		$offset = 0;
+		$stringlength = strlen($string);
+		while ($offset < $stringlength) {
+			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) {
+				// 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) {
+				// 110bbbbb 10bbbbbb
+				$charval = ((ord($string{($offset + 0)}) & 0x1F) <<  6) &
+				            (ord($string{($offset + 1)}) & 0x3F);
+				$offset += 2;
+			} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
+				// 0bbbbbbb
+				$charval = ord($string{$offset});
+				$offset += 1;
+			} else {
+				// error? maybe throw some warning here?
+				$charval = false;
+				$offset += 1;
+			}
+			if ($charval !== false) {
+				$newcharstring .= (($charval < 65536) ? getid3_lib::LittleEndian2String($charval, 2) : '?'."\x00");
+			}
+		}
+		return $newcharstring;
+	}
+
+	// UTF-8 => UTF-16LE (BOM)
+	function iconv_fallback_utf8_utf16($string) {
+		return getid3_lib::iconv_fallback_utf8_utf16le($string, true);
+	}
+
+	// UTF-16BE => UTF-8
+	function iconv_fallback_utf16be_utf8($string) {
+		if (substr($string, 0, 2) == "\xFE\xFF") {
+			// strip BOM
+			$string = substr($string, 2);
+		}
+		$newcharstring = '';
+		for ($i = 0; $i < strlen($string); $i += 2) {
+			$charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
+			$newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
+		}
+		return $newcharstring;
+	}
+
+	// UTF-16LE => UTF-8
+	function iconv_fallback_utf16le_utf8($string) {
+		if (substr($string, 0, 2) == "\xFF\xFE") {
+			// strip BOM
+			$string = substr($string, 2);
+		}
+		$newcharstring = '';
+		for ($i = 0; $i < strlen($string); $i += 2) {
+			$charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
+			$newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
+		}
+		return $newcharstring;
+	}
+
+	// UTF-16BE => ISO-8859-1
+	function iconv_fallback_utf16be_iso88591($string) {
+		if (substr($string, 0, 2) == "\xFE\xFF") {
+			// strip BOM
+			$string = substr($string, 2);
+		}
+		$newcharstring = '';
+		for ($i = 0; $i < strlen($string); $i += 2) {
+			$charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
+			$newcharstring .= (($charval < 256) ? chr($charval) : '?');
+		}
+		return $newcharstring;
+	}
+
+	// UTF-16LE => ISO-8859-1
+	function iconv_fallback_utf16le_iso88591($string) {
+		if (substr($string, 0, 2) == "\xFF\xFE") {
+			// strip BOM
+			$string = substr($string, 2);
+		}
+		$newcharstring = '';
+		for ($i = 0; $i < strlen($string); $i += 2) {
+			$charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
+			$newcharstring .= (($charval < 256) ? chr($charval) : '?');
+		}
+		return $newcharstring;
+	}
+
+	// UTF-16 (BOM) => ISO-8859-1
+	function iconv_fallback_utf16_iso88591($string) {
+		$bom = substr($string, 0, 2);
+		if ($bom == "\xFE\xFF") {
+			return getid3_lib::iconv_fallback_utf16be_iso88591(substr($string, 2));
+		} elseif ($bom == "\xFF\xFE") {
+			return getid3_lib::iconv_fallback_utf16le_iso88591(substr($string, 2));
+		}
+		return $string;
+	}
+
+	// UTF-16 (BOM) => UTF-8
+	function iconv_fallback_utf16_utf8($string) {
+		$bom = substr($string, 0, 2);
+		if ($bom == "\xFE\xFF") {
+			return getid3_lib::iconv_fallback_utf16be_utf8(substr($string, 2));
+		} elseif ($bom == "\xFF\xFE") {
+			return getid3_lib::iconv_fallback_utf16le_utf8(substr($string, 2));
+		}
+		return $string;
+	}
+
 	function iconv_fallback($in_charset, $out_charset, $string) {
 
 		if ($in_charset == $out_charset) {
 			return $string;
 		}
 
-		if (!function_exists('iconv')) {
+		static $iconv_broken_or_unavailable = array();
+		if (is_null(@$iconv_broken_or_unavailable[$in_charset.'_'.$out_charset])) {
+			$GETID3_ICONV_TEST_STRING = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ';
 
-			if (($in_charset == 'ISO-8859-1') && ($out_charset == 'UTF-8')) {
-				return utf8_encode($string);
+			// Check iconv()
+			if (function_exists('iconv')) {
+				if (@iconv($in_charset, 'ISO-8859-1', @iconv('ISO-8859-1', $in_charset, $GETID3_ICONV_TEST_STRING)) == $GETID3_ICONV_TEST_STRING) {
+					if (@iconv($out_charset, 'ISO-8859-1', @iconv('ISO-8859-1', $out_charset, $GETID3_ICONV_TEST_STRING)) == $GETID3_ICONV_TEST_STRING) {
+						// everything works, use iconv()
+						$iconv_broken_or_unavailable[$in_charset.'_'.$out_charset] = false;
+					} else {
+						// iconv() available, but broken. Use getID3()'s iconv_fallback() conversions instead
+						// known issue in PHP v4.1.x
+						$iconv_broken_or_unavailable[$in_charset.'_'.$out_charset] = true;
+					}
+				} else {
+					// iconv() available, but broken. Use getID3()'s iconv_fallback() conversions instead
+					// known issue in PHP v4.1.x
+					$iconv_broken_or_unavailable[$in_charset.'_'.$out_charset] = true;
+				}
+			} else {
+				// iconv() unavailable, use getID3()'s iconv_fallback() conversions
+				$iconv_broken_or_unavailable[$in_charset.'_'.$out_charset] = true;
 			}
-			if (($in_charset == 'UTF-8') && ($out_charset == 'ISO-8859-1')) {
-				return utf8_decode($string);
+		}
+
+		if ($iconv_broken_or_unavailable[$in_charset.'_'.$out_charset]) {
+			static $ConversionFunctionList = array();
+			if (empty($ConversionFunctionList)) {
+				$ConversionFunctionList['ISO-8859-1']['UTF-8']    = 'iconv_fallback_iso88591_utf8';
+				$ConversionFunctionList['ISO-8859-1']['UTF-16']   = 'iconv_fallback_iso88591_utf16';
+				$ConversionFunctionList['ISO-8859-1']['UTF-16BE'] = 'iconv_fallback_iso88591_utf16be';
+				$ConversionFunctionList['ISO-8859-1']['UTF-16LE'] = 'iconv_fallback_iso88591_utf16le';
+				$ConversionFunctionList['UTF-8']['ISO-8859-1']    = 'iconv_fallback_utf8_iso88591';
+				$ConversionFunctionList['UTF-8']['UTF-16']        = 'iconv_fallback_utf8_utf16';
+				$ConversionFunctionList['UTF-8']['UTF-16BE']      = 'iconv_fallback_utf8_utf16be';
+				$ConversionFunctionList['UTF-8']['UTF-16LE']      = 'iconv_fallback_utf8_utf16le';
+				$ConversionFunctionList['UTF-16']['ISO-8859-1']   = 'iconv_fallback_utf16_iso88591';
+				$ConversionFunctionList['UTF-16']['UTF-8']        = 'iconv_fallback_utf16_utf8';
+				$ConversionFunctionList['UTF-16LE']['ISO-8859-1'] = 'iconv_fallback_utf16le_iso88591';
+				$ConversionFunctionList['UTF-16LE']['UTF-8']      = 'iconv_fallback_utf16le_utf8';
+				$ConversionFunctionList['UTF-16BE']['ISO-8859-1'] = 'iconv_fallback_utf16be_iso88591';
+				$ConversionFunctionList['UTF-16BE']['UTF-8']      = 'iconv_fallback_utf16be_utf8';
 			}
-
+			if (isset($ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)])) {
+				$ConversionFunction = $ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)];
+				return getid3_lib::$ConversionFunction($string);
+			}
 			die('PHP does not have iconv() support - cannot convert from '.$in_charset.' to '.$out_charset);
 		}
 
@@ -779,7 +1099,8 @@
 				break;
 
 			case 'UTF-8':
-				for ($i = 0; $i < strlen($string); $i++) {
+				$strlen = strlen($string);
+				for ($i = 0; $i < $strlen; $i++) {
 					$char_ord_val = ord($string{$i});
 					$charval = 0;
 					if ($char_ord_val < 0x80) {
@@ -876,11 +1197,11 @@
 		} else {
 			$signbit = '0';
 		}
-		$storedreplaygain = round($replaygain * 10);
+		$storedreplaygain = intval(round($replaygain * 10));
 		$gainstring  = str_pad(decbin($namecode), 3, '0', STR_PAD_LEFT);
 		$gainstring .= str_pad(decbin($originatorcode), 3, '0', STR_PAD_LEFT);
 		$gainstring .= $signbit;
-		$gainstring .= str_pad(decbin(round($replaygain * 10)), 9, '0', STR_PAD_LEFT);
+		$gainstring .= str_pad(decbin($storedreplaygain), 9, '0', STR_PAD_LEFT);
 
 		return $gainstring;
 	}
@@ -895,9 +1216,8 @@
 			$imgData = fread($fd, filesize($urlpic));
 			fclose($fd);
 			return getid3_lib::GetDataImageSize($imgData);
-		} else {
-			return array('', '', '');
 		}
+		return array('', '', '');
 	}
 
 
@@ -955,7 +1275,7 @@
 						// if the skip is more than what we've read in, read more
 						$buffer -= $skiplen;
 						if ($buffer < 512) { // if the buffer of data is too low, read more file.
-							// $imgData .= fread( $fd,$skiplen+1024 );
+							// $imgData .= fread($fd, $skiplen + 1024);
 							// $buffer += $skiplen + 1024;
 							return false; // End loop in case we find run out of data
 						}
@@ -973,7 +1293,7 @@
 		static $ImageTypesLookup = array();
 		if (empty($ImageTypesLookup)) {
 			$ImageTypesLookup[1]  = 'gif';
-			$ImageTypesLookup[2]  = 'jpg';
+			$ImageTypesLookup[2]  = 'jpeg';
 			$ImageTypesLookup[3]  = 'png';
 			$ImageTypesLookup[4]  = 'swf';
 			$ImageTypesLookup[5]  = 'psd';
@@ -1055,14 +1375,14 @@
 
 		// Discard $begin lines
 		for ($i = 0; $i < ($begin + 3); $i++) {
-			fgets($fp);
+			fgets($fp, 1024);
 		}
 
 		// Loop thru line
 		while (0 < $line_count--) {
 
 			// Read line
-			$line = ltrim(fgets($fp), "\t ");
+			$line = ltrim(fgets($fp, 1024), "\t ");
 
 			// METHOD A: only cache the matching key - less memory but slower on next lookup of not-previously-looked-up key
 			//$keycheck = substr($line, 0, $keylength);
@@ -1073,7 +1393,7 @@
 
 			// METHOD B: cache all keys in this lookup - more memory but faster on next lookup of not-previously-looked-up key
 			//$cache[$file][$name][substr($line, 0, $keylength)] = trim(substr($line, $keylength + 1));
-			list($ThisKey, $ThisValue) = explode("\t", $line, 2);
+			@list($ThisKey, $ThisValue) = explode("\t", $line, 2);
 			$cache[$file][$name][$ThisKey] = trim($ThisValue);
 		}
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/getid3.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/getid3.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/getid3.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -9,23 +9,21 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-
 // Defines
-define('GETID3_VERSION', '1.7.0');
+define('GETID3_VERSION', '1.7.4');
 define('GETID3_FREAD_BUFFER_SIZE', 16384); // read buffer size in bytes
 
 
-/**
- * \defgroup getid3
- *
- * Extracts information from supported files, such as metadata from images.
- */
+
 class getID3
 {
 	// public: Settings
 	var $encoding                 = 'ISO-8859-1';     // CASE SENSITIVE! - i.e. (must be supported by iconv())
 	                                                  // Examples:  ISO-8859-1  UTF-8  UTF-16  UTF-16BE
 
+	var $encoding_id3v1           = 'ISO-8859-1';     // Should always be 'ISO-8859-1', but some tags may be written
+	                                                  // in other encodings such as 'EUC-CN'
+
 	// public: Optional tag checks - disable for speed.
 	var $option_tag_id3v1         = true;             // Read and process ID3v1 tags
 	var $option_tag_id3v2         = true;             // Read and process ID3v2 tags
@@ -43,19 +41,42 @@
 	var $option_sha1_data         = false;            // Get SHA1 sum of data part - slow
 	var $option_max_2gb_check     = true;             // Check whether file is larger than 2 Gb and thus not supported by PHP
 
-	// public: Compatability settings
-	var $option_no_iconv          = false;            // Will allow getID3() to run in a limited manner with only
-	                                                  // ISO-8859-1 and UTF-8 text encoding if iconv() functions are unavailable
-
 	// private
 	var $filename;
 
 
-
 	// public: constructor
 	function getID3()
 	{
 
+		$this->startup_error   = '';
+		$this->startup_warning = '';
+
+		// Check for PHP version >= 4.1.0
+		if (phpversion() < '4.1.0') {
+		    $this->startup_error .= 'getID3() requires PHP v4.1.0 or higher - you are running v'.phpversion();
+		}
+
+		// Check memory
+		$memory_limit = ini_get('memory_limit');
+		if (eregi('([0-9]+)M', $memory_limit, $matches)) {
+			// could be stored as "16M" rather than 16777216 for example
+			$memory_limit = $matches[1] * 1048576;
+		}
+		if ($memory_limit <= 0) {
+			// memory limits probably disabled
+		} elseif ($memory_limit <= 3145728) {
+	    	$this->startup_error .= 'PHP has less than 3MB available memory and will very likely run out. Increase memory_limit in php.ini';
+		} elseif ($memory_limit <= 12582912) {
+	    	$this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini';
+		}
+
+		// Check safe_mode off
+		if ((bool) ini_get('safe_mode')) {
+		    $this->warning('WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.');
+		}
+
+
 		// define a constant rather than looking up every time it is needed
 		if (!defined('GETID3_OS_ISWINDOWS')) {
 			if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
@@ -64,27 +85,7 @@
 				define('GETID3_OS_ISWINDOWS', false);
 			}
 		}
-		
-		/** 
-		 * little patch to make it not complain that iconv hasn't been compiled in...
-		 * I'd rather be left without access to asf and iso files than needing to 
-		 * recompile php :P
-		 */
-		if(!function_exists('iconv'))
-			$this->option_no_iconv = true;
 
-		// Check for required iconv()
-		if (!function_exists('iconv') && empty($this->option_no_iconv)) {
-
-			if (GETID3_OS_ISWINDOWS) {
-				echo 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
-			} else {
-				echo 'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
-			}
-			echo "\n".' Alternatively you can restrict $this->encoding to "UTF-8" and "ISO-8859-1" and set $this->option_no_iconv to true. getID3() will die on ISO and ASF modules, so use at your own risk!';
-			die();
-		}
-
 		// Get base path of getID3() - ONCE
 		if (!defined('GETID3_INCLUDEPATH')) {
 			define('GETID3_OS_DIRSLASH', (GETID3_OS_ISWINDOWS ? '\\' : '/'));
@@ -99,7 +100,7 @@
 
 		// Load support library
 		if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
-			die('getid3.lib.php is missing or corrupt.');
+			$this->startup_error .= 'getid3.lib.php is missing or corrupt';
 		}
 
 
@@ -109,13 +110,12 @@
 		// IMPORTANT: This path cannot have spaces in it. If neccesary, use the 8dot3 equivalent
 		//   ie for "C:/Program Files/Apache/" put "C:/PROGRA~1/APACHE/"
 		// IMPORTANT: This path must include the trailing slash
-		if (!defined('GETID3_HELPERAPPSDIR') && GETID3_OS_ISWINDOWS) {
+		if (GETID3_OS_ISWINDOWS && !defined('GETID3_HELPERAPPSDIR')) {
 
-			//$helperappsdir = GETID3_INCLUDEPATH.'..'.GETID3_OS_DIRSLASH.'helperapps'; // must not have any space in this path
-			$helperappsdir = "C:\PROGRA~1\APACHE~1\APACHE\HTDOCS\TRUNK\CLASS\GALLERY\HELPER~1";
+			$helperappsdir = GETID3_INCLUDEPATH.'..'.GETID3_OS_DIRSLASH.'helperapps'; // must not have any space in this path
 
 			if (!is_dir($helperappsdir)) {
-				die('"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist');
+				$this->startup_error .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist';
 			} elseif (strpos(realpath($helperappsdir), ' ') !== false) {
 				$DirPieces = explode(GETID3_OS_DIRSLASH, realpath($helperappsdir));
 				foreach ($DirPieces as $key => $value) {
@@ -128,7 +128,7 @@
 					}
 					$DirPieces[$key] = strtoupper($value);
 				}
-				die('GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary (on this server that would be something like "'.implode(GETID3_OS_DIRSLASH, $DirPieces).'" - NOTE: this may or may not be the actual 8.3 equivalent of "'.$helperappsdir.'", please double-check). You can run "dir /x" from the commandline to see the correct 8.3-style names. You need to edit the file "'.GETID3_INCLUDEPATH.'/getid3.php" around line '.(__LINE__ - 16));
+				$this->startup_error .= 'GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary (on this server that would be something like "'.implode(GETID3_OS_DIRSLASH, $DirPieces).'" - NOTE: this may or may not be the actual 8.3 equivalent of "'.$helperappsdir.'", please double-check). You can run "dir /x" from the commandline to see the correct 8.3-style names. You need to edit the file "'.GETID3_INCLUDEPATH.'/getid3.php" around line '.(__LINE__ - 16);
 			}
 			define('GETID3_HELPERAPPSDIR', realpath($helperappsdir).GETID3_OS_DIRSLASH);
 		}
@@ -140,19 +140,37 @@
 	// public: analyze file - replaces GetAllFileInfo() and GetTagOnly()
 	function analyze($filename) {
 
+		if (!empty($this->startup_error)) {
+			return $this->error($this->startup_error);
+		}
+		if (!empty($this->startup_warning)) {
+			$this->warning($this->startup_warning);
+		}
+
+		// init result array and set parameters
+		$this->info = array();
+		$this->info['GETID3_VERSION'] = GETID3_VERSION;
+
+		// Check encoding/iconv support
+		if (!function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
+			$errormessage = 'iconv() support is needed for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
+			if (GETID3_OS_ISWINDOWS) {
+				$errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
+			} else {
+				$errormessage .= 'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
+			}
+	    	return $this->error($errormessage);
+		}
+
 		// Disable magic_quotes_runtime, if neccesary
 		$old_magic_quotes_runtime = get_magic_quotes_runtime(); // store current setting of magic_quotes_runtime
 		if ($old_magic_quotes_runtime) {
 			set_magic_quotes_runtime(0);                        // turn off magic_quotes_runtime
 			if (get_magic_quotes_runtime()) {
-				die('Could not disable magic_quotes_runtime - getID3() cannot work properly with this setting enabled');
+				return $this->error('Could not disable magic_quotes_runtime - getID3() cannot work properly with this setting enabled');
 			}
 		}
 
-		// init result array and set parameters
-		$this->info = array();
-		$this->info['GETID3_VERSION'] = GETID3_VERSION;
-
 		// remote files not supported
 		if (preg_match('/^(ht|f)tp:\/\//', $filename)) {
 			return $this->error('Remote files are not supported in this version of getID3() - please copy the file locally first');
@@ -226,11 +244,10 @@
 		}
 
 
-
 		// handle ID3v1 tag
 		if ($this->option_tag_id3v1) {
 			if (!@include_once(GETID3_INCLUDEPATH.'module.tag.id3v1.php')) {
-				die('module.tag.id3v1.php is missing - you may disable option_tag_id3v1.');
+				return $this->error('module.tag.id3v1.php is missing - you may disable option_tag_id3v1.');
 			}
 			$tag = new getid3_id3v1($fp, $this->info);
 		}
@@ -238,7 +255,7 @@
 		// handle APE tag
 		if ($this->option_tag_apetag) {
 			if (!@include_once(GETID3_INCLUDEPATH.'module.tag.apetag.php')) {
-				die('module.tag.apetag.php is missing - you may disable option_tag_apetag.');
+				return $this->error('module.tag.apetag.php is missing - you may disable option_tag_apetag.');
 			}
 			$tag = new getid3_apetag($fp, $this->info);
 		}
@@ -246,7 +263,7 @@
 		// handle lyrics3 tag
 		if ($this->option_tag_lyrics3) {
 			if (!@include_once(GETID3_INCLUDEPATH.'module.tag.lyrics3.php')) {
-				die('module.tag.lyrics3.php is missing - you may disable option_tag_lyrics3.');
+				return $this->error('module.tag.lyrics3.php is missing - you may disable option_tag_lyrics3.');
 			}
 			$tag = new getid3_lyrics3($fp, $this->info);
 		}
@@ -269,8 +286,7 @@
 			if ($determined_format['fail_id3'] === 'ERROR') {
 				fclose($fp);
 				return $this->error('ID3 tags not allowed on this file type.');
-			}
-			elseif ($determined_format['fail_id3'] === 'WARNING') {
+			} elseif ($determined_format['fail_id3'] === 'WARNING') {
 				$this->info['warning'][] = 'ID3 tags not allowed on this file type.';
 			}
 		}
@@ -280,8 +296,7 @@
 			if ($determined_format['fail_ape'] === 'ERROR') {
 				fclose($fp);
 				return $this->error('APE tags not allowed on this file type.');
-			}
-			elseif ($determined_format['fail_ape'] === 'WARNING') {
+			} elseif ($determined_format['fail_ape'] === 'WARNING') {
 				$this->info['warning'][] = 'APE tags not allowed on this file type.';
 			}
 		}
@@ -295,7 +310,12 @@
 			return $this->error('Format not supported, module, '.$determined_format['include'].', was removed.');
 		}
 
-		// require module
+		// module requires iconv support
+        if (!function_exists('iconv') && @$determined_format['iconv_req']) {
+		    return $this->error('iconv support is required for this module ('.$determined_format['include'].').');
+		}
+
+		// include module
 		include_once(GETID3_INCLUDEPATH.$determined_format['include']);
 
 		// instantiate module class
@@ -351,15 +371,22 @@
 
 
 	// private: error handling
-	function error($msg) {
+	function error($message) {
 
 		$this->CleanUp();
 
-		$this->info['error'][] = $msg;
+		$this->info['error'][] = $message;
 		return $this->info;
 	}
 
 
+	// private: warning handling
+	function warning($message) {
+		$this->info['warning'][] = $message;
+		return true;
+	}
+
+
 	// private: CleanUp
 	function CleanUp() {
 
@@ -375,16 +402,22 @@
 		}
 
 		// remove empty root keys
-		foreach ($this->info as $key => $value) {
-			if (empty($this->info[$key]) && ($this->info[$key] !== 0) && ($this->info[$key] !== '0')) {
-				unset($this->info[$key]);
+		if (!empty($this->info)) {
+			foreach ($this->info as $key => $value) {
+				if (empty($this->info[$key]) && ($this->info[$key] !== 0) && ($this->info[$key] !== '0')) {
+					unset($this->info[$key]);
+				}
 			}
 		}
 
 		// remove meaningless entries from unknown-format files
 		if (empty($this->info['fileformat'])) {
-			unset($this->info['avdataoffset']);
-			unset($this->info['avdataend']);
+			if (isset($this->info['avdataoffset'])) {
+				unset($this->info['avdataoffset']);
+			}
+			if (isset($this->info['avdataend'])) {
+				unset($this->info['avdataend']);
+			}
 		}
 	}
 
@@ -412,7 +445,7 @@
 							'module'    => 'aac',
 							'option'    => 'adif',
 							'mime_type' => 'application/octet-stream',
-							'fail_ape'  => 'WARNING'
+							'fail_ape'  => 'WARNING',
 						  ),
 
 
@@ -423,7 +456,7 @@
 							'module'    => 'aac',
 							'option'    => 'adts',
 							'mime_type' => 'application/octet-stream',
-							'fail_ape'  => 'WARNING'
+							'fail_ape'  => 'WARNING',
 						  ),
 
 
@@ -565,11 +598,13 @@
 							'group'     => 'audio',
 							'module'    => 'shorten',
 							'mime_type' => 'audio/xmms-shn',
+							'fail_id3'  => 'ERROR',
+							'fail_ape'  => 'ERROR',
 						  ),
 
-				// TTA  - audio       - TTA Lossless Audio Compressor (http://tta.iszf.irk.ru/)
+				// TTA  - audio       - TTA Lossless Audio Compressor (http://tta.corecodec.org)
 				'tta'  => array(
-							'pattern'   => '^TTA',  // could also be '^TTA'."\x01"
+							'pattern'   => '^TTA',  // could also be '^TTA(\x01|\x02|\x03|2|1)'
 							'group'     => 'audio',
 							'module'    => 'tta',
 							'mime_type' => 'application/octet-stream',
@@ -591,7 +626,15 @@
 							'mime_type' => 'application/octet-stream',
 						  ),
 
+				// WV  - audio        - WavPack (v4.0+)
+				'wv'   => array(
+							'pattern'   => '^wvpk',
+							'group'     => 'audio',
+							'module'    => 'wavpack',
+							'mime_type' => 'application/octet-stream',
+						  ),
 
+
 				// Audio-Video formats
 
 				// ASF  - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio
@@ -600,6 +643,7 @@
 							'group'     => 'audio-video',
 							'module'    => 'asf',
 							'mime_type' => 'video/x-ms-asf',
+							'iconv_req' => false,
 						  ),
 
 				// BINK  - audio/video - Bink / Smacker
@@ -641,7 +685,7 @@
 							'module'    => 'ogg',
 							'mime_type' => 'application/ogg',
 							'fail_id3'  => 'WARNING',
-							'fail_ape'  => 'WARNING'
+							'fail_ape'  => 'WARNING',
 						  ),
 
 				// QT   - audio/video - Quicktime
@@ -658,7 +702,7 @@
 							'group'     => 'audio-video',
 							'module'    => 'riff',
 							'mime_type' => 'audio/x-wave',
-							'fail_ape'  => 'WARNING'
+							'fail_ape'  => 'WARNING',
 						  ),
 
 				// Real - audio/video - RealAudio, RealVideo
@@ -687,7 +731,7 @@
 							'module'    => 'bmp',
 							'mime_type' => 'image/bmp',
 							'fail_id3'  => 'ERROR',
-							'fail_ape'  => 'ERROR'
+							'fail_ape'  => 'ERROR',
 						  ),
 
 				// GIF  - still image - Graphics Interchange Format
@@ -697,7 +741,7 @@
 							'module'    => 'gif',
 							'mime_type' => 'image/gif',
 							'fail_id3'  => 'ERROR',
-							'fail_ape'  => 'ERROR'
+							'fail_ape'  => 'ERROR',
 						  ),
 
 				// JPEG - still image - Joint Photographic Experts Group (JPEG)
@@ -705,9 +749,9 @@
 							'pattern'   => '^\xFF\xD8\xFF',
 							'group'     => 'graphic',
 							'module'    => 'jpg',
-							'mime_type' => 'image/jpg',
+							'mime_type' => 'image/jpeg',
 							'fail_id3'  => 'ERROR',
-							'fail_ape'  => 'ERROR'
+							'fail_ape'  => 'ERROR',
 						  ),
 
 				// PCD  - still image - Kodak Photo CD
@@ -717,7 +761,7 @@
 							'module'    => 'pcd',
 							'mime_type' => 'image/x-photo-cd',
 							'fail_id3'  => 'ERROR',
-							'fail_ape'  => 'ERROR'
+							'fail_ape'  => 'ERROR',
 						  ),
 
 
@@ -728,26 +772,23 @@
 							'module'    => 'png',
 							'mime_type' => 'image/png',
 							'fail_id3'  => 'ERROR',
-							'fail_ape'  => 'ERROR'
+							'fail_ape'  => 'ERROR',
 						  ),
 
 
-				// Data formats
-
-				// EXE  - data        - EXEcutable program (EXE, COM)
-
-				/*
-				'exe'  => array(
-							'pattern'   => '^MZ',
-							'group'     => 'misc',
-							'module'    => 'exe',
-							'mime_type' => 'application/octet-stream',
+				// TIFF  - still image - Tagged Information File Format (TIFF)
+				'tiff' => array(
+							'pattern'   => '^(II\x2A\x00|MM\x00\x2A)',
+							'group'     => 'graphic',
+							'module'    => 'tiff',
+							'mime_type' => 'image/tiff',
 							'fail_id3'  => 'ERROR',
-							'fail_ape'  => 'ERROR'
+							'fail_ape'  => 'ERROR',
 						  ),
-				*/
 
 
+				// Data formats
+
 				// ISO  - data        - International Standards Organization (ISO) CD-ROM Image
 				'iso'  => array(
 							'pattern'   => '^.{32769}CD001',
@@ -755,7 +796,8 @@
 							'module'    => 'iso',
 							'mime_type' => 'application/octet-stream',
 							'fail_id3'  => 'ERROR',
-							'fail_ape'  => 'ERROR'
+							'fail_ape'  => 'ERROR',
+							'iconv_req' => false,
 						  ),
 
 				// RAR  - data        - RAR compressed data
@@ -765,7 +807,7 @@
 							'module'    => 'rar',
 							'mime_type' => 'application/octet-stream',
 							'fail_id3'  => 'ERROR',
-							'fail_ape'  => 'ERROR'
+							'fail_ape'  => 'ERROR',
 						  ),
 
 				// SZIP - audio       - SZIP compressed data
@@ -775,9 +817,29 @@
 							'module'    => 'szip',
 							'mime_type' => 'application/octet-stream',
 							'fail_id3'  => 'ERROR',
-							'fail_ape'  => 'ERROR'
+							'fail_ape'  => 'ERROR',
 						  ),
 
+				// TAR  - data        - TAR compressed data
+				'tar'  => array(
+							'pattern'   => '^.{100}[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20\x00]{12}[0-9\x20\x00]{12}',
+							'group'     => 'archive',
+							'module'    => 'tar',
+							'mime_type' => 'application/x-tar',
+							'fail_id3'  => 'ERROR',
+							'fail_ape'  => 'ERROR',
+						  ),
+
+				// GZIP  - data        - GZIP compressed data
+				'gz'  => array(
+							'pattern'   => '^\x1F\x8B\x08',
+							'group'     => 'archive',
+							'module'    => 'gzip',
+							'mime_type' => 'application/x-gzip',
+							'fail_id3'  => 'ERROR',
+							'fail_ape'  => 'ERROR',
+						  ),
+
 				// ZIP  - data        - ZIP compressed data
 				'zip'  => array(
 							'pattern'   => '^PK\x03\x04',
@@ -785,7 +847,7 @@
 							'module'    => 'zip',
 							'mime_type' => 'application/zip',
 							'fail_id3'  => 'ERROR',
-							'fail_ape'  => 'ERROR'
+							'fail_ape'  => 'ERROR',
 						  )
 			);
 		}
@@ -812,13 +874,31 @@
 			}
 		}
 
-		// Too many mp3 encoders on the market put gabage in front of mpeg files
-		// use assume format on these if format detection failed
+
 		if (preg_match('/\.mp[123a]$/i', $filename)) {
+
+			// Too many mp3 encoders on the market put gabage in front of mpeg files
+			// use assume format on these if format detection failed
 			$GetFileFormatArray = $this->GetFileFormatArray();
 			$info = $GetFileFormatArray['mp3'];
 			$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
 			return $info;
+
+		//} elseif (preg_match('/\.tar$/i', $filename)) {
+        //
+		//	// TAR files don't have any useful header to work from
+		//	// TAR  - data        - TAR compressed data
+		//	$info = array(
+		//		'pattern'   => '^.{512}',
+		//		'group'     => 'archive',
+		//		'module'    => 'tar',
+		//		'mime_type' => 'application/octet-stream',
+		//		'fail_id3'  => 'ERROR',
+		//		'fail_ape'  => 'ERROR',
+		//	);
+		//	$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
+		//	return $info;
+
 		}
 
 		return false;
@@ -860,13 +940,14 @@
 				'nsv'       => array('nsv'           , 'ISO-8859-1'),
 				'ogg'       => array('vorbiscomment' , 'UTF-8'),
 				'png'       => array('png'           , 'UTF-8'),
+				'tiff'      => array('tiff'          , 'ISO-8859-1'),
 				'quicktime' => array('quicktime'     , 'ISO-8859-1'),
 				'real'      => array('real'          , 'ISO-8859-1'),
 				'vqf'       => array('vqf'           , 'ISO-8859-1'),
 				'zip'       => array('zip'           , 'ISO-8859-1'),
 				'riff'      => array('riff'          , 'ISO-8859-1'),
 				'lyrics3'   => array('lyrics3'       , 'ISO-8859-1'),
-				'id3v1'     => array('id3v1'         , 'ISO-8859-1'),
+				'id3v1'     => array('id3v1'         , $this->encoding_id3v1),
 				'id3v2'     => array('id3v2'         , 'UTF-8'), // not according to the specs (every frame can have a different encoding), but getID3() force-converts all encodings to UTF-8
 				'ape'       => array('ape'           , 'UTF-8')
 			);
@@ -901,7 +982,8 @@
 					foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {
 						foreach ($valuearray as $key => $value) {
 							if (is_string($value)) {
-								$this->info['tags_html'][$tag_name][$tag_key][$key] = getid3_lib::MultiByteCharString2HTML($value, $encoding);
+								//$this->info['tags_html'][$tag_name][$tag_key][$key] = getid3_lib::MultiByteCharString2HTML($value, $encoding);
+								$this->info['tags_html'][$tag_name][$tag_key][$key] = str_replace('&#0;', '', getid3_lib::MultiByteCharString2HTML($value, $encoding));
 							} else {
 								$this->info['tags_html'][$tag_name][$tag_key][$key] = $value;
 							}
@@ -924,7 +1006,7 @@
 				break;
 
 			default:
-				die('bad algorithm "'.$algorithm.'" in getHashdata()');
+				return $this->error('bad algorithm "'.$algorithm.'" in getHashdata()');
 				break;
 		}
 

Added: plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.gzip.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.gzip.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.gzip.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -0,0 +1,254 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info at getid3.org>               //
+//  available at http://getid3.sourceforge.net                 //
+//            or http://www.getid3.org                         //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details                             //
+/////////////////////////////////////////////////////////////////
+//                                                             //
+// module.archive.gzip.php                                     //
+// written by Mike Mozolin <teddybearØmail*ru>                 //
+// module for analyzing GZIP files                             //
+// dependencies: NONE                                          //
+//                                                            ///
+/////////////////////////////////////////////////////////////////
+
+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';
+		return $this->read_gzip($fd, $ThisFileInfo);
+	}
+
+	// Reads the gzip-file
+	function read_gzip($fd, &$ThisFileInfo) {
+
+		$start_length = 10;
+		$unpack_header = 'a1id1/a1id2/a1cmethod/a1flags/a4mtime/a1xflags/a1os';
+		//+---+---+---+---+---+---+---+---+---+---+
+		//|ID1|ID2|CM |FLG|     MTIME     |XFL|OS |
+		//+---+---+---+---+---+---+---+---+---+---+
+		@fseek($fd, 0);
+		$buffer = @fread($fd, $ThisFileInfo['filesize']);
+
+		$arr_members = explode("\x1F\x8B\x08", $buffer);
+		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;
+				}
+			}
+			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'][++$idx];
+
+			$buff = "\x1F\x8B\x08".$arr_members[$i];
+
+			$attr = unpack($unpack_header, substr($buff, 0, $start_length));
+			$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['compression'] = $this->get_xflag_type($thisThisFileInfo['raw']['xflags']);
+
+			$thisThisFileInfo['os'] = $this->get_os_type($thisThisFileInfo['raw']['os']);
+			if (!$thisThisFileInfo['os']) {
+				$ThisFileInfo['error'][] = 'Read error on gzip file';
+				return false;
+			}
+
+			$fpointer = 10;
+			$arr_xsubfield = array();
+			// bit 2 - FLG.FEXTRA
+			//+---+---+=================================+
+			//| XLEN  |...XLEN bytes of "extra field"...|
+			//+---+---+=================================+
+			if ($thisThisFileInfo['flags']['extra']) {
+				$w_xlen = substr($buff, $fpointer, 2);
+				$xlen = getid3_lib::LittleEndian2Int($w_xlen);
+				$fpointer += 2;
+
+				$thisThisFileInfo['raw']['xfield'] = substr($buff, $fpointer, $xlen);
+				// Extra SubFields
+				//+---+---+---+---+==================================+
+				//|SI1|SI2|  LEN  |... LEN bytes of subfield data ...|
+				//+---+---+---+---+==================================+
+				$idx = 0;
+				while (true) {
+					if ($idx >= $xlen) {
+						break;
+					}
+					$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);
+						$idx += 2;
+						$arr_xsubfield[] = substr($buff, $fpointer+$idx, $xsublen);
+						$idx += $xsublen;
+					} else {
+						break;
+					}
+				}
+				$fpointer += $xlen;
+			}
+			// bit 3 - FLG.FNAME
+			//+=========================================+
+			//|...original file name, zero-terminated...|
+			//+=========================================+
+			// 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) {
+					if (ord($buff[$fpointer]) == 0) {
+						$fpointer++;
+						break;
+					}
+					$thisThisFileInfo['filename'] .= $buff[$fpointer];
+					$fpointer++;
+				}
+			}
+			// bit 4 - FLG.FCOMMENT
+			//+===================================+
+			//|...file comment, zero-terminated...|
+			//+===================================+
+			if ($thisThisFileInfo['flags']['comment']) {
+				while (true) {
+					if (ord($buff[$fpointer]) == 0) {
+						$fpointer++;
+						break;
+					}
+					$thisThisFileInfo['comment'] .= $buff[$fpointer];
+					$fpointer++;
+				}
+			}
+			// bit 1 - FLG.FHCRC
+			//+---+---+
+			//| CRC16 |
+			//+---+---+
+			if ($thisThisFileInfo['flags']['crc16']) {
+				$w_crc = substr($buff, $fpointer, 2);
+				$thisThisFileInfo['crc16'] = getid3_lib::LittleEndian2Int($w_crc);
+				$fpointer += 2;
+			}
+			// bit 0 - FLG.FTEXT
+			//if ($thisThisFileInfo['raw']['flags'] & 0x01) {
+			//	Ignored...
+			//}
+			// bits 5, 6, 7 - reserved
+
+			$thisThisFileInfo['crc32']    = getid3_lib::LittleEndian2Int(substr($buff, strlen($buff) - 8, 4));
+			$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
+	function get_os_type($key) {
+		static $os_type = array(
+			'0'   => 'FAT filesystem (MS-DOS, OS/2, NT/Win32)',
+			'1'   => 'Amiga',
+			'2'   => 'VMS (or OpenVMS)',
+			'3'   => 'Unix',
+			'4'   => 'VM/CMS',
+			'5'   => 'Atari TOS',
+			'6'   => 'HPFS filesystem (OS/2, NT)',
+			'7'   => 'Macintosh',
+			'8'   => 'Z-System',
+			'9'   => 'CP/M',
+			'10'  => 'TOPS-20',
+			'11'  => 'NTFS filesystem (NT)',
+			'12'  => 'QDOS',
+			'13'  => 'Acorn RISCOS',
+			'255' => 'unknown'
+		);
+		return @$os_type[$key];
+	}
+
+	// Converts the eXtra FLags
+	function get_xflag_type($key) {
+		static $xflag_type = array(
+			'0' => 'unknown',
+			'2' => 'maximum compression',
+			'4' => 'fastest algorithm'
+		);
+		return @$xflag_type[$key];
+	}
+}
+
+?>

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.rar.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.rar.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.rar.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_rar
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.szip.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.szip.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.szip.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_szip
 {
 

Added: plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.tar.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.tar.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.tar.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -0,0 +1,181 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info at getid3.org>               //
+//  available at http://getid3.sourceforge.net                 //
+//            or http://www.getid3.org                         //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details                             //
+/////////////////////////////////////////////////////////////////
+//                                                             //
+// module.archive.tar.php                                      //
+// written by Mike Mozolin <teddybearØmail*ru>                 //
+// module for analyzing TAR files                              //
+// dependencies: NONE                                          //
+//                                                            ///
+/////////////////////////////////////////////////////////////////
+
+class getid3_tar {
+
+	function getid3_tar(&$fd, &$ThisFileInfo) {
+		$ThisFileInfo['fileformat'] = 'tar';
+
+		@fseek($fd, 0);
+		$filebuffer = @fread($fd, $ThisFileInfo['filesize']);
+		return $this->read_tar($filebuffer, $ThisFileInfo);
+	}
+
+	// Reads the tar-file
+	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';
+
+		$null_512k = str_repeat("\0", 512); // end-of-file marker
+
+		$ThisFileInfo['tar']['files'] = array();
+
+		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++) {
+				$checksum += ord(substr($buffer, $i, 1));
+			}
+			for ($i = 148; $i < 156; $i++) {
+				$checksum += ord(' ');
+			}
+			for ($i = 156; $i < 512; $i++) {
+				$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']));
+			$prefix  =        trim(@$attr['prefix']);
+			// EOF Found
+			if (($checksum == 256) && ($chksum == 0)) {
+				break;
+			}
+			if ($prefix) {
+				$name = $prefix.'/'.$name;
+			}
+			if ((preg_match('#/$#', $name)) && !$name) {
+				$typeflag = 5;
+			}
+			// If it's the end of the tar-file...
+			if ($buffer == $null_512k) {
+				break;
+			}
+			// Read the next chunk
+			$data = substr($filebuffer, 0, $size);
+			$filebuffer = substr($filebuffer, strlen($data));
+			if (strlen($data) != $size) {
+				$ThisFileInfo['error'][] = 'Read error on tar file';
+				return false;
+			}
+			$diff = $size % 512;
+			if ($diff != 0) {
+				// Padding, throw away
+				$buff = substr($filebuffer, 0, (512 - $diff));
+				$filebuffer = substr($filebuffer, strlen($buff));
+			}
+			// Protect against tar-files with garbage at the end
+			if ($name == '') {
+				break;
+			}
+			$ThisFileInfo['tar']['file_details'][$name] = array (
+				'name'     => $name,
+				'mode_raw' => $mode,
+				'mode'     => getid3_tar::display_perms($mode),
+				'uid'      => $uid,
+				'gid'      => $gid,
+				'size'     => $size,
+				'mtime'    => $mtime,
+				'chksum'   => $chksum,
+				'typeflag' => getid3_tar::get_flag_type($typflag),
+				'linkname' => $lnkname,
+				'magic'    => $magic,
+				'version'  => $ver,
+				'uname'    => $uname,
+				'gname'    => $gname,
+				'devmajor' => $devmaj,
+				'devminor' => $devmin
+			);
+			$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
+	function display_perms($mode) {
+		// Determine Type
+		if ($mode & 0x1000)     $type='p'; // FIFO pipe
+		elseif ($mode & 0x2000) $type='c'; // Character special
+		elseif ($mode & 0x4000) $type='d'; // Directory
+		elseif ($mode & 0x6000) $type='b'; // Block special
+		elseif ($mode & 0x8000) $type='-'; // Regular
+		elseif ($mode & 0xA000) $type='l'; // Symbolic Link
+		elseif ($mode & 0xC000) $type='s'; // Socket
+		else                    $type='u'; // UNKNOWN
+
+		// Determine permissions
+		$owner['read']    = (($mode & 00400) ? 'r' : '-');
+		$owner['write']   = (($mode & 00200) ? 'w' : '-');
+		$owner['execute'] = (($mode & 00100) ? 'x' : '-');
+		$group['read']    = (($mode & 00040) ? 'r' : '-');
+		$group['write']   = (($mode & 00020) ? 'w' : '-');
+		$group['execute'] = (($mode & 00010) ? 'x' : '-');
+		$world['read']    = (($mode & 00004) ? 'r' : '-');
+		$world['write']   = (($mode & 00002) ? 'w' : '-');
+		$world['execute'] = (($mode & 00001) ? 'x' : '-');
+
+		// Adjust for SUID, SGID and sticky bit
+		if ($mode & 0x800) $owner['execute'] = ($owner['execute'] == 'x') ? 's' : 'S';
+		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']);
+		return $s;
+	}
+
+	// Converts the file type
+	function get_flag_type($typflag) {
+		static $flag_types = array(
+			'0' => 'LF_NORMAL',
+			'1' => 'LF_LINK',
+			'2' => 'LF_SYNLINK',
+			'3' => 'LF_CHR',
+			'4' => 'LF_BLK',
+			'5' => 'LF_DIR',
+			'6' => 'LF_FIFO',
+			'7' => 'LF_CONFIG',
+			'D' => 'LF_DUMPDIR',
+			'K' => 'LF_LONGLINK',
+			'L' => 'LF_LONGNAME',
+			'M' => 'LF_MULTIVOL',
+			'N' => 'LF_NAMES',
+			'S' => 'LF_SPARSE',
+			'V' => 'LF_VOLHDR'
+		);
+		return @$flag_types[$typflag];
+	}
+
+}
+
+?>
\ No newline at end of file

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.zip.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.zip.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.archive.zip.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,17 +13,15 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_zip
 {
 
 	function getid3_zip(&$fd, &$ThisFileInfo) {
 
-		$ThisFileInfo['fileformat'] = 'zip';
+		$ThisFileInfo['fileformat']      = 'zip';
 		$ThisFileInfo['zip']['encoding'] = 'ISO-8859-1';
-		$ThisFileInfo['zip']['files'] = array();
+		$ThisFileInfo['zip']['files']    = array();
 
 		$ThisFileInfo['zip']['compressed_size']   = 0;
 		$ThisFileInfo['zip']['uncompressed_size'] = 0;
@@ -43,7 +41,7 @@
 				$ThisFileInfo['zip']['end_central_directory'] = $this->ZIPparseEndOfCentralDirectory($fd);
 
 				fseek($fd, $ThisFileInfo['zip']['end_central_directory']['directory_offset'], SEEK_SET);
-				$ThisFileInfo['zip']['entries_count']     = 0;
+				$ThisFileInfo['zip']['entries_count'] = 0;
 				while ($centraldirectoryentry = $this->ZIPparseCentralDirectory($fd)) {
 					$ThisFileInfo['zip']['central_directory'][] = $centraldirectoryentry;
 					$ThisFileInfo['zip']['entries_count']++;
@@ -88,6 +86,9 @@
 				$ThisFileInfo['error'][] = 'Warning: Truncated file! - Total compressed file sizes ('.$ThisFileInfo['zip']['compressed_size'].' bytes) is greater than filesize minus Central Directory and End Of Central Directory structures ('.($ThisFileInfo['filesize'] - 46 - 22).' bytes)';
 			}
 			$ThisFileInfo['error'][] = 'Cannot find End Of Central Directory - returned list of files in [zip][entries] array may not be complete';
+			foreach ($ThisFileInfo['zip']['entries'] as $key => $valuearray) {
+				$ThisFileInfo['zip']['files'][$valuearray['filename']] = $valuearray['uncompressed_size'];
+			}
 			return true;
 
 		} else {
@@ -201,13 +202,14 @@
 			$ZIPlocalFileHeader .= fread($fd, $FilenameExtrafieldLength);
 
 			if ($LocalFileHeader['raw']['filename_length'] > 0) {
-				$LocalFileHeader['filename']                    = substr($ZIPlocalFileHeader, 30, $LocalFileHeader['raw']['filename_length']);
+				$LocalFileHeader['filename']                = substr($ZIPlocalFileHeader, 30, $LocalFileHeader['raw']['filename_length']);
 			}
 			if ($LocalFileHeader['raw']['extra_field_length'] > 0) {
 				$LocalFileHeader['raw']['extra_field_data'] = substr($ZIPlocalFileHeader, 30 + $LocalFileHeader['raw']['filename_length'], $LocalFileHeader['raw']['extra_field_length']);
 			}
 		}
 
+		$LocalFileHeader['data_offset'] = ftell($fd);
 		//$LocalFileHeader['compressed_data'] = fread($fd, $LocalFileHeader['raw']['compressed_size']);
 		fseek($fd, $LocalFileHeader['raw']['compressed_size'], SEEK_CUR);
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.asf.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.asf.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.asf.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -10,7 +10,6 @@
 // module.audio-video.asf.php                                  //
 // module for analyzing ASF, WMA and WMV files                 //
 // dependencies: module.audio-video.riff.php                   //
-//               module.tag.id3v1.php (optional)               //
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
@@ -23,9 +22,7 @@
 }
 
 
-/**
- * \ingroup getid3
- */
+
 class getid3_asf
 {
 
@@ -296,7 +293,7 @@
 						//return false;
 						break;
 					}
-					$thisfile_asf_codeclistobject['codec_entries_count']       = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
+					$thisfile_asf_codeclistobject['codec_entries_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 					$offset += 4;
 					for ($CodecEntryCounter = 0; $CodecEntryCounter < $thisfile_asf_codeclistobject['codec_entries_count']; $CodecEntryCounter++) {
 						// shortcut
@@ -324,8 +321,12 @@
 
 						if ($thisfile_asf_codeclistobject_codecentries_current['type_raw'] == 2) {
 							// audio codec
-							$thisfile_audio['codec'] = $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['name']);
+							if (strpos($thisfile_asf_codeclistobject_codecentries_current['description'], ',') === false) {
+								$ThisFileInfo['error'][] = '[asf][codec_list_object][codec_entries]['.$CodecEntryCounter.'][description] expected to contain comma-seperated list of parameters: "'.$thisfile_asf_codeclistobject_codecentries_current['description'].'"';
+								return false;
+							}
 							list($AudioCodecBitrate, $AudioCodecFrequency, $AudioCodecChannels) = explode(',', $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']));
+							$thisfile_audio['codec'] = $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['name']);
 
 							if (!isset($thisfile_audio['bitrate']) && strstr($AudioCodecBitrate, 'kbps')) {
 								$thisfile_audio['bitrate'] = (int) (trim(str_replace('kbps', '', $AudioCodecBitrate)) * 1000);
@@ -733,17 +734,7 @@
 
 							case 'wm/genre':
 							case 'genre':
-								$genre = $this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
-
-								// id3v1 module might not be loaded
-								$GETID3_ERRORARRAY = &$ThisFileInfo['warning'];
-								if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v1.php', __FILE__, false)) {
-									$CleanedGenre = getid3_id3v1::StandardiseID3v1GenreName($genre); // convert to standard GenreID and back to standard spelling/capitalization
-									if ($CleanedGenre != $genre) {
-										$genre = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', $CleanedGenre);
-									}
-								}
-								$thisfile_asf_comments['genre'] = array($genre);
+								$thisfile_asf_comments['genre'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
 								break;
 
 							case 'wm/tracknumber':
@@ -773,13 +764,18 @@
 							case 'id3':
 								// id3v2 module might not be loaded
 								if (class_exists('getid3_id3v2')) {
-									if ($tempfilehandle = tmpfile()) {
-										$tempThisfileInfo = array('encoding'=>$ThisFileInfo['encoding']);
-										fwrite($tempfilehandle, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
-										$id3 = new getid3_id3v2($tempfilehandle, $tempThisfileInfo);
-										fclose($tempfilehandle);
-										$ThisFileInfo['id3v2'] = $tempThisfileInfo['id3v2'];
-									}
+								    $tempfile         = tempnam('*', 'getID3');
+								    $tempfilehandle   = fopen($tempfile, "wb");
+									$tempThisfileInfo = array('encoding'=>$ThisFileInfo['encoding']);
+									fwrite($tempfilehandle, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
+									fclose($tempfilehandle);
+									
+									$tempfilehandle = fopen($tempfile, "rb");
+									$id3 = new getid3_id3v2($tempfilehandle, $tempThisfileInfo);
+									fclose($tempfilehandle);
+									unlink($tempfile);
+									
+									$ThisFileInfo['id3v2'] = $tempThisfileInfo['id3v2'];
 								}
 								break;
 
@@ -1391,8 +1387,8 @@
 			$GUIDarray['GETID3_ASF_Stream_Prioritization_Object']        = 'D4FED15B-88D3-454F-81F0-ED5C45999E24';
 			$GUIDarray['GETID3_ASF_Payload_Ext_System_Content_Type']     = 'D590DC20-07BC-436C-9CF7-F3BBFBF1A4DC';
 			$GUIDarray['GETID3_ASF_Old_File_Properties_Object']          = 'D6E229D0-35DA-11D1-9034-00A0C90349BE';
-			$GUIDarray['GETID3_ASF_Old_GETID3_ASF_Header_Object']               = 'D6E229D1-35DA-11D1-9034-00A0C90349BE';
-			$GUIDarray['GETID3_ASF_Old_GETID3_ASF_Data_Object']                 = 'D6E229D2-35DA-11D1-9034-00A0C90349BE';
+			$GUIDarray['GETID3_ASF_Old_ASF_Header_Object']               = 'D6E229D1-35DA-11D1-9034-00A0C90349BE';
+			$GUIDarray['GETID3_ASF_Old_ASF_Data_Object']                 = 'D6E229D2-35DA-11D1-9034-00A0C90349BE';
 			$GUIDarray['GETID3_ASF_Index_Object']                        = 'D6E229D3-35DA-11D1-9034-00A0C90349BE';
 			$GUIDarray['GETID3_ASF_Old_Stream_Properties_Object']        = 'D6E229D4-35DA-11D1-9034-00A0C90349BE';
 			$GUIDarray['GETID3_ASF_Old_Content_Description_Object']      = 'D6E229D5-35DA-11D1-9034-00A0C90349BE';
@@ -1440,7 +1436,7 @@
 			$GUIDarray['GETID3_ASF_Mutex_Language']                      = 'D6E22A00-35DA-11D1-9034-00A0C90349BE';
 			$GUIDarray['GETID3_ASF_Mutex_Bitrate']                       = 'D6E22A01-35DA-11D1-9034-00A0C90349BE';
 			$GUIDarray['GETID3_ASF_Mutex_Unknown']                       = 'D6E22A02-35DA-11D1-9034-00A0C90349BE';
-			$GUIDarray['GETID3_ASF_Old_GETID3_ASF_Placeholder_Object']          = 'D6E22A0E-35DA-11D1-9034-00A0C90349BE';
+			$GUIDarray['GETID3_ASF_Old_ASF_Placeholder_Object']          = 'D6E22A0E-35DA-11D1-9034-00A0C90349BE';
 			$GUIDarray['GETID3_ASF_Old_Data_Unit_Extension_Object']      = 'D6E22A0F-35DA-11D1-9034-00A0C90349BE';
 			$GUIDarray['GETID3_ASF_Web_Stream_Format']                   = 'DA1E6B13-8359-4050-B398-388E965BF00C';
 			$GUIDarray['GETID3_ASF_Payload_Ext_System_File_Name']        = 'E165EC0E-19ED-45D7-B4A7-25CBD1E28E9B';
@@ -1537,7 +1533,7 @@
 		// UNIX timestamp is number of seconds since January 1, 1970
 		// 116444736000000000 = 10000000 * 60 * 60 * 24 * 365 * 369 + 89 leap days
 		if ($round) {
-			return round(($FILETIME - 116444736000000000) / 10000000);
+			return intval(round(($FILETIME - 116444736000000000) / 10000000));
 		}
 		return ($FILETIME - 116444736000000000) / 10000000;
 	}

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.bink.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.bink.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.bink.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_bink
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.matroska.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.matroska.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.matroska.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_matroska
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.mpeg.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.mpeg.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.mpeg.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -24,9 +24,7 @@
 define('GETID3_MPEG_VIDEO_GROUP_START',     "\x00\x00\x01\xB8");
 define('GETID3_MPEG_AUDIO_START',           "\x00\x00\x01\xC0");
 
-/**
- * \ingroup getid3
- */
+
 class getid3_mpeg
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.nsv.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.nsv.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.nsv.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_nsv
 {
 
@@ -75,30 +73,30 @@
 
 		$ThisFileInfo['nsv']['NSVs']['offset']          = $fileoffset;
 
-		$ThisFileInfo['nsv']['NSVs']['video_codec']     =                  substr($NSVsheader, $offset, 4);
+		$ThisFileInfo['nsv']['NSVs']['video_codec']     =                              substr($NSVsheader, $offset, 4);
 		$offset += 4;
-		$ThisFileInfo['nsv']['NSVs']['audio_codec']     =                  substr($NSVsheader, $offset, 4);
+		$ThisFileInfo['nsv']['NSVs']['audio_codec']     =                              substr($NSVsheader, $offset, 4);
 		$offset += 4;
 		$ThisFileInfo['nsv']['NSVs']['resolution_x']    = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 2));
 		$offset += 2;
 		$ThisFileInfo['nsv']['NSVs']['resolution_y']    = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 2));
 		$offset += 2;
 
-		$ThisFileInfo['nsv']['NSVs']['framerate_index'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 2));
+		$ThisFileInfo['nsv']['NSVs']['framerate_index'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
 		$offset += 1;
-		$ThisFileInfo['nsv']['NSVs']['unknown1b']       = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+		//$ThisFileInfo['nsv']['NSVs']['unknown1b']       = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
 		$offset += 1;
-		$ThisFileInfo['nsv']['NSVs']['unknown1c']       = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+		//$ThisFileInfo['nsv']['NSVs']['unknown1c']       = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
 		$offset += 1;
-		$ThisFileInfo['nsv']['NSVs']['unknown1d']       = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+		//$ThisFileInfo['nsv']['NSVs']['unknown1d']       = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
 		$offset += 1;
-		$ThisFileInfo['nsv']['NSVs']['unknown2a']       = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+		//$ThisFileInfo['nsv']['NSVs']['unknown2a']       = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
 		$offset += 1;
-		$ThisFileInfo['nsv']['NSVs']['unknown2b']       = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+		//$ThisFileInfo['nsv']['NSVs']['unknown2b']       = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
 		$offset += 1;
-		$ThisFileInfo['nsv']['NSVs']['unknown2c']       = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+		//$ThisFileInfo['nsv']['NSVs']['unknown2c']       = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
 		$offset += 1;
-		$ThisFileInfo['nsv']['NSVs']['unknown2d']       = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
+		//$ThisFileInfo['nsv']['NSVs']['unknown2d']       = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
 		$offset += 1;
 
 		switch ($ThisFileInfo['nsv']['NSVs']['audio_codec']) {
@@ -116,14 +114,8 @@
 			case 'MP3 ':
 			case 'NONE':
 			default:
-				$ThisFileInfo['nsv']['NSVs']['unknown3a']    = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
-				$offset += 1;
-				$ThisFileInfo['nsv']['NSVs']['unknown3b']    = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
-				$offset += 1;
-				$ThisFileInfo['nsv']['NSVs']['unknown3c']    = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
-				$offset += 1;
-				$ThisFileInfo['nsv']['NSVs']['unknown3d']    = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
-				$offset += 1;
+				//$ThisFileInfo['nsv']['NSVs']['unknown3']     = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 4));
+				$offset += 4;
 				break;
 		}
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.quicktime.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.quicktime.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.quicktime.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -5,24 +5,23 @@
 //            or http://www.getid3.org                         //
 /////////////////////////////////////////////////////////////////
 // See readme.txt for more details                             //
+/////////////////////////////////////////////////////////////////
+//                                                             //
+// module.audio-video.quicktime.php                            //
+// module for analyzing Quicktime and MP3-in-MP4 files         //
+// dependencies: module.audio.mp3.php                          //
+//                                                            ///
+/////////////////////////////////////////////////////////////////
 
+getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
 
-getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
-/**
- * \ingroup getid3
- *
- *                                                             //
- * module.audio-video.quicktime.php                            //
- * module for analyzing Quicktime and MP3-in-MP4 files         //
- * dependencies: module.audio.mp3.php                          //
- *                                                            ///
-*/
 class getid3_quicktime
 {
 
 	function getid3_quicktime(&$fd, &$ThisFileInfo, $ReturnAtomData=true, $ParseAllPossibleAtoms=false) {
 
-		$ThisFileInfo['fileformat']          = 'quicktime';
+		$ThisFileInfo['fileformat'] = 'quicktime';
+		$ThisFileInfo['quicktime']['hinting'] = false;
 
 		fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
 
@@ -35,9 +34,9 @@
 
 			$atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4));
 			$atomname =               substr($AtomHeader, 4, 4);
-			$ThisFileInfo['quicktime']["$atomname"]['name']   = $atomname;
-			$ThisFileInfo['quicktime']["$atomname"]['size']   = $atomsize;
-			$ThisFileInfo['quicktime']["$atomname"]['offset'] = $offset;
+			$ThisFileInfo['quicktime'][$atomname]['name']   = $atomname;
+			$ThisFileInfo['quicktime'][$atomname]['size']   = $atomsize;
+			$ThisFileInfo['quicktime'][$atomname]['offset'] = $offset;
 
 			if (($offset + $atomsize) > $ThisFileInfo['avdataend']) {
 				$ThisFileInfo['error'][] = 'Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atomsize.' bytes)';
@@ -53,11 +52,11 @@
 			switch ($atomname) {
 				case 'mdat': // Media DATa atom
 					// 'mdat' contains the actual data for the audio/video
-					if (($atomsize > 8) && (!isset($ThisFileInfo['avdataend_tmp']) || ($ThisFileInfo['quicktime']["$atomname"]['size'] > ($ThisFileInfo['avdataend_tmp'] - $ThisFileInfo['avdataoffset'])))) {
+					if (($atomsize > 8) && (!isset($ThisFileInfo['avdataend_tmp']) || ($ThisFileInfo['quicktime'][$atomname]['size'] > ($ThisFileInfo['avdataend_tmp'] - $ThisFileInfo['avdataoffset'])))) {
 
-						$ThisFileInfo['avdataoffset'] = $ThisFileInfo['quicktime']["$atomname"]['offset'] + 8;
+						$ThisFileInfo['avdataoffset'] = $ThisFileInfo['quicktime'][$atomname]['offset'] + 8;
 						$OldAVDataEnd                 = $ThisFileInfo['avdataend'];
-						$ThisFileInfo['avdataend']    = $ThisFileInfo['quicktime']["$atomname"]['offset'] + $ThisFileInfo['quicktime']["$atomname"]['size'];
+						$ThisFileInfo['avdataend']    = $ThisFileInfo['quicktime'][$atomname]['offset'] + $ThisFileInfo['quicktime'][$atomname]['size'];
 
 						if (getid3_mp3::MPEGaudioHeaderValid(getid3_mp3::MPEGaudioHeaderDecode(fread($fd, 4)))) {
 							getid3_mp3::getOnlyMPEGaudioInfo($fd, $ThisFileInfo, $ThisFileInfo['avdataoffset'], false);
@@ -85,7 +84,7 @@
 
 				default:
 					$atomHierarchy = array();
-					$ThisFileInfo['quicktime']["$atomname"] = $this->QuicktimeParseAtom($atomname, $atomsize, fread($fd, $atomsize), $ThisFileInfo, $offset, $atomHierarchy, $ParseAllPossibleAtoms);
+					$ThisFileInfo['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, fread($fd, $atomsize), $ThisFileInfo, $offset, $atomHierarchy, $ParseAllPossibleAtoms);
 					break;
 			}
 
@@ -205,7 +204,7 @@
 
 
 			case 'play': // auto-PLAY atom
-				$atomstructure['autoplay']            = (bool) getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
+				$atomstructure['autoplay']             = (bool) getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
 
 				$ThisFileInfo['quicktime']['autoplay'] = $atomstructure['autoplay'];
 				break;
@@ -235,7 +234,7 @@
 			case 'cmvd': // Compressed MooV Data atom
 				// Code by ubergeekØubergeek*tv based on information from
 				// http://developer.apple.com/quicktime/icefloe/dispatch012.html
-				$atomstructure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atomdata,  0, 4));
+				$atomstructure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atomdata, 0, 4));
 
 				$CompressedFileData = substr($atomdata, 4);
 				if ($UncompressedHeader = @gzuncompress($CompressedFileData)) {
@@ -286,14 +285,14 @@
 
 			case 'rmcs': // Reference Movie Cpu Speed atom
 				$atomstructure['version']          = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-				$atomstructure['flags_raw']        = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+				$atomstructure['flags_raw']        = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 				$atomstructure['cpu_speed_rating'] = getid3_lib::BigEndian2Int(substr($atomdata,  4, 2));
 				break;
 
 
 			case 'rmvc': // Reference Movie Version Check atom
 				$atomstructure['version']            = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-				$atomstructure['flags_raw']          = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+				$atomstructure['flags_raw']          = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 				$atomstructure['gestalt_selector']   =                           substr($atomdata,  4, 4);
 				$atomstructure['gestalt_value_mask'] = getid3_lib::BigEndian2Int(substr($atomdata,  8, 4));
 				$atomstructure['gestalt_value']      = getid3_lib::BigEndian2Int(substr($atomdata, 12, 4));
@@ -303,7 +302,7 @@
 
 			case 'rmcd': // Reference Movie Component check atom
 				$atomstructure['version']                = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-				$atomstructure['flags_raw']              = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+				$atomstructure['flags_raw']              = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 				$atomstructure['component_type']         =                           substr($atomdata,  4, 4);
 				$atomstructure['component_subtype']      =                           substr($atomdata,  8, 4);
 				$atomstructure['component_manufacturer'] =                           substr($atomdata, 12, 4);
@@ -315,7 +314,7 @@
 
 			case 'rmdr': // Reference Movie Data Rate atom
 				$atomstructure['version']       = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-				$atomstructure['flags_raw']     = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+				$atomstructure['flags_raw']     = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 				$atomstructure['data_rate']     = getid3_lib::BigEndian2Int(substr($atomdata,  4, 4));
 
 				$atomstructure['data_rate_bps'] = $atomstructure['data_rate'] * 10;
@@ -324,7 +323,7 @@
 
 			case 'rmla': // Reference Movie Language Atom
 				$atomstructure['version']     = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-				$atomstructure['flags_raw']   = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+				$atomstructure['flags_raw']   = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 				$atomstructure['language_id'] = getid3_lib::BigEndian2Int(substr($atomdata,  4, 2));
 
 				$atomstructure['language']    = $this->QuicktimeLanguageLookup($atomstructure['language_id']);
@@ -336,14 +335,38 @@
 
 			case 'rmla': // Reference Movie Language Atom
 				$atomstructure['version']   = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-				$atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+				$atomstructure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 				$atomstructure['track_id']  = getid3_lib::BigEndian2Int(substr($atomdata,  4, 2));
 				break;
 
 
+			case 'ptv ': // Print To Video - defines a movie's full screen mode
+				// http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm
+				$atomstructure['display_size_raw']  = getid3_lib::BigEndian2Int(substr($atomdata, 0, 2));
+				$atomstructure['reserved_1']        = getid3_lib::BigEndian2Int(substr($atomdata, 2, 2)); // hardcoded: 0x0000
+				$atomstructure['reserved_2']        = getid3_lib::BigEndian2Int(substr($atomdata, 4, 2)); // hardcoded: 0x0000
+				$atomstructure['slide_show_flag']   = getid3_lib::BigEndian2Int(substr($atomdata, 6, 1));
+				$atomstructure['play_on_open_flag'] = getid3_lib::BigEndian2Int(substr($atomdata, 7, 1));
+
+				$atomstructure['flags']['play_on_open'] = (bool) $atomstructure['play_on_open_flag'];
+				$atomstructure['flags']['slide_show']   = (bool) $atomstructure['slide_show_flag'];
+
+				$ptv_lookup[0] = 'normal';
+				$ptv_lookup[1] = 'double';
+				$ptv_lookup[2] = 'half';
+				$ptv_lookup[3] = 'full';
+				$ptv_lookup[4] = 'current';
+				if (isset($ptv_lookup[$atomstructure['display_size_raw']])) {
+					$atomstructure['display_size'] = $ptv_lookup[$atomstructure['display_size_raw']];
+				} else {
+					$ThisFileInfo['warning'][] = 'unknown "ptv " display constant ('.$atomstructure['display_size_raw'].')';
+				}
+				break;
+
+
 			case 'stsd': // Sample Table Sample Description atom
 				$atomstructure['version']        = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-				$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+				$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 				$atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata,  4, 4));
 				$stsdEntriesDataOffset = 8;
 				for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
@@ -392,10 +415,14 @@
 									$ThisFileInfo['audio']['sample_rate']              = $ThisFileInfo['quicktime']['audio']['sample_rate'];
 									$ThisFileInfo['audio']['channels']                 = $ThisFileInfo['quicktime']['audio']['channels'];
 									$ThisFileInfo['audio']['bits_per_sample']          = $ThisFileInfo['quicktime']['audio']['bit_depth'];
-									if ($ThisFileInfo['audio']['codec'] == 'raw PCM') {
-										$ThisFileInfo['audio']['lossless'] = true;
-									} else {
-										$ThisFileInfo['audio']['lossless'] = false;
+									switch ($atomstructure['sample_description_table'][$i]['data_format']) {
+										case 'raw ': // PCM
+										case 'alac': // Apple Lossless Audio Codec
+											$ThisFileInfo['audio']['lossless'] = true;
+											break;
+										default:
+											$ThisFileInfo['audio']['lossless'] = false;
+											break;
 									}
 									break;
 							}
@@ -483,7 +510,7 @@
 			case 'stts': // Sample Table Time-to-Sample atom
 				//if ($ParseAllPossibleAtoms) {
 					$atomstructure['version']        = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-					$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+					$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 					$atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata,  4, 4));
 					$sttsEntriesDataOffset = 8;
 					$FrameRateCalculatorArray = array();
@@ -526,7 +553,7 @@
 			case 'stss': // Sample Table Sync Sample (key frames) atom
 				if ($ParseAllPossibleAtoms) {
 					$atomstructure['version']        = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-					$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+					$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 					$atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata,  4, 4));
 					$stssEntriesDataOffset = 8;
 					for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
@@ -540,7 +567,7 @@
 			case 'stsc': // Sample Table Sample-to-Chunk atom
 				if ($ParseAllPossibleAtoms) {
 					$atomstructure['version']        = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-					$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+					$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 					$atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata,  4, 4));
 					$stscEntriesDataOffset = 8;
 					for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
@@ -558,7 +585,7 @@
 			case 'stsz': // Sample Table SiZe atom
 				if ($ParseAllPossibleAtoms) {
 					$atomstructure['version']        = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-					$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+					$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 					$atomstructure['sample_size']    = getid3_lib::BigEndian2Int(substr($atomdata,  4, 4));
 					$atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata,  8, 4));
 					$stszEntriesDataOffset = 12;
@@ -575,7 +602,7 @@
 			case 'stco': // Sample Table Chunk Offset atom
 				if ($ParseAllPossibleAtoms) {
 					$atomstructure['version']        = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-					$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+					$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 					$atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata,  4, 4));
 					$stcoEntriesDataOffset = 8;
 					for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
@@ -588,7 +615,7 @@
 
 			case 'dref': // Data REFerence atom
 				$atomstructure['version']        = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-				$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+				$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 				$atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata,  4, 4));
 				$drefDataOffset = 8;
 				for ($i = 0; $i < $atomstructure['number_entries']; $i++) {
@@ -598,7 +625,7 @@
 					$drefDataOffset += 4;
 					$atomstructure['data_references'][$i]['version']                 = getid3_lib::BigEndian2Int(substr($atomdata,  $drefDataOffset, 1));
 					$drefDataOffset += 1;
-					$atomstructure['data_references'][$i]['flags_raw']               = getid3_lib::BigEndian2Int(substr($atomdata,  $drefDataOffset, 3)); // hardcoded: 0x000
+					$atomstructure['data_references'][$i]['flags_raw']               = getid3_lib::BigEndian2Int(substr($atomdata,  $drefDataOffset, 3)); // hardcoded: 0x0000
 					$drefDataOffset += 3;
 					$atomstructure['data_references'][$i]['data']                    =               substr($atomdata, $drefDataOffset, ($atomstructure['data_references'][$i]['size'] - 4 - 4 - 1 - 3));
 					$drefDataOffset += ($atomstructure['data_references'][$i]['size'] - 4 - 4 - 1 - 3);
@@ -610,7 +637,7 @@
 
 			case 'gmin': // base Media INformation atom
 				$atomstructure['version']                = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-				$atomstructure['flags_raw']              = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+				$atomstructure['flags_raw']              = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 				$atomstructure['graphics_mode']          = getid3_lib::BigEndian2Int(substr($atomdata,  4, 2));
 				$atomstructure['opcolor_red']            = getid3_lib::BigEndian2Int(substr($atomdata,  6, 2));
 				$atomstructure['opcolor_green']          = getid3_lib::BigEndian2Int(substr($atomdata,  8, 2));
@@ -622,7 +649,7 @@
 
 			case 'smhd': // Sound Media information HeaDer atom
 				$atomstructure['version']                = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-				$atomstructure['flags_raw']              = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+				$atomstructure['flags_raw']              = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 				$atomstructure['balance']                = getid3_lib::BigEndian2Int(substr($atomdata,  4, 2));
 				$atomstructure['reserved']               = getid3_lib::BigEndian2Int(substr($atomdata,  6, 2));
 				break;
@@ -642,7 +669,7 @@
 
 			case 'hdlr': // HanDLeR reference atom
 				$atomstructure['version']                = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-				$atomstructure['flags_raw']              = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+				$atomstructure['flags_raw']              = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 				$atomstructure['component_type']         =                           substr($atomdata,  4, 4);
 				$atomstructure['component_subtype']      =                           substr($atomdata,  8, 4);
 				$atomstructure['component_manufacturer'] =                           substr($atomdata, 12, 4);
@@ -658,7 +685,7 @@
 
 			case 'mdhd': // MeDia HeaDer atom
 				$atomstructure['version']               = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-				$atomstructure['flags_raw']             = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+				$atomstructure['flags_raw']             = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 				$atomstructure['creation_time']         = getid3_lib::BigEndian2Int(substr($atomdata,  4, 4));
 				$atomstructure['modify_time']           = getid3_lib::BigEndian2Int(substr($atomdata,  8, 4));
 				$atomstructure['time_scale']            = getid3_lib::BigEndian2Int(substr($atomdata, 12, 4));
@@ -721,19 +748,19 @@
 
 			case 'elst': // Edit LiST atom
 				$atomstructure['version']        = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-				$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+				$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 				$atomstructure['number_entries'] = getid3_lib::BigEndian2Int(substr($atomdata,  4, 4));
 				for ($i = 0; $i < $atomstructure['number_entries']; $i++ ) {
-					$atomstructure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($i * 12) + 0, 4));
-					$atomstructure['edit_list'][$i]['media_time']     = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($i * 12) + 4, 4));
-					$atomstructure['edit_list'][$i]['media_rate']     = getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($i * 12) + 8, 4));
+					$atomstructure['edit_list'][$i]['track_duration'] =   getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($i * 12) + 0, 4));
+					$atomstructure['edit_list'][$i]['media_time']     =   getid3_lib::BigEndian2Int(substr($atomdata, 8 + ($i * 12) + 4, 4));
+					$atomstructure['edit_list'][$i]['media_rate']     = getid3_lib::FixedPoint16_16(substr($atomdata, 8 + ($i * 12) + 8, 4));
 				}
 				break;
 
 
 			case 'kmat': // compressed MATte atom
 				$atomstructure['version']        = getid3_lib::BigEndian2Int(substr($atomdata,  0, 1));
-				$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x000
+				$atomstructure['flags_raw']      = getid3_lib::BigEndian2Int(substr($atomdata,  1, 3)); // hardcoded: 0x0000
 				$atomstructure['matte_data_raw'] =               substr($atomdata,  4);
 				break;
 
@@ -763,12 +790,12 @@
 				$atomstructure['reserved']           =                             substr($atomdata, 26, 10);
 				$atomstructure['matrix_a']           = getid3_lib::FixedPoint16_16(substr($atomdata, 36, 4));
 				$atomstructure['matrix_b']           = getid3_lib::FixedPoint16_16(substr($atomdata, 40, 4));
-				$atomstructure['matrix_u']           = getid3_lib::FixedPoint16_16(substr($atomdata, 44, 4));
+				$atomstructure['matrix_u']           =  getid3_lib::FixedPoint2_30(substr($atomdata, 44, 4));
 				$atomstructure['matrix_c']           = getid3_lib::FixedPoint16_16(substr($atomdata, 48, 4));
-				$atomstructure['matrix_v']           = getid3_lib::FixedPoint16_16(substr($atomdata, 52, 4));
-				$atomstructure['matrix_d']           = getid3_lib::FixedPoint16_16(substr($atomdata, 56, 4));
-				$atomstructure['matrix_x']           =  getid3_lib::FixedPoint2_30(substr($atomdata, 60, 4));
-				$atomstructure['matrix_y']           =  getid3_lib::FixedPoint2_30(substr($atomdata, 64, 4));
+				$atomstructure['matrix_d']           = getid3_lib::FixedPoint16_16(substr($atomdata, 52, 4));
+				$atomstructure['matrix_v']           =  getid3_lib::FixedPoint2_30(substr($atomdata, 56, 4));
+				$atomstructure['matrix_x']           = getid3_lib::FixedPoint16_16(substr($atomdata, 60, 4));
+				$atomstructure['matrix_y']           = getid3_lib::FixedPoint16_16(substr($atomdata, 64, 4));
 				$atomstructure['matrix_w']           =  getid3_lib::FixedPoint2_30(substr($atomdata, 68, 4));
 				$atomstructure['preview_time']       =   getid3_lib::BigEndian2Int(substr($atomdata, 72, 4));
 				$atomstructure['preview_duration']   =   getid3_lib::BigEndian2Int(substr($atomdata, 76, 4));
@@ -782,10 +809,11 @@
 					$ThisFileInfo['error'][] = 'Corrupt Quicktime file: mvhd.time_scale == zero';
 					return false;
 				}
-				$atomstructure['creation_time_unix']     = getid3_lib::DateMac2Unix($atomstructure['creation_time']);
-				$atomstructure['modify_time_unix']       = getid3_lib::DateMac2Unix($atomstructure['modify_time']);
-				$ThisFileInfo['quicktime']['time_scale'] = $atomstructure['time_scale'];
-				$ThisFileInfo['playtime_seconds']        = $atomstructure['duration'] / $atomstructure['time_scale'];
+				$atomstructure['creation_time_unix']        = getid3_lib::DateMac2Unix($atomstructure['creation_time']);
+				$atomstructure['modify_time_unix']          = getid3_lib::DateMac2Unix($atomstructure['modify_time']);
+				$ThisFileInfo['quicktime']['time_scale']    = $atomstructure['time_scale'];
+				$ThisFileInfo['quicktime']['display_scale'] = $atomstructure['matrix_a'];
+				$ThisFileInfo['playtime_seconds']           = $atomstructure['duration'] / $atomstructure['time_scale'];
 				break;
 
 
@@ -822,8 +850,8 @@
 				$atomstructure['modify_time_unix']    = getid3_lib::DateMac2Unix($atomstructure['modify_time']);
 
 				if (!isset($ThisFileInfo['video']['resolution_x']) || !isset($ThisFileInfo['video']['resolution_y'])) {
-					$ThisFileInfo['video']['resolution_x']      = $atomstructure['width'];
-					$ThisFileInfo['video']['resolution_y']      = $atomstructure['height'];
+					$ThisFileInfo['video']['resolution_x'] = $atomstructure['width'];
+					$ThisFileInfo['video']['resolution_y'] = $atomstructure['height'];
 				}
 				$ThisFileInfo['video']['resolution_x'] = max($ThisFileInfo['video']['resolution_x'], $atomstructure['width']);
 				$ThisFileInfo['video']['resolution_y'] = max($ThisFileInfo['video']['resolution_y'], $atomstructure['height']);
@@ -843,6 +871,9 @@
 				$NextTagPosition = strpos($atomdata, '©');
 				while ($NextTagPosition < strlen($atomdata)) {
 					$metaItemSize = getid3_lib::BigEndian2Int(substr($atomdata, $NextTagPosition - 4, 4)) - 4;
+					if ($metaItemSize == -4) {
+					    break;
+					}
 					$metaItemRaw  = substr($atomdata, $NextTagPosition, $metaItemSize);
 					$metaItemKey  = substr($metaItemRaw, 0, 4);
 					$metaItemData = substr($metaItemRaw, 20);
@@ -897,6 +928,13 @@
 				$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));
@@ -906,6 +944,7 @@
 			case 'FXTC': // Something to do with Adobe After Effects (?)
 			case 'PrmA':
 			case 'code':
+			case 'FIEL': // this is NOT "fiel" (Field Ordering) as describe here: http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html
 				// Observed-but-not-handled atom types are just listed here
 				// to prevent warnings being generated
 				$atomstructure['data'] = $atomdata;
@@ -1119,7 +1158,7 @@
 			$QuicktimeVideoCodecLookup['WRAW'] = 'Windows RAW';
 			$QuicktimeVideoCodecLookup['y420'] = 'YUV420';
 		}
-		return (isset($QuicktimeVideoCodecLookup["$codecid"]) ? $QuicktimeVideoCodecLookup["$codecid"] : '');
+		return (isset($QuicktimeVideoCodecLookup[$codecid]) ? $QuicktimeVideoCodecLookup[$codecid] : '');
 	}
 
 	function QuicktimeAudioCodecLookup($codecid) {
@@ -1128,6 +1167,7 @@
 			$QuicktimeAudioCodecLookup['.mp3']          = 'Fraunhofer MPEG Layer-III alias';
 			$QuicktimeAudioCodecLookup['aac ']          = 'ISO/IEC 14496-3 AAC';
 			$QuicktimeAudioCodecLookup['agsm']          = 'Apple GSM 10:1';
+			$QuicktimeAudioCodecLookup['alac']          = 'Apple Lossless Audio Codec';
 			$QuicktimeAudioCodecLookup['alaw']          = 'A-law 2:1';
 			$QuicktimeAudioCodecLookup['conv']          = 'Sample Format';
 			$QuicktimeAudioCodecLookup['dvca']          = 'DV';
@@ -1163,7 +1203,7 @@
 			$QuicktimeAudioCodecLookup['twos']          = 'signed/two\'s complement (Big Endian)';
 			$QuicktimeAudioCodecLookup['ulaw']          = 'mu-law 2:1';
 		}
-		return (isset($QuicktimeAudioCodecLookup["$codecid"]) ? $QuicktimeAudioCodecLookup["$codecid"] : '');
+		return (isset($QuicktimeAudioCodecLookup[$codecid]) ? $QuicktimeAudioCodecLookup[$codecid] : '');
 	}
 
 	function QuicktimeDCOMLookup($compressionid) {
@@ -1172,7 +1212,7 @@
 			$QuicktimeDCOMLookup['zlib'] = 'ZLib Deflate';
 			$QuicktimeDCOMLookup['adec'] = 'Apple Compression';
 		}
-		return (isset($QuicktimeDCOMLookup["$compressionid"]) ? $QuicktimeDCOMLookup["$compressionid"] : '');
+		return (isset($QuicktimeDCOMLookup[$compressionid]) ? $QuicktimeDCOMLookup[$compressionid] : '');
 	}
 
 	function QuicktimeColorNameLookup($colordepthid) {
@@ -1235,8 +1275,8 @@
 			$handyatomtranslatorarray['©url'] = 'url';
 			$handyatomtranslatorarray['©enc'] = 'encoder';
 		}
-		if (isset($handyatomtranslatorarray["$keyname"])) {
-			$ThisFileInfo['quicktime']['comments'][$handyatomtranslatorarray["$keyname"]][] = $data;
+		if (isset($handyatomtranslatorarray[$keyname])) {
+			$ThisFileInfo['quicktime']['comments'][$handyatomtranslatorarray[$keyname]][] = $data;
 		}
 
 		return true;

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.real.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.real.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.real.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -5,16 +5,16 @@
 //            or http://www.getid3.org                         //
 /////////////////////////////////////////////////////////////////
 // See readme.txt for more details                             //
+/////////////////////////////////////////////////////////////////
+//                                                             //
+// module.audio-video.real.php                                 //
+// module for analyzing Real Audio/Video files                 //
+// dependencies: module.audio-video.riff.php                   //
+//                                                            ///
+/////////////////////////////////////////////////////////////////
+
 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
 
-/**
- * \ingroup getid3
- *                                                             //
- * module.audio-video.real.php                                 //
- * module for analyzing Real Audio/Video files                 //
- * dependencies: module.audio-video.riff.php                   //
- *                                                            ///
-*/
 class getid3_real
 {
 
@@ -35,7 +35,7 @@
 				if ($this->ParseOldRAheader(substr($ChunkData, 0, 128), $ThisFileInfo['real']['old_ra_header'])) {
 					$ThisFileInfo['audio']['dataformat']      = 'real';
 					$ThisFileInfo['audio']['lossless']        = false;
-					$ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['real']['old_ra_header']['sample_rate'];
+					$ThisFileInfo['audio']['sample_rate']     = $ThisFileInfo['real']['old_ra_header']['sample_rate'];
 					$ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['real']['old_ra_header']['bits_per_sample'];
 					$ThisFileInfo['audio']['channels']        = $ThisFileInfo['real']['old_ra_header']['channels'];
 
@@ -48,7 +48,7 @@
 							$ThisFileInfo['real']['comments'][$key][] = trim($valuearray[0]);
 						}
 					}
-					break;
+					return true;
 				}
 				$ThisFileInfo['error'][] = 'There was a problem parsing this RealAudio file. Please submit it for analysis to http://www.getid3.org/upload/ or info at getid3.org';
 				unset($ThisFileInfo['bitrate']);
@@ -189,16 +189,16 @@
 								$thisfile_real_chunks_currentchunk_videoinfo['width']             = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 12, 2));
 								$thisfile_real_chunks_currentchunk_videoinfo['height']            = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 14, 2));
 								$thisfile_real_chunks_currentchunk_videoinfo['bits_per_sample']   = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 16, 2));
-								$thisfile_real_chunks_currentchunk_videoinfo['unknown1']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 18, 2));
-								$thisfile_real_chunks_currentchunk_videoinfo['unknown2']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 20, 2));
+								//$thisfile_real_chunks_currentchunk_videoinfo['unknown1']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 18, 2));
+								//$thisfile_real_chunks_currentchunk_videoinfo['unknown2']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 20, 2));
 								$thisfile_real_chunks_currentchunk_videoinfo['frames_per_second'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 22, 2));
-								$thisfile_real_chunks_currentchunk_videoinfo['unknown3']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 24, 2));
-								$thisfile_real_chunks_currentchunk_videoinfo['unknown4']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 26, 2));
-								$thisfile_real_chunks_currentchunk_videoinfo['unknown5']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 28, 2));
-								$thisfile_real_chunks_currentchunk_videoinfo['unknown6']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 30, 2));
-								$thisfile_real_chunks_currentchunk_videoinfo['unknown7']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 32, 2));
-								$thisfile_real_chunks_currentchunk_videoinfo['unknown8']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 34, 2));
-								$thisfile_real_chunks_currentchunk_videoinfo['unknown9']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 36, 2));
+								//$thisfile_real_chunks_currentchunk_videoinfo['unknown3']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 24, 2));
+								//$thisfile_real_chunks_currentchunk_videoinfo['unknown4']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 26, 2));
+								//$thisfile_real_chunks_currentchunk_videoinfo['unknown5']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 28, 2));
+								//$thisfile_real_chunks_currentchunk_videoinfo['unknown6']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 30, 2));
+								//$thisfile_real_chunks_currentchunk_videoinfo['unknown7']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 32, 2));
+								//$thisfile_real_chunks_currentchunk_videoinfo['unknown8']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 34, 2));
+								//$thisfile_real_chunks_currentchunk_videoinfo['unknown9']          = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 36, 2));
 
 								$thisfile_real_chunks_currentchunk_videoinfo['codec'] = getid3_riff::RIFFfourccLookup($thisfile_real_chunks_currentchunk_videoinfo['fourcc2']);
 
@@ -230,10 +230,26 @@
 								$thisfile_real_chunks_currentchunk['logical_fileinfo'] = array();
 								$thisfile_real_chunks_currentchunk_logicalfileinfo     = &$thisfile_real_chunks_currentchunk['logical_fileinfo'];
 
-								$thisfile_real_chunks_currentchunk_logicalfileinfo['logical_fileinfo_length'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata,  0, 4));
-								$thisfile_real_chunks_currentchunk_logicalfileinfo['a']                       = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata,  4, 4));
-								$thisfile_real_chunks_currentchunk_logicalfileinfo['b']                       = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata,  8, 4));
-								$thisfile_real_chunks_currentchunk_logicalfileinfo['c']                       = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 12, 4));
+								$thisfile_real_chunks_currentchunk_logicalfileinfo_offset = 0;
+								$thisfile_real_chunks_currentchunk_logicalfileinfo['logical_fileinfo_length'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, 4));
+								$thisfile_real_chunks_currentchunk_logicalfileinfo_offset += 4;
+
+								//$thisfile_real_chunks_currentchunk_logicalfileinfo['unknown1']                = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, 4));
+								$thisfile_real_chunks_currentchunk_logicalfileinfo_offset += 4;
+
+								$thisfile_real_chunks_currentchunk_logicalfileinfo['num_tags']                = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, 4));
+								$thisfile_real_chunks_currentchunk_logicalfileinfo_offset += 4;
+
+								//$thisfile_real_chunks_currentchunk_logicalfileinfo['unknown2']                = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, 4));
+								$thisfile_real_chunks_currentchunk_logicalfileinfo_offset += 4;
+
+								//$thisfile_real_chunks_currentchunk_logicalfileinfo['d']                       = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, 1));
+
+								//$thisfile_real_chunks_currentchunk_logicalfileinfo['one_type'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata,     $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, 4));
+								//$thisfile_real_chunks_currentchunk_logicalfileinfo_thislength  = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 4 + $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, 2));
+								//$thisfile_real_chunks_currentchunk_logicalfileinfo['one']      =                           substr($thisfile_real_chunks_currentchunk_typespecificdata, 6 + $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, $thisfile_real_chunks_currentchunk_logicalfileinfo_thislength);
+								//$thisfile_real_chunks_currentchunk_logicalfileinfo_offset += (6 + $thisfile_real_chunks_currentchunk_logicalfileinfo_thislength);
+
 								break;
 
 						}
@@ -255,18 +271,25 @@
 								case 'video/x-pn-realvideo':
 								case 'video/x-pn-multirate-realvideo':
 									$ThisFileInfo['video']['bitrate']            = (isset($ThisFileInfo['video']['bitrate']) ? $ThisFileInfo['video']['bitrate'] : 0) + $thisfile_real_chunks_currentchunk['avg_bit_rate'];
-									$ThisFileInfo['video']['birate_mode']        = 'cbr';
+									$ThisFileInfo['video']['bitrate_mode']       = 'cbr';
 									$ThisFileInfo['video']['dataformat']         = 'real';
 									$ThisFileInfo['video']['lossless']           = false;
 									$ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
 									break;
+
+								case 'audio/x-ralf-mpeg4-generic':
+									$ThisFileInfo['audio']['bitrate']    = (isset($ThisFileInfo['audio']['bitrate']) ? $ThisFileInfo['audio']['bitrate'] : 0) + $thisfile_real_chunks_currentchunk['avg_bit_rate'];
+									$ThisFileInfo['audio']['codec']      = 'RealAudio Lossless';
+									$ThisFileInfo['audio']['dataformat'] = 'real';
+									$ThisFileInfo['audio']['lossless']   = true;
+									break;
 							}
 							$ThisFileInfo['bitrate'] = (isset($ThisFileInfo['video']['bitrate']) ? $ThisFileInfo['video']['bitrate'] : 0) + (isset($ThisFileInfo['audio']['bitrate']) ? $ThisFileInfo['audio']['bitrate'] : 0);
 						}
 					}
 					break;
 
-				case 'CONT': // Content Description Header
+				case 'CONT': // Content Description Header (text comments)
 					$thisfile_real_chunks_currentchunk['object_version'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
 					$offset += 2;
 					if ($thisfile_real_chunks_currentchunk['object_version'] == 0) {
@@ -367,9 +390,9 @@
 
 			$ParsedArray['header_size']      = getid3_lib::BigEndian2Int(substr($OldRAheaderData,  6, 2));
 			$ParsedArray['channels']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData,  8, 2)); // always 1 (?)
-			$ParsedArray['unknown1']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 10, 2));
-			$ParsedArray['unknown2']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 12, 2));
-			$ParsedArray['unknown3']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 14, 2));
+			//$ParsedArray['unknown1']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 10, 2));
+			//$ParsedArray['unknown2']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 12, 2));
+			//$ParsedArray['unknown3']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 14, 2));
 			$ParsedArray['bytes_per_minute'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 16, 2));
 			$ParsedArray['audio_bytes']      = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 18, 4));
 			$ParsedArray['comments_raw']     =                           substr($OldRAheaderData, 22, $ParsedArray['header_size'] - 22 + 1); // not including null terminator
@@ -393,7 +416,7 @@
 
 		} elseif ($ParsedArray['version1'] <= 5) {
 
-			$ParsedArray['unknown1']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData,  6, 2));
+			//$ParsedArray['unknown1']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData,  6, 2));
 			$ParsedArray['fourcc1']          =                           substr($OldRAheaderData,  8, 4);
 			$ParsedArray['file_size']        = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 12, 4));
 			$ParsedArray['version2']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 16, 2));
@@ -402,25 +425,25 @@
 			$ParsedArray['coded_frame_size'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 24, 4));
 			$ParsedArray['audio_bytes']      = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 28, 4));
 			$ParsedArray['bytes_per_minute'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 32, 4));
-			$ParsedArray['unknown5']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 36, 4));
+			//$ParsedArray['unknown5']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 36, 4));
 			$ParsedArray['sub_packet_h']     = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 40, 2));
 			$ParsedArray['frame_size']       = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 42, 2));
 			$ParsedArray['sub_packet_size']  = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 44, 2));
-			$ParsedArray['unknown6']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 46, 2));
+			//$ParsedArray['unknown6']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 46, 2));
 
 			switch ($ParsedArray['version1']) {
 
 				case 4:
 					$ParsedArray['sample_rate']      = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 48, 2));
-					$ParsedArray['unknown8']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 50, 2));
+					//$ParsedArray['unknown8']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 50, 2));
 					$ParsedArray['bits_per_sample']  = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 52, 2));
 					$ParsedArray['channels']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 54, 2));
 					$ParsedArray['length_fourcc2']   = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 56, 1));
 					$ParsedArray['fourcc2']          =                           substr($OldRAheaderData, 57, 4);
 					$ParsedArray['length_fourcc3']   = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 61, 1));
 					$ParsedArray['fourcc3']          =                           substr($OldRAheaderData, 62, 4);
-					$ParsedArray['unknown9']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 66, 1));
-					$ParsedArray['unknown10']        = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 67, 2));
+					//$ParsedArray['unknown9']         = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 66, 1));
+					//$ParsedArray['unknown10']        = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 67, 2));
 					$ParsedArray['comments_raw']     =                           substr($OldRAheaderData, 69, $ParsedArray['header_size'] - 69 + 16);
 
 					$commentoffset = 0;
@@ -490,8 +513,9 @@
 			$RealAudioCodecFourCClookup['cook'][0] = 'RealAudio G2';
 			$RealAudioCodecFourCClookup['atrc'][0] = 'RealAudio 8';
 		}
-		if (isset($RealAudioCodecFourCClookup[$fourcc][round($bitrate)])) {
-			return $RealAudioCodecFourCClookup[$fourcc][round($bitrate)];
+		$roundbitrate = intval(round($bitrate));
+		if (isset($RealAudioCodecFourCClookup[$fourcc][$roundbitrate])) {
+			return $RealAudioCodecFourCClookup[$fourcc][$roundbitrate];
 		} elseif (isset($RealAudioCodecFourCClookup[$fourcc][0])) {
 			return $RealAudioCodecFourCClookup[$fourcc][0];
 		}

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.riff.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.riff.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.riff.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -10,7 +10,7 @@
 // module.audio-video.riff.php                                 //
 // module for analyzing RIFF files                             //
 // multiple formats supported by this module:                  //
-//    Wave, AVI, AIFF/AIFC, (MP3,AC3)/RIFF, Wavpack, 8SVX      //
+//    Wave, AVI, AIFF/AIFC, (MP3,AC3)/RIFF, Wavpack v3, 8SVX   //
 // dependencies: module.audio.mp3.php                          //
 //               module.audio.ac3.php (optional)               //
 //                                                            ///
@@ -18,9 +18,6 @@
 
 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
 
-/**
- * \ingroup getid3
- */
 class getid3_riff
 {
 
@@ -114,8 +111,8 @@
 
 					$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
@@ -273,7 +270,7 @@
 				}
 
 				if (!empty($ThisFileInfo['wavpack'])) {
-					$thisfile_audio_dataformat   = 'wavpack';
+					$thisfile_audio_dataformat = 'wavpack';
 					$thisfile_audio['bitrate_mode'] = 'vbr';
 					$thisfile_audio['encoder']      = 'WavPack v'.$ThisFileInfo['wavpack']['version'];
 
@@ -337,7 +334,7 @@
 							$thisfile_riff_litewave_raw['m_bFactExists']      = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 38, 2));
 							$thisfile_riff_litewave_raw['m_dwRiffChunkSize']  = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 40, 4));
 
-							//$thisfile_riff_litewave['quality_factor'] = (int) round((2000 - $thisfile_riff_litewave_raw['m_dwScale']) / 20);
+							//$thisfile_riff_litewave['quality_factor'] = intval(round((2000 - $thisfile_riff_litewave_raw['m_dwScale']) / 20));
 							$thisfile_riff_litewave['quality_factor'] = $thisfile_riff_litewave_raw['m_wQuality'];
 
 							$thisfile_riff_litewave['flags']['raw_source']    = ($thisfile_riff_litewave_raw['compression_flags'] & 0x01) ? false : true;
@@ -402,7 +399,7 @@
 				break;
 
 			case 'AVI ':
-				$thisfile_video['bitrate_mode'] = 'cbr';
+				$thisfile_video['bitrate_mode'] = 'vbr'; // maybe not, but probably
 				$thisfile_video['dataformat']   = 'avi';
 				$ThisFileInfo['mime_type']      = 'video/avi';
 
@@ -465,7 +462,7 @@
 						$thisfile_video['total_frames']              = $thisfile_riff_video_current['total_frames'];
 					}
 
-					$thisfile_riff_video_current['frame_rate']   = round(1000000 / $thisfile_riff_raw_avih['dwMicroSecPerFrame'], 3);
+					$thisfile_riff_video_current['frame_rate'] = round(1000000 / $thisfile_riff_raw_avih['dwMicroSecPerFrame'], 3);
 					$thisfile_video['frame_rate'] = $thisfile_riff_video_current['frame_rate'];
 				}
 				if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strh'][0]['data'])) {
@@ -477,6 +474,10 @@
 
 								if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'])) {
 									$strfData = $thisfile_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'];
+
+									// shortcut
+									$thisfile_riff_raw_strf_strhfccType_streamindex = &$thisfile_riff_raw['strf'][$strhfccType][$streamindex];
+
 									switch ($strhfccType) {
 										case 'auds':
 											$thisfile_audio['bitrate_mode'] = 'cbr';
@@ -500,7 +501,6 @@
 
 											// shortcut
 											$thisfile_riff_raw['strf'][$strhfccType][$streamindex] = $thisfile_riff_audio[$streamindex]['raw'];
-											$thisfile_riff_raw_strf_strhfccType_streamindex        = &$thisfile_riff_raw['strf'][$strhfccType][$streamindex];
 
 											unset($thisfile_riff_audio[$streamindex]['raw']);
 											$thisfile_audio = getid3_lib::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]);
@@ -545,15 +545,14 @@
 											$thisfile_audio_streams_currentstream['dataformat']   = $thisfile_audio_dataformat;
 											$thisfile_audio_streams_currentstream['lossless']     = $thisfile_audio['lossless'];
 											$thisfile_audio_streams_currentstream['bitrate_mode'] = $thisfile_audio['bitrate_mode'];
-
 											break;
 
 
 										case 'iavs':
 										case 'vids':
 											// shortcut
-											$thisfile_riff_raw['strh'][$i]  = array();
-											$thisfile_riff_raw_strh_current = &$thisfile_riff_raw['strh'][$i];
+											$thisfile_riff_raw['strh'][$i]                  = array();
+											$thisfile_riff_raw_strh_current                 = &$thisfile_riff_raw['strh'][$i];
 
 											$thisfile_riff_raw_strh_current['fccType']               =                  substr($strhData,  0, 4);  // same as $strhfccType;
 											$thisfile_riff_raw_strh_current['fccHandler']            =                  substr($strhData,  4, 4);
@@ -901,56 +900,7 @@
 			$thisfile_riff['comments']['title'][] = trim(substr($thisfile_riff_WAVE['DISP'][count($thisfile_riff_WAVE['DISP']) - 1]['data'], 4));
 		}
 		if (isset($thisfile_riff_WAVE['INFO']) && is_array($thisfile_riff_WAVE['INFO'])) {
-			$RIFFinfoKeyLookup = array(
-				'IARL'=>'archivallocation',
-				'IART'=>'artist',
-				'ICDS'=>'costumedesigner',
-				'ICMS'=>'commissionedby',
-				'ICMT'=>'comment',
-				'ICNT'=>'country',
-				'ICOP'=>'copyright',
-				'ICRD'=>'creationdate',
-				'IDIM'=>'dimensions',
-				'IDIT'=>'digitizationdate',
-				'IDPI'=>'resolution',
-				'IDST'=>'distributor',
-				'IEDT'=>'editor',
-				'IENG'=>'engineers',
-				'IFRM'=>'accountofparts',
-				'IGNR'=>'genre',
-				'IKEY'=>'keywords',
-				'ILGT'=>'lightness',
-				'ILNG'=>'language',
-				'IMED'=>'orignalmedium',
-				'IMUS'=>'composer',
-				'INAM'=>'title',
-				'IPDS'=>'productiondesigner',
-				'IPLT'=>'palette', 
-				'IPRD'=>'product',
-				'IPRO'=>'producer',
-				'IPRT'=>'part',
-				'IRTD'=>'rating',
-				'ISBJ'=>'subject',
-				'ISFT'=>'software',
-				'ISGN'=>'secondarygenre',
-				'ISHP'=>'sharpness',
-				'ISRC'=>'sourcesupplier',
-				'ISRF'=>'digitizationsource',
-				'ISTD'=>'productionstudio',
-				'ISTR'=>'starring',
-				'ITCH'=>'encoded_by',
-				'IWEB'=>'url',
-				'IWRI'=>'writer'
-			);
-			foreach ($RIFFinfoKeyLookup as $key => $value) {
-				if (isset($thisfile_riff_WAVE['INFO'][$key])) {
-					foreach ($thisfile_riff_WAVE['INFO'][$key] as $commentid => $commentdata) {
-						if (trim($commentdata['data']) != '') {
-							$thisfile_riff['comments'][$value][] = trim($commentdata['data']);
-						}
-					}
-				}
-			}
+			$this->RIFFcommentsParse($thisfile_riff_WAVE['INFO'], $thisfile_riff['comments']);
 		}
 
 		if (empty($thisfile_audio['encoder']) && !empty($ThisFileInfo['mpeg']['audio']['LAME']['short_version'])) {
@@ -1055,6 +1005,60 @@
 	}
 
 
+	function RIFFcommentsParse(&$RIFFinfoArray, &$CommentsTargetArray) {
+		$RIFFinfoKeyLookup = array(
+			'IARL'=>'archivallocation',
+			'IART'=>'artist',
+			'ICDS'=>'costumedesigner',
+			'ICMS'=>'commissionedby',
+			'ICMT'=>'comment',
+			'ICNT'=>'country',
+			'ICOP'=>'copyright',
+			'ICRD'=>'creationdate',
+			'IDIM'=>'dimensions',
+			'IDIT'=>'digitizationdate',
+			'IDPI'=>'resolution',
+			'IDST'=>'distributor',
+			'IEDT'=>'editor',
+			'IENG'=>'engineers',
+			'IFRM'=>'accountofparts',
+			'IGNR'=>'genre',
+			'IKEY'=>'keywords',
+			'ILGT'=>'lightness',
+			'ILNG'=>'language',
+			'IMED'=>'orignalmedium',
+			'IMUS'=>'composer',
+			'INAM'=>'title',
+			'IPDS'=>'productiondesigner',
+			'IPLT'=>'palette',
+			'IPRD'=>'product',
+			'IPRO'=>'producer',
+			'IPRT'=>'part',
+			'IRTD'=>'rating',
+			'ISBJ'=>'subject',
+			'ISFT'=>'software',
+			'ISGN'=>'secondarygenre',
+			'ISHP'=>'sharpness',
+			'ISRC'=>'sourcesupplier',
+			'ISRF'=>'digitizationsource',
+			'ISTD'=>'productionstudio',
+			'ISTR'=>'starring',
+			'ITCH'=>'encoded_by',
+			'IWEB'=>'url',
+			'IWRI'=>'writer'
+		);
+		foreach ($RIFFinfoKeyLookup as $key => $value) {
+			if (isset($RIFFinfoArray[$key])) {
+				foreach ($RIFFinfoArray[$key] as $commentid => $commentdata) {
+					if (trim($commentdata['data']) != '') {
+						@$CommentsTargetArray[$value][] = trim($commentdata['data']);
+					}
+				}
+			}
+		}
+		return true;
+	}
+
 	function ParseRIFF(&$fd, $startoffset, $maxoffset, &$ThisFileInfo) {
 
 		$maxoffset = min($maxoffset, $ThisFileInfo['avdataend']);
@@ -1065,14 +1069,22 @@
 
 		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.';
+				break;
+			}
 			if (($chunksize % 2) != 0) {
 				// all structures are packed on word boundaries
 				$chunksize++;
 			}
 
 			switch ($chunkname) {
-
 				case 'LIST':
 					$listname = fread($fd, 4);
 					switch ($listname) {
@@ -1149,7 +1161,11 @@
 							if (!isset($RIFFchunk[$listname])) {
 								$RIFFchunk[$listname] = array();
 							}
-							$RIFFchunk[$listname] = array_merge_recursive($RIFFchunk[$listname], getid3_riff::ParseRIFF($fd, ftell($fd), ftell($fd) + $chunksize - 4, $ThisFileInfo));
+							$LISTchunkParent    = $listname;
+							$LISTchunkMaxOffset = ftell($fd) - 4 + $chunksize;
+							if ($parsedChunk = getid3_riff::ParseRIFF($fd, ftell($fd), ftell($fd) + $chunksize - 4, $ThisFileInfo)) {
+								$RIFFchunk[$listname] = array_merge_recursive($RIFFchunk[$listname], $parsedChunk);
+							}
 							break;
 					}
 					break;
@@ -1166,7 +1182,7 @@
 							$ThisFileInfo['avdataoffset'] = ftell($fd);
 							$ThisFileInfo['avdataend']    = $ThisFileInfo['avdataoffset'] + $chunksize;
 
-							$RIFFdataChunkContentsTest = fread($fd, 32);
+							$RIFFdataChunkContentsTest = fread($fd, 36);
 
 							if ((strlen($RIFFdataChunkContentsTest) > 0) && preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', substr($RIFFdataChunkContentsTest, 0, 4))) {
 
@@ -1204,6 +1220,7 @@
 								$GETID3_ERRORARRAY = &$ThisFileInfo['warning'];
 								if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, false)) {
 
+									// ok to use tmpfile here - only 56 bytes
 									if ($fd_temp = tmpfile()) {
 
 										for ($i = 0; $i < 28; $i += 2) {
@@ -1239,7 +1256,7 @@
 								// This is WavPack data
 								$ThisFileInfo['wavpack']['offset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
 								$ThisFileInfo['wavpack']['size']   = getid3_lib::LittleEndian2Int(substr($RIFFdataChunkContentsTest, 4, 4));
-								getid3_riff::RIFFparseWavPackHeader(substr($RIFFdataChunkContentsTest, 8, 22), $ThisFileInfo);
+								getid3_riff::RIFFparseWavPackHeader(substr($RIFFdataChunkContentsTest, 8, 28), $ThisFileInfo);
 
 							} else {
 
@@ -1260,8 +1277,20 @@
 							break;
 
 						default:
-							// read data in if smaller than 2kB
-							if ($chunksize < 2048) {
+							if (!empty($LISTchunkParent) && (($RIFFchunk[$chunkname][$thisindex]['offset'] + $RIFFchunk[$chunkname][$thisindex]['size']) <= $LISTchunkMaxOffset)) {
+								$RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['offset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
+								$RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['size']   = $RIFFchunk[$chunkname][$thisindex]['size'];
+								unset($RIFFchunk[$chunkname][$thisindex]['offset']);
+								unset($RIFFchunk[$chunkname][$thisindex]['size']);
+								if (isset($RIFFchunk[$chunkname][$thisindex]) && empty($RIFFchunk[$chunkname][$thisindex])) {
+									unset($RIFFchunk[$chunkname][$thisindex]);
+								}
+								if (isset($RIFFchunk[$chunkname]) && empty($RIFFchunk[$chunkname])) {
+									unset($RIFFchunk[$chunkname]);
+								}
+								$RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['data'] = fread($fd, $chunksize);
+							} elseif ($chunksize < 2048) {
+								// only read data in if smaller than 2kB
 								$RIFFchunk[$chunkname][$thisindex]['data'] = fread($fd, $chunksize);
 							} else {
 								fseek($fd, $chunksize, SEEK_CUR);
@@ -1280,29 +1309,28 @@
 
 	function ParseRIFFdata(&$RIFFdata, &$ThisFileInfo) {
 		if ($RIFFdata) {
-			if ($fp_temp = tmpfile()) {
 
-				$RIFFdataLength = strlen($RIFFdata);
-				$NewLengthString = getid3_lib::LittleEndian2String($RIFFdataLength, 4);
-				for ($i = 0; $i < 4; $i++) {
-					$RIFFdata{$i + 4} = $NewLengthString{$i};
-				}
-				fwrite($fp_temp, $RIFFdata);
-				$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);
-				$ThisFileInfo['riff']     = $dummy['riff'];
-				$ThisFileInfo['warning']  = $dummy['warning'];
-				$ThisFileInfo['error']    = $dummy['error'];
-				$ThisFileInfo['tags']     = $dummy['tags'];
-				$ThisFileInfo['comments'] = $dummy['comments'];
-				fclose($fp_temp);
-				return true;
+		    $tempfile = tempnam('*', 'getID3');
+            $fp_temp  = fopen($tempfile, "wb");
+			$RIFFdataLength = strlen($RIFFdata);
+			$NewLengthString = getid3_lib::LittleEndian2String($RIFFdataLength, 4);
+			for ($i = 0; $i < 4; $i++) {
+				$RIFFdata{$i + 4} = $NewLengthString{$i};
+			}
+			fwrite($fp_temp, $RIFFdata);
+			fclose($fp_temp);
 
-			} else {
-
-				$ThisFileInfo['error'][] = 'Error calling tmpfile() to parse OptimFROG RIFF header';
-
-			}
+			$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);
+			$ThisFileInfo['riff']     = $dummy['riff'];
+			$ThisFileInfo['warning']  = $dummy['warning'];
+			$ThisFileInfo['error']    = $dummy['error'];
+			$ThisFileInfo['tags']     = $dummy['tags'];
+			$ThisFileInfo['comments'] = $dummy['comments'];
+			fclose($fp_temp);
+			unlink($tempfile);
+			return true;
 		}
 		return false;
 	}
@@ -1360,7 +1388,7 @@
 			$thisfile_wavpack['crc2']          = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 16, 4));
 			$thisfile_wavpack['extension']     =                              substr($WavPackChunkData, 20, 4);
 			$thisfile_wavpack['extra_bc']      = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 24, 1));
-			for ($i = 0; $i < 3; $i++) {
+			for ($i = 0; $i <= 2; $i++) {
 				$thisfile_wavpack['extras'][]  = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 25 + $i, 1));
 			}
 
@@ -1600,7 +1628,7 @@
 			AYUV	4:4:4 YUV (AYUV)
 			AZPR	Quicktime Apple Video (AZPR)
 			BGR 	Raw RGB32
-			BLZ0	FFmpeg MPEG-4
+			BLZ0	Blizzard DivX MPEG-4
 			BTVC	Conexant Composite Video
 			BINK	RAD Game Tools Bink Video
 			BT20	Conexant Prosumer Video

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.swf.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.swf.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio-video.swf.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_swf
 {
 
@@ -27,9 +25,10 @@
 
 		fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
 
+//echo 'reading '.($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']).' bytes<br>';
 		$SWFfileData = fread($fd, $ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']); // 8 + 2 + 2 + max(9) bytes NOT including Frame_Size RECT data
 
-		$ThisFileInfo['swf']['header']['signature']   = substr($SWFfileData, 0, 3);
+		$ThisFileInfo['swf']['header']['signature']  = substr($SWFfileData, 0, 3);
 		switch ($ThisFileInfo['swf']['header']['signature']) {
 			case 'FWS':
 				$ThisFileInfo['swf']['header']['compressed'] = false;
@@ -46,17 +45,28 @@
 				return false;
 				break;
 		}
-		$ThisFileInfo['swf']['header']['version']      = getid3_lib::LittleEndian2Int(substr($SWFfileData, 3, 1));
-		$ThisFileInfo['swf']['header']['length']       = getid3_lib::LittleEndian2Int(substr($SWFfileData, 4, 4));
+		$ThisFileInfo['swf']['header']['version'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 3, 1));
+		$ThisFileInfo['swf']['header']['length']  = getid3_lib::LittleEndian2Int(substr($SWFfileData, 4, 4));
 
+//echo '1<br>';
 		if ($ThisFileInfo['swf']['header']['compressed']) {
 
-			if ($UncompressedFileData = @gzuncompress(substr($SWFfileData, 8))) {
+//echo '2<br>';
+//			$foo = substr($SWFfileData, 8, 4096);
+//			echo '['.strlen($foo).']<br>';
+//			$fee = gzuncompress($foo);
+//			echo '('.strlen($fee).')<br>';
+//return false;
+//echo '<br>time: '.time().'<br>';
+//return false;
+			if ($UncompressedFileData = gzuncompress(substr($SWFfileData, 8))) {
 
+//echo '3<br>';
 				$SWFfileData = substr($SWFfileData, 0, 8).$UncompressedFileData;
 
 			} else {
 
+//echo '4<br>';
 				$ThisFileInfo['error'][] = 'Error decompressing compressed SWF data';
 				return false;
 
@@ -85,8 +95,8 @@
 		$ThisFileInfo['swf']['header']['frame_count'] = getid3_lib::LittleEndian2Int(substr($SWFfileData, 10 + $FrameSizeDataLength, 2));
 
 		$ThisFileInfo['video']['frame_rate']         = $ThisFileInfo['swf']['header']['frame_rate'];
-		$ThisFileInfo['video']['resolution_x']       = round($ThisFileInfo['swf']['header']['frame_width']  / 20);
-		$ThisFileInfo['video']['resolution_y']       = round($ThisFileInfo['swf']['header']['frame_height'] / 20);
+		$ThisFileInfo['video']['resolution_x']       = intval(round($ThisFileInfo['swf']['header']['frame_width']  / 20));
+		$ThisFileInfo['video']['resolution_y']       = intval(round($ThisFileInfo['swf']['header']['frame_height'] / 20));
 		$ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
 
 		if (($ThisFileInfo['swf']['header']['frame_count'] > 0) && ($ThisFileInfo['swf']['header']['frame_rate'] > 0)) {

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.aac.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.aac.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.aac.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_aac
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.ac3.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.ac3.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.ac3.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_ac3
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.au.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.au.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.au.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_au
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.avr.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.avr.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.avr.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_avr
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.bonk.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.bonk.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.bonk.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_bonk
 {
 	function getid3_bonk(&$fd, &$ThisFileInfo) {
@@ -125,7 +123,6 @@
 				$thisfile_bonk_BONK['downsampling_ratio'] =        getid3_lib::LittleEndian2Int(substr($BonkData, 19, 1));
 				$thisfile_bonk_BONK['samples_per_packet'] =        getid3_lib::LittleEndian2Int(substr($BonkData, 20, 2));
 
-
 				$ThisFileInfo['avdataoffset'] = $thisfile_bonk_BONK['offset'] + 5 + 17;
 				$ThisFileInfo['avdataend']    = $thisfile_bonk_BONK['offset'] + $thisfile_bonk_BONK['size'];
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.flac.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.flac.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.flac.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -15,9 +15,7 @@
 
 
 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE__, true);
-/**
- * \ingroup getid3
- */
+
 class getid3_flac
 {
 
@@ -33,7 +31,7 @@
 		$ThisFileInfo['fileformat']            = 'flac';
 		$ThisFileInfo['audio']['dataformat']   = 'flac';
 		$ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
-		$ThisFileInfo['audio']['lossless']     = false;
+		$ThisFileInfo['audio']['lossless']     = true;
 
 		return getid3_flac::FLACparseMETAdata($fd, $ThisFileInfo);
 	}
@@ -49,18 +47,26 @@
 			$METAdataBlockLength          = getid3_lib::BigEndian2Int(substr($METAdataBlockHeader, 1, 3));
 			$METAdataBlockTypeText        = getid3_flac::FLACmetaBlockTypeLookup($METAdataBlockType);
 
-			$ThisFileInfo['flac']["$METAdataBlockTypeText"]['raw']['offset']          = $METAdataBlockOffset;
-			$ThisFileInfo['flac']["$METAdataBlockTypeText"]['raw']['last_meta_block'] = $METAdataLastBlockFlag;
-			$ThisFileInfo['flac']["$METAdataBlockTypeText"]['raw']['block_type']      = $METAdataBlockType;
-			$ThisFileInfo['flac']["$METAdataBlockTypeText"]['raw']['block_type_text'] = $METAdataBlockTypeText;
-			$ThisFileInfo['flac']["$METAdataBlockTypeText"]['raw']['block_length']    = $METAdataBlockLength;
-			$ThisFileInfo['flac']["$METAdataBlockTypeText"]['raw']['block_data']      = fread($fd, $METAdataBlockLength);
+			if ($METAdataBlockLength <= 0) {
+				$ThisFileInfo['error'][] = 'corrupt or invalid METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$METAdataBlockType.') at offset '.$METAdataBlockOffset;
+				break;
+			}
+
+			$ThisFileInfo['flac'][$METAdataBlockTypeText]['raw'] = array();
+			$ThisFileInfo_flac_METAdataBlockTypeText_raw = &$ThisFileInfo['flac'][$METAdataBlockTypeText]['raw'];
+
+			$ThisFileInfo_flac_METAdataBlockTypeText_raw['offset']          = $METAdataBlockOffset;
+			$ThisFileInfo_flac_METAdataBlockTypeText_raw['last_meta_block'] = $METAdataLastBlockFlag;
+			$ThisFileInfo_flac_METAdataBlockTypeText_raw['block_type']      = $METAdataBlockType;
+			$ThisFileInfo_flac_METAdataBlockTypeText_raw['block_type_text'] = $METAdataBlockTypeText;
+			$ThisFileInfo_flac_METAdataBlockTypeText_raw['block_length']    = $METAdataBlockLength;
+			$ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data']      = fread($fd, $METAdataBlockLength);
 			$ThisFileInfo['avdataoffset'] = ftell($fd);
 
 			switch ($METAdataBlockTypeText) {
 
 				case 'STREAMINFO':
-					if (!getid3_flac::FLACparseSTREAMINFO($ThisFileInfo['flac']["$METAdataBlockTypeText"]['raw']['block_data'], $ThisFileInfo)) {
+					if (!getid3_flac::FLACparseSTREAMINFO($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'], $ThisFileInfo)) {
 						return false;
 					}
 					break;
@@ -70,13 +76,13 @@
 					break;
 
 				case 'APPLICATION':
-					if (!getid3_flac::FLACparseAPPLICATION($ThisFileInfo['flac']["$METAdataBlockTypeText"]['raw']['block_data'], $ThisFileInfo)) {
+					if (!getid3_flac::FLACparseAPPLICATION($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'], $ThisFileInfo)) {
 						return false;
 					}
 					break;
 
 				case 'SEEKTABLE':
-					if (!getid3_flac::FLACparseSEEKTABLE($ThisFileInfo['flac']["$METAdataBlockTypeText"]['raw']['block_data'], $ThisFileInfo)) {
+					if (!getid3_flac::FLACparseSEEKTABLE($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'], $ThisFileInfo)) {
 						return false;
 					}
 					break;
@@ -89,7 +95,7 @@
 					break;
 
 				case 'CUESHEET':
-					if (!getid3_flac::FLACparseCUESHEET($ThisFileInfo['flac']["$METAdataBlockTypeText"]['raw']['block_data'], $ThisFileInfo)) {
+					if (!getid3_flac::FLACparseCUESHEET($ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'], $ThisFileInfo)) {
 						return false;
 					}
 					break;
@@ -124,7 +130,7 @@
 				$ThisFileInfo['md5_data_source'] = '';
 				$md5 = $ThisFileInfo['flac']['STREAMINFO']['audio_signature'];
 				for ($i = 0; $i < strlen($md5); $i++) {
-					$ThisFileInfo['md5_data_source'] .= str_pad(dechex(ord($md5[$i])), 2, '00', STR_PAD_LEFT);
+					$ThisFileInfo['md5_data_source'] .= str_pad(dechex(ord($md5{$i})), 2, '00', STR_PAD_LEFT);
 				}
 				if (!preg_match('/^[0-9a-f]{32}$/', $ThisFileInfo['md5_data_source'])) {
 					unset($ThisFileInfo['md5_data_source']);
@@ -287,7 +293,7 @@
 			for ($index = 0; $index < $ThisFileInfo['flac']['CUESHEET']['tracks'][$TrackNumber]['index_points']; $index++) {
 				$IndexSampleOffset = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 8));
 				$offset += 8;
-				$IndexNumber       = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 8));
+				$IndexNumber       = getid3_lib::BigEndian2Int(substr($METAdataBlockData, $offset, 1));
 				$offset += 1;
 
 				$offset += 3; // reserved

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.la.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.la.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.la.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -15,9 +15,6 @@
 
 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
 
-/**
- * \ingroup getid3
- */
 class getid3_la
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.lpac.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.lpac.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.lpac.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -15,9 +15,6 @@
 
 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
 
-/**
- * \ingroup getid3
- */
 class getid3_lpac
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.midi.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.midi.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.midi.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_midi
 {
 
@@ -74,10 +72,10 @@
 		}
 
 		if ($scanwholefile) { // this can take quite a long time, so have the option to bypass it if speed is very important
-			$thisfile_midi['totalticks'] = 0;
-			$ThisFileInfo['playtime_seconds']   = 0;
-			$CurrentMicroSecondsPerBeat = 500000; // 120 beats per minute;  60,000,000 microseconds per minute -> 500,000 microseconds per beat
-			$CurrentBeatsPerMinute      = 120;    // 120 beats per minute;  60,000,000 microseconds per minute -> 500,000 microseconds per beat
+			$thisfile_midi['totalticks']      = 0;
+			$ThisFileInfo['playtime_seconds'] = 0;
+			$CurrentMicroSecondsPerBeat       = 500000; // 120 beats per minute;  60,000,000 microseconds per minute -> 500,000 microseconds per beat
+			$CurrentBeatsPerMinute            = 120;    // 120 beats per minute;  60,000,000 microseconds per minute -> 500,000 microseconds per beat
 
 			foreach ($trackdataarray as $tracknumber => $trackdata) {
 
@@ -92,7 +90,7 @@
 						$eventid = count($MIDIevents[$tracknumber]);
 					}
 					$deltatime = 0;
-					for ($i=0;$i<4;$i++) {
+					for ($i = 0; $i < 4; $i++) {
 						$deltatimebyte = ord(substr($trackdata, $eventsoffset++, 1));
 						$deltatime = ($deltatime << 7) + ($deltatimebyte & 0x7F);
 						if ($deltatimebyte & 0x80) {
@@ -115,27 +113,27 @@
 					}
 					$MIDIevents[$tracknumber][$eventid]['eventid']   = $LastIssuedMIDIcommand;
 					$MIDIevents[$tracknumber][$eventid]['channel']   = $LastIssuedMIDIchannel;
-					if ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0x8) { // Note off (key is released)
+					if ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0x08) { // Note off (key is released)
 
 						$notenumber = ord(substr($trackdata, $eventsoffset++, 1));
 						$velocity   = ord(substr($trackdata, $eventsoffset++, 1));
 
-					} elseif ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0x9) { // Note on (key is pressed)
+					} elseif ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0x09) { // Note on (key is pressed)
 
 						$notenumber = ord(substr($trackdata, $eventsoffset++, 1));
 						$velocity   = ord(substr($trackdata, $eventsoffset++, 1));
 
-					} elseif ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0xA) { // Key after-touch
+					} elseif ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0x0A) { // Key after-touch
 
 						$notenumber = ord(substr($trackdata, $eventsoffset++, 1));
 						$velocity   = ord(substr($trackdata, $eventsoffset++, 1));
 
-					} elseif ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0xB) { // Control Change
+					} elseif ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0x0B) { // Control Change
 
 						$controllernum = ord(substr($trackdata, $eventsoffset++, 1));
 						$newvalue      = ord(substr($trackdata, $eventsoffset++, 1));
 
-					} elseif ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0xC) { // Program (patch) change
+					} elseif ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0x0C) { // Program (patch) change
 
 						$newprogramnum = ord(substr($trackdata, $eventsoffset++, 1));
 
@@ -146,17 +144,17 @@
 							$thisfile_midi_raw['track'][$tracknumber]['instrument'] = $this->GeneralMIDIinstrumentLookup($newprogramnum);
 						}
 
-					} elseif ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0xD) { // Channel after-touch
+					} elseif ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0x0D) { // Channel after-touch
 
 						$channelnumber = ord(substr($trackdata, $eventsoffset++, 1));
 
-					} elseif ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0xE) { // Pitch wheel change (2000H is normal or no change)
+					} elseif ($MIDIevents[$tracknumber][$eventid]['eventid'] == 0x0E) { // Pitch wheel change (2000H is normal or no change)
 
 						$changeLSB = ord(substr($trackdata, $eventsoffset++, 1));
 						$changeMSB = ord(substr($trackdata, $eventsoffset++, 1));
 						$pitchwheelchange = (($changeMSB & 0x7F) << 7) & ($changeLSB & 0x7F);
 
-					} elseif (($MIDIevents[$tracknumber][$eventid]['eventid'] == 0xF) && ($MIDIevents[$tracknumber][$eventid]['channel'] == 0xF)) {
+					} elseif (($MIDIevents[$tracknumber][$eventid]['eventid'] == 0x0F) && ($MIDIevents[$tracknumber][$eventid]['channel'] == 0x0F)) {
 
 						$METAeventCommand = ord(substr($trackdata, $eventsoffset++, 1));
 						$METAeventLength  = ord(substr($trackdata, $eventsoffset++, 1));
@@ -190,13 +188,13 @@
 								//$thisfile_midi_raw['events'][$tracknumber][$eventid]['instrument'] = $text_instrument;
 								break;
 
-							case 0x05: // Text: lyric
-								$text_lyric  = substr($METAeventData, 0, $METAeventLength);
-								//$thisfile_midi_raw['events'][$tracknumber][$eventid]['lyric'] = $text_lyric;
-								if (!isset($thisfile_midi['lyric'])) {
-									$thisfile_midi['lyric'] = '';
+							case 0x05: // Text: lyrics
+								$text_lyrics  = substr($METAeventData, 0, $METAeventLength);
+								//$thisfile_midi_raw['events'][$tracknumber][$eventid]['lyrics'] = $text_lyrics;
+								if (!isset($thisfile_midi['lyrics'])) {
+									$thisfile_midi['lyrics'] = '';
 								}
-								$thisfile_midi['lyric'] .= $text_lyric."\n";
+								$thisfile_midi['lyrics'] .= $text_lyrics."\n";
 								break;
 
 							case 0x06: // Text: marker
@@ -220,7 +218,7 @@
 									return false;
 								}
 								$thisfile_midi_raw['events'][$tracknumber][$CumulativeDeltaTime]['us_qnote'] = $CurrentMicroSecondsPerBeat;
-								$CurrentBeatsPerMinute      = (1000000 / $CurrentMicroSecondsPerBeat) * 60;
+								$CurrentBeatsPerMinute = (1000000 / $CurrentMicroSecondsPerBeat) * 60;
 								$MicroSecondsPerQuarterNoteAfter[$CumulativeDeltaTime] = $CurrentMicroSecondsPerBeat;
 								$TicksAtCurrentBPM = 0;
 								break;
@@ -265,16 +263,23 @@
 
 					} else {
 
-						$ThisFileInfo['warning'][] = 'Unhandled MIDI Event ID: '.$MIDIevents[$tracknumber][$eventid]['eventid'];
+						$ThisFileInfo['warning'][] = 'Unhandled MIDI Event ID: '.$MIDIevents[$tracknumber][$eventid]['eventid'].' + Channel ID: '.$MIDIevents[$tracknumber][$eventid]['channel'];
 
 					}
 				}
-				if ($tracknumber > 0) {
+				if (($tracknumber > 0) || (count($trackdataarray) == 1)) {
 					$thisfile_midi['totalticks'] = max($thisfile_midi['totalticks'], $CumulativeDeltaTime);
 				}
 			}
-			$previoustickoffset = 0;
+			$previoustickoffset = null;
+
+			ksort($MicroSecondsPerQuarterNoteAfter);
 			foreach ($MicroSecondsPerQuarterNoteAfter as $tickoffset => $microsecondsperbeat) {
+				if (is_null($previoustickoffset)) {
+					$prevmicrosecondsperbeat = $microsecondsperbeat;
+					$previoustickoffset = $tickoffset;
+					continue;
+				}
 				if ($thisfile_midi['totalticks'] > $tickoffset) {
 
 					if ($thisfile_midi_raw['ticksperqnote'] == 0) {
@@ -282,7 +287,9 @@
 						return false;
 					}
 
-					$ThisFileInfo['playtime_seconds'] += (($tickoffset - $previoustickoffset) / $thisfile_midi_raw['ticksperqnote']) * ($microsecondsperbeat / 1000000);
+					$ThisFileInfo['playtime_seconds'] += (($tickoffset - $previoustickoffset) / $thisfile_midi_raw['ticksperqnote']) * ($prevmicrosecondsperbeat / 1000000);
+
+					$prevmicrosecondsperbeat = $microsecondsperbeat;
 					$previoustickoffset = $tickoffset;
 				}
 			}
@@ -298,6 +305,14 @@
 			}
 		}
 
+		if ($ThisFileInfo['playtime_seconds'] > 0) {
+			$ThisFileInfo['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
+		}
+
+		if (!empty($thisfile_midi['lyrics'])) {
+			$thisfile_midi['comments']['lyrics'][] = $thisfile_midi['lyrics'];
+		}
+
 		return true;
 	}
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.mod.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.mod.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.mod.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_mod
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.monkey.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.monkey.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.monkey.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_monkey
 {
 
@@ -33,7 +31,7 @@
 		$thisfile_monkeysaudio_raw            = &$thisfile_monkeysaudio['raw'];
 
 		fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
-		$MACheaderData = fread($fd, 40);
+		$MACheaderData = fread($fd, 74);
 
 		$thisfile_monkeysaudio_raw['magic'] = substr($MACheaderData, 0, 4);
 		if ($thisfile_monkeysaudio_raw['magic'] != 'MAC ') {
@@ -41,18 +39,59 @@
 			unset($ThisFileInfo['fileformat']);
 			return false;
 		}
-		$thisfile_monkeysaudio_raw['nVersion']             = getid3_lib::LittleEndian2Int(substr($MACheaderData, 4, 2));
-		$thisfile_monkeysaudio_raw['nCompressionLevel']    = getid3_lib::LittleEndian2Int(substr($MACheaderData, 6, 2));
-		$thisfile_monkeysaudio_raw['nFormatFlags']         = getid3_lib::LittleEndian2Int(substr($MACheaderData, 8, 2));
-		$thisfile_monkeysaudio_raw['nChannels']            = getid3_lib::LittleEndian2Int(substr($MACheaderData, 10, 2));
-		$thisfile_monkeysaudio_raw['nSampleRate']          = getid3_lib::LittleEndian2Int(substr($MACheaderData, 12, 4));
-		$thisfile_monkeysaudio_raw['nWAVHeaderBytes']      = getid3_lib::LittleEndian2Int(substr($MACheaderData, 16, 4));
-		$thisfile_monkeysaudio_raw['nWAVTerminatingBytes'] = getid3_lib::LittleEndian2Int(substr($MACheaderData, 20, 4));
-		$thisfile_monkeysaudio_raw['nTotalFrames']         = getid3_lib::LittleEndian2Int(substr($MACheaderData, 24, 4));
-		$thisfile_monkeysaudio_raw['nFinalFrameSamples']   = getid3_lib::LittleEndian2Int(substr($MACheaderData, 28, 4));
-		$thisfile_monkeysaudio_raw['nPeakLevel']           = getid3_lib::LittleEndian2Int(substr($MACheaderData, 32, 4));
-		$thisfile_monkeysaudio_raw['nSeekElements']        = getid3_lib::LittleEndian2Int(substr($MACheaderData, 38, 2));
+		$thisfile_monkeysaudio_raw['nVersion']             = getid3_lib::LittleEndian2Int(substr($MACheaderData, 4, 2)); // appears to be uint32 in 3.98+
 
+		if ($thisfile_monkeysaudio_raw['nVersion'] < 3980) {
+			$thisfile_monkeysaudio_raw['nCompressionLevel']    = getid3_lib::LittleEndian2Int(substr($MACheaderData, 6, 2));
+			$thisfile_monkeysaudio_raw['nFormatFlags']         = getid3_lib::LittleEndian2Int(substr($MACheaderData, 8, 2));
+			$thisfile_monkeysaudio_raw['nChannels']            = getid3_lib::LittleEndian2Int(substr($MACheaderData, 10, 2));
+			$thisfile_monkeysaudio_raw['nSampleRate']          = getid3_lib::LittleEndian2Int(substr($MACheaderData, 12, 4));
+			$thisfile_monkeysaudio_raw['nHeaderDataBytes']     = getid3_lib::LittleEndian2Int(substr($MACheaderData, 16, 4));
+			$thisfile_monkeysaudio_raw['nWAVTerminatingBytes'] = getid3_lib::LittleEndian2Int(substr($MACheaderData, 20, 4));
+			$thisfile_monkeysaudio_raw['nTotalFrames']         = getid3_lib::LittleEndian2Int(substr($MACheaderData, 24, 4));
+			$thisfile_monkeysaudio_raw['nFinalFrameSamples']   = getid3_lib::LittleEndian2Int(substr($MACheaderData, 28, 4));
+			$thisfile_monkeysaudio_raw['nPeakLevel']           = getid3_lib::LittleEndian2Int(substr($MACheaderData, 32, 4));
+			$thisfile_monkeysaudio_raw['nSeekElements']        = getid3_lib::LittleEndian2Int(substr($MACheaderData, 38, 2));
+			$offset = 8;
+		} else {
+			$offset = 8;
+			// APE_DESCRIPTOR
+			$thisfile_monkeysaudio_raw['nDescriptorBytes']       = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset,  4));
+			$offset += 4;
+			$thisfile_monkeysaudio_raw['nHeaderBytes']           = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset,  4));
+			$offset += 4;
+			$thisfile_monkeysaudio_raw['nSeekTableBytes']        = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset,  4));
+			$offset += 4;
+			$thisfile_monkeysaudio_raw['nHeaderDataBytes']       = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset,  4));
+			$offset += 4;
+			$thisfile_monkeysaudio_raw['nAPEFrameDataBytes']     = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset,  4));
+			$offset += 4;
+			$thisfile_monkeysaudio_raw['nAPEFrameDataBytesHigh'] = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset,  4));
+			$offset += 4;
+			$thisfile_monkeysaudio_raw['nTerminatingDataBytes']  = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset,  4));
+			$offset += 4;
+			$thisfile_monkeysaudio_raw['cFileMD5']               =                              substr($MACheaderData, $offset, 16);
+			$offset += 16;
+
+			// APE_HEADER
+			$thisfile_monkeysaudio_raw['nCompressionLevel']    = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset, 2));
+			$offset += 2;
+			$thisfile_monkeysaudio_raw['nFormatFlags']         = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset, 2));
+			$offset += 2;
+			$thisfile_monkeysaudio_raw['nBlocksPerFrame']      = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset, 4));
+			$offset += 4;
+			$thisfile_monkeysaudio_raw['nFinalFrameBlocks']    = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset, 4));
+			$offset += 4;
+			$thisfile_monkeysaudio_raw['nTotalFrames']         = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset, 4));
+			$offset += 4;
+			$thisfile_monkeysaudio_raw['nBitsPerSample']       = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset, 2));
+			$offset += 2;
+			$thisfile_monkeysaudio_raw['nChannels']            = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset, 2));
+			$offset += 2;
+			$thisfile_monkeysaudio_raw['nSampleRate']          = getid3_lib::LittleEndian2Int(substr($MACheaderData, $offset, 4));
+			$offset += 4;
+		}
+
 		$thisfile_monkeysaudio['flags']['8-bit']         = (bool) ($thisfile_monkeysaudio_raw['nFormatFlags'] & 0x0001);
 		$thisfile_monkeysaudio['flags']['crc-32']        = (bool) ($thisfile_monkeysaudio_raw['nFormatFlags'] & 0x0002);
 		$thisfile_monkeysaudio['flags']['peak_level']    = (bool) ($thisfile_monkeysaudio_raw['nFormatFlags'] & 0x0004);
@@ -61,12 +100,10 @@
 		$thisfile_monkeysaudio['flags']['no_wav_header'] = (bool) ($thisfile_monkeysaudio_raw['nFormatFlags'] & 0x0020);
 		$thisfile_monkeysaudio['version']                = $thisfile_monkeysaudio_raw['nVersion'] / 1000;
 		$thisfile_monkeysaudio['compression']            = $this->MonkeyCompressionLevelNameLookup($thisfile_monkeysaudio_raw['nCompressionLevel']);
-		$thisfile_monkeysaudio['samples_per_frame']      = $this->MonkeySamplesPerFrame($thisfile_monkeysaudio_raw['nVersion'], $thisfile_monkeysaudio_raw['nCompressionLevel']);
+		if ($thisfile_monkeysaudio_raw['nVersion'] < 3980) {
+			$thisfile_monkeysaudio['samples_per_frame']      = $this->MonkeySamplesPerFrame($thisfile_monkeysaudio_raw['nVersion'], $thisfile_monkeysaudio_raw['nCompressionLevel']);
+		}
 		$thisfile_monkeysaudio['bits_per_sample']        = ($thisfile_monkeysaudio['flags']['24-bit'] ? 24 : ($thisfile_monkeysaudio['flags']['8-bit'] ? 8 : 16));
-		if ($thisfile_monkeysaudio['bits_per_sample'] == 0) {
-			$ThisFileInfo['error'][] = 'Corrupt MAC file: bits_per_sample == zero';
-			return false;
-		}
 		$thisfile_monkeysaudio['channels']               = $thisfile_monkeysaudio_raw['nChannels'];
 		$ThisFileInfo['audio']['channels']               = $thisfile_monkeysaudio['channels'];
 		$thisfile_monkeysaudio['sample_rate']            = $thisfile_monkeysaudio_raw['nSampleRate'];
@@ -75,10 +112,15 @@
 			return false;
 		}
 		$ThisFileInfo['audio']['sample_rate']            = $thisfile_monkeysaudio['sample_rate'];
-		$thisfile_monkeysaudio['peak_level']             = $thisfile_monkeysaudio_raw['nPeakLevel'];
-		$thisfile_monkeysaudio['peak_ratio']             = $thisfile_monkeysaudio['peak_level'] / pow(2, $thisfile_monkeysaudio['bits_per_sample'] - 1);
-		$thisfile_monkeysaudio['frames']                 = $thisfile_monkeysaudio_raw['nTotalFrames'];
-		$thisfile_monkeysaudio['samples']                = (($thisfile_monkeysaudio['frames'] - 1) * $thisfile_monkeysaudio['samples_per_frame']) + $thisfile_monkeysaudio_raw['nFinalFrameSamples'];
+		if ($thisfile_monkeysaudio['flags']['peak_level']) {
+			$thisfile_monkeysaudio['peak_level']         = $thisfile_monkeysaudio_raw['nPeakLevel'];
+			$thisfile_monkeysaudio['peak_ratio']         = $thisfile_monkeysaudio['peak_level'] / pow(2, $thisfile_monkeysaudio['bits_per_sample'] - 1);
+		}
+		if ($thisfile_monkeysaudio_raw['nVersion'] >= 3980) {
+			$thisfile_monkeysaudio['samples']            = (($thisfile_monkeysaudio_raw['nTotalFrames'] - 1) * $thisfile_monkeysaudio_raw['nBlocksPerFrame']) + $thisfile_monkeysaudio_raw['nFinalFrameBlocks'];
+		} else {
+			$thisfile_monkeysaudio['samples']            = (($thisfile_monkeysaudio_raw['nTotalFrames'] - 1) * $thisfile_monkeysaudio['samples_per_frame']) + $thisfile_monkeysaudio_raw['nFinalFrameSamples'];
+		}
 		$thisfile_monkeysaudio['playtime']               = $thisfile_monkeysaudio['samples'] / $thisfile_monkeysaudio['sample_rate'];
 		if ($thisfile_monkeysaudio['playtime'] == 0) {
 			$ThisFileInfo['error'][] = 'Corrupt MAC file: playtime == zero';
@@ -91,13 +133,39 @@
 			$ThisFileInfo['error'][] = 'Corrupt MAC file: uncompressed_size == zero';
 			return false;
 		}
-		$thisfile_monkeysaudio['compression_ratio']      = $thisfile_monkeysaudio['compressed_size'] / ($thisfile_monkeysaudio['uncompressed_size'] + $thisfile_monkeysaudio_raw['nWAVHeaderBytes']);
+		$thisfile_monkeysaudio['compression_ratio']      = $thisfile_monkeysaudio['compressed_size'] / ($thisfile_monkeysaudio['uncompressed_size'] + $thisfile_monkeysaudio_raw['nHeaderDataBytes']);
 		$thisfile_monkeysaudio['bitrate']                = (($thisfile_monkeysaudio['samples'] * $thisfile_monkeysaudio['channels'] * $thisfile_monkeysaudio['bits_per_sample']) / $thisfile_monkeysaudio['playtime']) * $thisfile_monkeysaudio['compression_ratio'];
 		$ThisFileInfo['audio']['bitrate']                = $thisfile_monkeysaudio['bitrate'];
 
-		// add size of MAC header to avdataoffset - MD5data
-		$ThisFileInfo['avdataoffset'] += 40;
+		// add size of MAC header to avdataoffset
+		if ($thisfile_monkeysaudio_raw['nVersion'] >= 3980) {
+			$ThisFileInfo['avdataoffset'] += $thisfile_monkeysaudio_raw['nDescriptorBytes'];
+			$ThisFileInfo['avdataoffset'] += $thisfile_monkeysaudio_raw['nHeaderBytes'];
+			$ThisFileInfo['avdataoffset'] += $thisfile_monkeysaudio_raw['nSeekTableBytes'];
+			$ThisFileInfo['avdataoffset'] += $thisfile_monkeysaudio_raw['nHeaderDataBytes'];
 
+			$ThisFileInfo['avdataend'] -= $thisfile_monkeysaudio_raw['nTerminatingDataBytes'];
+		} else {
+			$ThisFileInfo['avdataoffset'] += $offset;
+		}
+
+		if ($thisfile_monkeysaudio_raw['nVersion'] >= 3980) {
+			if ($thisfile_monkeysaudio_raw['cFileMD5'] === str_repeat("\x00", 16)) {
+				//$ThisFileInfo['warning'][] = 'cFileMD5 is null';
+			} else {
+				$ThisFileInfo['md5_data_source'] = '';
+				$md5 = $thisfile_monkeysaudio_raw['cFileMD5'];
+				for ($i = 0; $i < strlen($md5); $i++) {
+					$ThisFileInfo['md5_data_source'] .= str_pad(dechex(ord($md5{$i})), 2, '00', STR_PAD_LEFT);
+				}
+				if (!preg_match('/^[0-9a-f]{32}$/', $ThisFileInfo['md5_data_source'])) {
+					unset($ThisFileInfo['md5_data_source']);
+				}
+			}
+		}
+
+
+
 		$ThisFileInfo['audio']['bits_per_sample'] = $thisfile_monkeysaudio['bits_per_sample'];
 		$ThisFileInfo['audio']['encoder']         = 'MAC v'.number_format($thisfile_monkeysaudio['version'], 2);
 		$ThisFileInfo['audio']['encoder_options'] = ucfirst($thisfile_monkeysaudio['compression']).' compression';

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.mp3.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.mp3.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.mp3.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -20,9 +20,7 @@
 // mpeg-audio streams
 define('GETID3_MP3_VALID_CHECK_FRAMES', 35);
 
-/**
- * \ingroup getid3
- */
+
 class getid3_mp3
 {
 
@@ -198,6 +196,8 @@
 				$KnownEncoderValues['**'][88][4][1][3][3][19500] = '--r3mix';                    // 3.90,   3.90.1, 3.92
 				$KnownEncoderValues['**'][88][4][1][3][3][19600] = '--r3mix';                    // 3.90.2, 3.90.3, 3.91
 				$KnownEncoderValues['**'][67][4][1][3][4][18000] = '--r3mix';                    // 3.94,   3.95
+				$KnownEncoderValues['**'][68][3][2][3][4][18000] = '--alt-preset medium';        // 3.90.3
+				$KnownEncoderValues['**'][68][4][2][3][4][18000] = '--alt-preset fast medium';   // 3.90.3
 
 				$KnownEncoderValues[0xFF][99][1][1][1][2][0]     = '--preset studio';            // 3.90,   3.90.1, 3.90.2, 3.91, 3.92
 				$KnownEncoderValues[0xFF][58][2][1][3][2][20600] = '--preset studio';            // 3.90.3, 3.93.1
@@ -521,7 +521,7 @@
 					if (($thisfile_mpeg_audio['bitrate'] == 'free') || ($thisfile_mpeg_audio['bitrate'] == 64000) || ($thisfile_mpeg_audio['bitrate'] >= 96000)) {
 						// these are ok
 					} else {
-						$ThisFileInfo['error'][] = round($thisfile_mpeg_audio['bitrate'] / 1000).'kbps not allowed in Layer 2, '.$thisfile_mpeg_audio['channelmode'].'.';
+						$ThisFileInfo['error'][] = intval(round($thisfile_mpeg_audio['bitrate'] / 1000)).'kbps not allowed in Layer 2, '.$thisfile_mpeg_audio['channelmode'].'.';
 						return false;
 					}
 					break;
@@ -1173,7 +1173,7 @@
 				$nextoffset += $framelength;
 			}
 			if (count($ActualFrameLengthValues) > 0) {
-				$framelength = round(array_sum($ActualFrameLengthValues) / count($ActualFrameLengthValues));
+				$framelength = intval(round(array_sum($ActualFrameLengthValues) / count($ActualFrameLengthValues)));
 			}
 		}
 		return $framelength;
@@ -1332,7 +1332,7 @@
 
 		}
 
-		$header_len = strlen($header) - round(GETID3_FREAD_BUFFER_SIZE / 2);
+		$header_len = strlen($header) - intval(round(GETID3_FREAD_BUFFER_SIZE / 2));
 		while (true) {
 
 			if (($SynchSeekOffset > $header_len) && (($avdataoffset + $SynchSeekOffset)  < $ThisFileInfo['avdataend']) && !feof($fd)) {
@@ -1354,7 +1354,7 @@
 				} elseif ($header .= fread($fd, GETID3_FREAD_BUFFER_SIZE)) {
 
 					// great
-					$header_len = strlen($header) - round(GETID3_FREAD_BUFFER_SIZE / 2);
+					$header_len = strlen($header) - intval(round(GETID3_FREAD_BUFFER_SIZE / 2));
 
 				} else {
 
@@ -1798,7 +1798,7 @@
 	function ClosestStandardMP3Bitrate($bitrate) {
 		static $StandardBitrates = array(320000, 256000, 224000, 192000, 160000, 128000, 112000, 96000, 80000, 64000, 56000, 48000, 40000, 32000, 24000, 16000, 8000);
 		static $BitrateTable = array(0=>'-');
-		$roundbitrate = round($bitrate, -3);
+		$roundbitrate = intval(round($bitrate, -3));
 		if (!isset($BitrateTable[$roundbitrate])) {
 			if ($roundbitrate > 320000) {
 				$BitrateTable[$roundbitrate] = round($bitrate, -4);
@@ -1924,18 +1924,17 @@
 			$LAMEpresetUsedLookup[1006] = '--alt-preset medium';
 			$LAMEpresetUsedLookup[1007] = '--alt-preset fast medium';
 
-			if ($LAMEtag['short_version'] >= 'LAME3.94') {
-				// LAME 3.94 additions/changes
-				$LAMEpresetUsedLookup[320]  = '--preset insane';                                                             // 3.94a15 Nov 12 2003
-				$LAMEpresetUsedLookup[430]  = '--preset radio';                                                              // 3.94a15 Nov 12 2003
-				$LAMEpresetUsedLookup[450]  = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'portable'; // 3.94a15 Nov 12 2003
-				$LAMEpresetUsedLookup[460]  = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'medium';   // 3.94a15 Nov 12 2003
-				$LAMEpresetUsedLookup[470]  = '--r3mix';                                                                     // 3.94b1  Dec 18 2003
-				$LAMEpresetUsedLookup[480]  = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'standard'; // 3.94a15 Nov 12 2003
-				$LAMEpresetUsedLookup[500]  = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'extreme';  // 3.94a15 Nov 12 2003
-				$LAMEpresetUsedLookup[1010] = '--preset portable';                                                           // 3.94a15 Oct 21 2003
-				$LAMEpresetUsedLookup[1015] = '--preset radio';                                                              // 3.94a15 Oct 21 2003
-			}
+			// LAME 3.94 additions/changes
+			$LAMEpresetUsedLookup[1010] = '--preset portable';                                                           // 3.94a15 Oct 21 2003
+			$LAMEpresetUsedLookup[1015] = '--preset radio';                                                              // 3.94a15 Oct 21 2003
+
+			$LAMEpresetUsedLookup[320]  = '--preset insane';                                                             // 3.94a15 Nov 12 2003
+			$LAMEpresetUsedLookup[430]  = '--preset radio';                                                              // 3.94a15 Nov 12 2003
+			$LAMEpresetUsedLookup[450]  = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'portable';  // 3.94a15 Nov 12 2003
+			$LAMEpresetUsedLookup[460]  = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'medium';    // 3.94a15 Nov 12 2003
+			$LAMEpresetUsedLookup[470]  = '--r3mix';                                                                     // 3.94b1  Dec 18 2003
+			$LAMEpresetUsedLookup[480]  = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'standard';  // 3.94a15 Nov 12 2003
+			$LAMEpresetUsedLookup[500]  = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'extreme';   // 3.94a15 Nov 12 2003
 		}
 		return (isset($LAMEpresetUsedLookup[$LAMEtag['preset_used_id']]) ? $LAMEpresetUsedLookup[$LAMEtag['preset_used_id']] : 'new/unknown preset: '.$LAMEtag['preset_used_id'].' - report to info at getid3.org');
 	}

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.mpc.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.mpc.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.mpc.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_mpc
 {
 
@@ -33,7 +31,7 @@
 
 		fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
 
-		$thisfile_mpc_header['size']    = 30;
+		$thisfile_mpc_header['size'] = 28;
 		$MPCheaderData = fread($fd, $thisfile_mpc_header['size']);
 		$offset = 0;
 
@@ -46,6 +44,11 @@
 		} elseif (preg_match('/^[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0]/s', substr($MPCheaderData, 0, 4))) {
 
 			// this is SV4 - SV6, handle seperately
+            $thisfile_mpc_header['size'] = 8;
+
+            // add size of file header to avdataoffset - calc bitrate correctly + MD5 data
+		    $ThisFileInfo['avdataoffset'] += $thisfile_mpc_header['size'];
+
 			// Most of this code adapted from Jurgen Faul's MPEGplus source code - thanks Jurgen! :)
 			$HeaderDWORD[0] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, 0, 4));
 			$HeaderDWORD[1] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, 4, 4));
@@ -73,6 +76,7 @@
 				case 4:
 					$thisfile_mpc_header['frame_count'] = ($HeaderDWORD[1] >> 16);
 					break;
+
 				case 5:
 				case 6:
 					$thisfile_mpc_header['frame_count'] =  $HeaderDWORD[1];
@@ -89,9 +93,9 @@
 				$ThisFileInfo['warning'][] = 'Block size expected to be 1, actual value found: '.$thisfile_mpc_header['block_size'];
 			}
 
-			$thisfile_mpc_header['sample_rate'] = 44100; // AB: used by all files up to SV7
-			$ThisFileInfo['audio']['sample_rate']         = $thisfile_mpc_header['sample_rate'];
-			$thisfile_mpc_header['samples']     = $thisfile_mpc_header['frame_count'] * 1152 * $ThisFileInfo['audio']['channels'];
+			$thisfile_mpc_header['sample_rate']   = 44100; // AB: used by all files up to SV7
+			$ThisFileInfo['audio']['sample_rate'] = $thisfile_mpc_header['sample_rate'];
+			$thisfile_mpc_header['samples']       = $thisfile_mpc_header['frame_count'] * 1152 * $ThisFileInfo['audio']['channels'];
 
 			if ($thisfile_mpc_header['target_bitrate'] == 0) {
 				$ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
@@ -115,7 +119,7 @@
 		}
 
 		// Continue with SV7+ handling
-		$StreamVersionByte                                     = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 1));
+		$StreamVersionByte                           = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 1));
 		$offset += 1;
 		$thisfile_mpc_header['stream_major_version'] = ($StreamVersionByte & 0x0F);
 		$thisfile_mpc_header['stream_minor_version'] = ($StreamVersionByte & 0xF0) >> 4;
@@ -132,7 +136,7 @@
 				return false;
 		}
 
-		$FlagsDWORD1                                             = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
+		$FlagsDWORD1                                   = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
 		$offset += 4;
 		$thisfile_mpc_header['intensity_stereo']       = (bool) (($FlagsDWORD1 & 0x80000000) >> 31);
 		$thisfile_mpc_header['mid_side_stereo']        = (bool) (($FlagsDWORD1 & 0x40000000) >> 30);
@@ -153,7 +157,7 @@
 		$thisfile_mpc_header['raw']['album_gain']      = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 2), true);
 		$offset += 2;
 
-		$FlagsDWORD2                                             = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
+		$FlagsDWORD2                                   = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 4));
 		$offset += 4;
 		$thisfile_mpc_header['true_gapless']           = (bool) (($FlagsDWORD2 & 0x80000000) >> 31);
 		$thisfile_mpc_header['last_frame_length']      =         ($FlagsDWORD2 & 0x7FF00000) >> 20;
@@ -164,16 +168,16 @@
 		$thisfile_mpc_header['raw']['encoder_version'] = getid3_lib::LittleEndian2Int(substr($MPCheaderData, $offset, 1));
 		$offset += 1;
 
-		$thisfile_mpc_header['profile']                = $this->MPCprofileNameLookup($thisfile_mpc_header['raw']['profile']);
-		$thisfile_mpc_header['sample_rate']            = $this->MPCfrequencyLookup($thisfile_mpc_header['raw']['sample_rate']);
+		$thisfile_mpc_header['profile']     = $this->MPCprofileNameLookup($thisfile_mpc_header['raw']['profile']);
+		$thisfile_mpc_header['sample_rate'] = $this->MPCfrequencyLookup($thisfile_mpc_header['raw']['sample_rate']);
 		if ($thisfile_mpc_header['sample_rate'] == 0) {
 			$ThisFileInfo['error'][] = 'Corrupt MPC file: frequency == zero';
 			return false;
 		}
-		$ThisFileInfo['audio']['sample_rate']                    = $thisfile_mpc_header['sample_rate'];
-		$thisfile_mpc_header['samples']                = ((($thisfile_mpc_header['frame_count'] - 1) * 1152) + $thisfile_mpc_header['last_frame_length']) * $ThisFileInfo['audio']['channels'];
+		$ThisFileInfo['audio']['sample_rate'] = $thisfile_mpc_header['sample_rate'];
+		$thisfile_mpc_header['samples']       = ((($thisfile_mpc_header['frame_count'] - 1) * 1152) + $thisfile_mpc_header['last_frame_length']) * $ThisFileInfo['audio']['channels'];
 
-		$ThisFileInfo['playtime_seconds']                        = ($thisfile_mpc_header['samples'] / $ThisFileInfo['audio']['channels']) / $ThisFileInfo['audio']['sample_rate'];
+		$ThisFileInfo['playtime_seconds']     = ($thisfile_mpc_header['samples'] / $ThisFileInfo['audio']['channels']) / $ThisFileInfo['audio']['sample_rate'];
 		if ($ThisFileInfo['playtime_seconds'] == 0) {
 			$ThisFileInfo['error'][] = 'Corrupt MPC file: playtime_seconds == zero';
 			return false;
@@ -184,33 +188,33 @@
 
 		$ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
 
-		$thisfile_mpc_header['title_peak']             = $thisfile_mpc_header['raw']['title_peak'];
-		$thisfile_mpc_header['title_peak_db']          = $this->MPCpeakDBLookup($thisfile_mpc_header['title_peak']);
+		$thisfile_mpc_header['title_peak']        = $thisfile_mpc_header['raw']['title_peak'];
+		$thisfile_mpc_header['title_peak_db']     = $this->MPCpeakDBLookup($thisfile_mpc_header['title_peak']);
 		if ($thisfile_mpc_header['raw']['title_gain'] < 0) {
-			$thisfile_mpc_header['title_gain_db']      = (float) (32768 + $thisfile_mpc_header['raw']['title_gain']) / -100;
+			$thisfile_mpc_header['title_gain_db'] = (float) (32768 + $thisfile_mpc_header['raw']['title_gain']) / -100;
 		} else {
-			$thisfile_mpc_header['title_gain_db']      = (float) $thisfile_mpc_header['raw']['title_gain'] / 100;
+			$thisfile_mpc_header['title_gain_db'] = (float) $thisfile_mpc_header['raw']['title_gain'] / 100;
 		}
 
-		$thisfile_mpc_header['album_peak']             = $thisfile_mpc_header['raw']['album_peak'];
-		$thisfile_mpc_header['album_peak_db']          = $this->MPCpeakDBLookup($thisfile_mpc_header['album_peak']);
+		$thisfile_mpc_header['album_peak']        = $thisfile_mpc_header['raw']['album_peak'];
+		$thisfile_mpc_header['album_peak_db']     = $this->MPCpeakDBLookup($thisfile_mpc_header['album_peak']);
 		if ($thisfile_mpc_header['raw']['album_gain'] < 0) {
-			$thisfile_mpc_header['album_gain_db']      = (float) (32768 + $thisfile_mpc_header['raw']['album_gain']) / -100;
+			$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']);
+		$thisfile_mpc_header['encoder_version']   = $this->MPCencoderVersionLookup($thisfile_mpc_header['raw']['encoder_version']);
 
-		$ThisFileInfo['replay_gain']['track']['adjustment']      = $thisfile_mpc_header['title_gain_db'];
+		$ThisFileInfo['replay_gain']['track']['adjustment'] = $thisfile_mpc_header['title_gain_db'];
 		$ThisFileInfo['replay_gain']['album']['adjustment'] = $thisfile_mpc_header['album_gain_db'];
 
 		if ($thisfile_mpc_header['title_peak'] > 0) {
-			$ThisFileInfo['replay_gain']['track']['peak']            = $thisfile_mpc_header['title_peak'];
+			$ThisFileInfo['replay_gain']['track']['peak'] = $thisfile_mpc_header['title_peak'];
 		} elseif (round($thisfile_mpc_header['max_level'] * 1.18) > 0) {
-			$ThisFileInfo['replay_gain']['track']['peak']            = getid3_lib::CastAsInt(round($thisfile_mpc_header['max_level'] * 1.18)); // why? I don't know - see mppdec.c
+			$ThisFileInfo['replay_gain']['track']['peak'] = getid3_lib::CastAsInt(round($thisfile_mpc_header['max_level'] * 1.18)); // why? I don't know - see mppdec.c
 		}
 		if ($thisfile_mpc_header['album_peak'] > 0) {
-			$ThisFileInfo['replay_gain']['album']['peak']       = $thisfile_mpc_header['album_peak'];
+			$ThisFileInfo['replay_gain']['album']['peak'] = $thisfile_mpc_header['album_peak'];
 		}
 
 		//$ThisFileInfo['audio']['encoder'] = 'SV'.$thisfile_mpc_header['stream_major_version'].'.'.$thisfile_mpc_header['stream_minor_version'].', '.$thisfile_mpc_header['encoder_version'];

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.ogg.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.ogg.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.ogg.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -15,9 +15,6 @@
 
 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.flac.php', __FILE__, true);
 
-/**
- * \ingroup getid3
- */
 class getid3_ogg
 {
 
@@ -242,7 +239,7 @@
 					if ($ThisFileInfo['audio']['bitrate_mode'] == 'abr') {
 
 						// Set -b 128 on abr files
-						$ThisFileInfo['audio']['encoder_options'] = '-b '.ceil($ThisFileInfo['ogg']['bitrate_nominal'] / 1000);
+						$ThisFileInfo['audio']['encoder_options'] = '-b '.round($ThisFileInfo['ogg']['bitrate_nominal'] / 1000);
 
 					} elseif (($ThisFileInfo['audio']['bitrate_mode'] == 'vbr') && ($ThisFileInfo['audio']['channels'] == 2) && ($ThisFileInfo['audio']['sample_rate'] >= 44100) && ($ThisFileInfo['audio']['sample_rate'] <= 48000)) {
 						// Set -q N on vbr files
@@ -252,7 +249,7 @@
 				}
 
 				if (empty($ThisFileInfo['audio']['encoder_options']) && !empty($ThisFileInfo['ogg']['bitrate_nominal'])) {
-					$ThisFileInfo['audio']['encoder_options'] = 'Nominal bitrate: '.ceil(round($ThisFileInfo['ogg']['bitrate_nominal'] / 1000)) .'kbps';
+					$ThisFileInfo['audio']['encoder_options'] = 'Nominal bitrate: '.intval(round($ThisFileInfo['ogg']['bitrate_nominal'] / 1000)).'kbps';
 				}
 			}
 		}
@@ -521,25 +518,24 @@
 	function get_quality_from_nominal_bitrate($nominal_bitrate) {
 
 		// decrease precision
-		$nominal_bitrate = ceil(round($nominal_bitrate / 1000));
+		$nominal_bitrate = $nominal_bitrate / 1000;
 
-		// q-1 to q4
 		if ($nominal_bitrate < 128) {
-			return ($nominal_bitrate - 64) / 16;
+			// q-1 to q4
+			$qval = ($nominal_bitrate - 64) / 16;
+		} elseif ($nominal_bitrate < 256) {
+			// q4 to q8
+			$qval = $nominal_bitrate / 32;
+		} elseif ($nominal_bitrate < 320) {
+			// q8 to q9
+			$qval = ($nominal_bitrate + 256) / 64;
+		} else {
+			// q9 to q10
+			$qval = ($nominal_bitrate + 1300) / 180;
 		}
-
-		// q4 to q8
-		if ($nominal_bitrate < 256) {
-			return $nominal_bitrate / 32;
-		}
-
-		// q8 to q9
-		if ($nominal_bitrate < 320) {
-			return ($nominal_bitrate + 256) / 64;
-		}
-
-		// q9 to q10
-		return ($nominal_bitrate + 1300) / 180;
+		//return $qval; // 5.031324
+		//return intval($qval); // 5
+		return round($qval, 1); // 5 or 4.9
 	}
 
 }

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.optimfrog.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.optimfrog.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.optimfrog.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -15,9 +15,6 @@
 
 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
 
-/**
- * \ingroup getid3
- */
 class getid3_optimfrog
 {
 
@@ -52,7 +49,9 @@
 		$OptimFROGheaderData = fread($fd, 45);
 		$ThisFileInfo['avdataoffset'] = 45;
 
-		$OptimFROGencoderVersion = getid3_lib::LittleEndian2Int(substr($OptimFROGheaderData, 0, 1)) / 10;
+		$OptimFROGencoderVersion_raw   = getid3_lib::LittleEndian2Int(substr($OptimFROGheaderData, 0, 1));
+		$OptimFROGencoderVersion_major = floor($OptimFROGencoderVersion_raw / 10);
+		$OptimFROGencoderVersion_minor = $OptimFROGencoderVersion_raw - ($OptimFROGencoderVersion_major * 10);
 		$RIFFdata                = substr($OptimFROGheaderData, 1, 44);
 		$OrignalRIFFheaderSize   = getid3_lib::LittleEndian2Int(substr($RIFFdata,  4, 4)) +  8;
 		$OrignalRIFFdataSize     = getid3_lib::LittleEndian2Int(substr($RIFFdata, 40, 4)) + 44;
@@ -69,7 +68,7 @@
 		$RIFFdata = substr($RIFFdata, 0, 36).substr($RIFFdata, 44).substr($RIFFdata, 36, 8);
 		getid3_riff::ParseRIFFdata($RIFFdata, $ThisFileInfo);
 
-		$ThisFileInfo['audio']['encoder']         = 'OptimFROG '.round($OptimFROGencoderVersion, 1);
+		$ThisFileInfo['audio']['encoder']         = 'OptimFROG '.$OptimFROGencoderVersion_major.'.'.$OptimFROGencoderVersion_minor;
 		$ThisFileInfo['audio']['channels']        = $ThisFileInfo['riff']['audio'][0]['channels'];
 		$ThisFileInfo['audio']['sample_rate']     = $ThisFileInfo['riff']['audio'][0]['sample_rate'];
 		$ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['riff']['audio'][0]['bits_per_sample'];
@@ -219,7 +218,9 @@
 					$thisfile_ofr_thisblock['offset'] = $BlockOffset;
 					$thisfile_ofr_thisblock['size']   = $BlockSize;
 
-					$RIFFdata .= fread($fd, $BlockSize);
+					if ($BlockSize > 0) {
+						$RIFFdata .= fread($fd, $BlockSize);
+					}
 					break;
 
 				case 'RECV':

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.rkau.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.rkau.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.rkau.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_rkau
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.shorten.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.shorten.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.shorten.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_shorten
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.tta.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.tta.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.tta.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_tta
 {
 
@@ -27,7 +25,7 @@
 		$ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
 
 		fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
-		$ttaheader = fread($fd, 20);
+		$ttaheader = fread($fd, 26);
 
 		$ThisFileInfo['tta']['magic'] = substr($ttaheader,  0,  3);
 		if ($ThisFileInfo['tta']['magic'] != 'TTA') {
@@ -39,11 +37,12 @@
 		}
 
 		switch ($ttaheader{3}) {
-			case "\x01":
-			case "\x02":
-			case "\x03":
+			case "\x01": // TTA v1.x
+			case "\x02": // TTA v1.x
+			case "\x03": // TTA v1.x
+				// "It was the demo-version of the TTA encoder. There is no released format with such header. TTA encoder v1 is not supported about a year."
 				$ThisFileInfo['tta']['major_version'] = 1;
-				$ThisFileInfo['avdataoffset']         = 16;
+				$ThisFileInfo['avdataoffset'] += 16;
 
 				$ThisFileInfo['tta']['compression_level']   = ord($ttaheader{3});
 				$ThisFileInfo['tta']['channels']            = getid3_lib::LittleEndian2Int(substr($ttaheader,  4,  2));
@@ -51,12 +50,14 @@
 				$ThisFileInfo['tta']['sample_rate']         = getid3_lib::LittleEndian2Int(substr($ttaheader,  8,  4));
 				$ThisFileInfo['tta']['samples_per_channel'] = getid3_lib::LittleEndian2Int(substr($ttaheader, 12,  4));
 
+				$ThisFileInfo['audio']['encoder_options']   = '-e'.$ThisFileInfo['tta']['compression_level'];
 				$ThisFileInfo['playtime_seconds']           = $ThisFileInfo['tta']['samples_per_channel'] / $ThisFileInfo['tta']['sample_rate'];
 				break;
 
-			case '2':
+			case '2': // TTA v2.x
+				// "I have hurried to release the TTA 2.0 encoder. Format documentation is removed from our site. This format still in development. Please wait the TTA2 format, encoder v4."
 				$ThisFileInfo['tta']['major_version'] = 2;
-				$ThisFileInfo['avdataoffset']         = 20;
+				$ThisFileInfo['avdataoffset'] += 20;
 
 				$ThisFileInfo['tta']['compression_level']   = getid3_lib::LittleEndian2Int(substr($ttaheader,  4,  2));
 				$ThisFileInfo['tta']['audio_format']        = getid3_lib::LittleEndian2Int(substr($ttaheader,  6,  2));
@@ -65,15 +66,32 @@
 				$ThisFileInfo['tta']['sample_rate']         = getid3_lib::LittleEndian2Int(substr($ttaheader, 12,  4));
 				$ThisFileInfo['tta']['data_length']         = getid3_lib::LittleEndian2Int(substr($ttaheader, 16,  4));
 
+				$ThisFileInfo['audio']['encoder_options']   = '-e'.$ThisFileInfo['tta']['compression_level'];
 				$ThisFileInfo['playtime_seconds']           = $ThisFileInfo['tta']['data_length'] / $ThisFileInfo['tta']['sample_rate'];
 				break;
 
+			case '1': // TTA v3.x
+				// "This is a first stable release of the TTA format. It will be supported by the encoders v3 or higher."
+				$ThisFileInfo['tta']['major_version'] = 3;
+				$ThisFileInfo['avdataoffset'] += 26;
+
+				$ThisFileInfo['tta']['audio_format']        = getid3_lib::LittleEndian2Int(substr($ttaheader,  4,  2)); // getid3_riff::RIFFwFormatTagLookup()
+				$ThisFileInfo['tta']['channels']            = getid3_lib::LittleEndian2Int(substr($ttaheader,  6,  2));
+				$ThisFileInfo['tta']['bits_per_sample']     = getid3_lib::LittleEndian2Int(substr($ttaheader,  8,  2));
+				$ThisFileInfo['tta']['sample_rate']         = getid3_lib::LittleEndian2Int(substr($ttaheader, 10,  4));
+				$ThisFileInfo['tta']['data_length']         = getid3_lib::LittleEndian2Int(substr($ttaheader, 14,  4));
+				$ThisFileInfo['tta']['crc32_footer']        =                              substr($ttaheader, 18,  4);
+				$ThisFileInfo['tta']['seek_point']          = getid3_lib::LittleEndian2Int(substr($ttaheader, 22,  4));
+
+				$ThisFileInfo['playtime_seconds']           = $ThisFileInfo['tta']['data_length'] / $ThisFileInfo['tta']['sample_rate'];
+				break;
+
 			default:
 				$ThisFileInfo['error'][] = 'This version of getID3() only knows how to handle TTA v1 and v2 - it may not work correctly with this file which appears to be TTA v'.$ttaheader{3};
+				return false;
 				break;
 		}
 
-		$ThisFileInfo['audio']['encoder_options'] = '-e'.$ThisFileInfo['tta']['compression_level'];
 		$ThisFileInfo['audio']['encoder']         = 'TTA v'.$ThisFileInfo['tta']['major_version'];
 		$ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['tta']['bits_per_sample'];
 		$ThisFileInfo['audio']['sample_rate']     = $ThisFileInfo['tta']['sample_rate'];

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.voc.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.voc.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.voc.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_voc
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.vqf.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.vqf.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.vqf.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_vqf
 {
 	function getid3_vqf(&$fd, &$ThisFileInfo) {
@@ -66,13 +64,15 @@
 				$ThisFileInfo['error'][] = 'Invalid chunk size ('.$ChunkSize.') for chunk "'.$ChunkName.'" at offset '.$ChunkBaseOffset;
 				break;
 			}
-			$ChunkData .= fread($fd, $ChunkSize);
+			if ($ChunkSize > 0) {
+				$ChunkData .= fread($fd, $ChunkSize);
+			}
 
 			switch ($ChunkName) {
 				case 'COMM':
 					// shortcut
 					$thisfile_vqf['COMM'] = array();
-					$thisfile_vqf_COMM    = $thisfile_vqf['COMM'];
+					$thisfile_vqf_COMM    = &$thisfile_vqf['COMM'];
 
 					$thisfile_vqf_COMM['channel_mode']   = getid3_lib::BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
 					$chunkoffset += 4;
@@ -150,7 +150,7 @@
 			'COMT' => 'comment',
 			'ALBM' => 'album'
 		);
-		return (isset($VQFcommentNiceNameLookup["$shortname"]) ? $VQFcommentNiceNameLookup["$shortname"] : $shortname);
+		return (isset($VQFcommentNiceNameLookup[$shortname]) ? $VQFcommentNiceNameLookup[$shortname] : $shortname);
 	}
 
 }

Added: plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.wavpack.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.wavpack.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.audio.wavpack.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -0,0 +1,372 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info at getid3.org>               //
+//  available at http://getid3.sourceforge.net                 //
+//            or http://www.getid3.org                         //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details                             //
+/////////////////////////////////////////////////////////////////
+//                                                             //
+// module.audio.wavpack.php                                    //
+// module for analyzing WavPack v4.0+ Audio files              //
+// dependencies: NONE                                          //
+//                                                            ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_wavpack
+{
+
+	function getid3_wavpack(&$fd, &$ThisFileInfo) {
+
+		fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
+
+		while (true) {
+
+			$wavpackheader = fread($fd, 32);
+
+			if (ftell($fd) >= $ThisFileInfo['avdataend']) {
+				break;
+			} elseif (feof($fd)) {
+				break;
+			} elseif (
+				(@$ThisFileInfo['wavpack']['blockheader']['total_samples'] > 0) &&
+				(@$ThisFileInfo['wavpack']['blockheader']['block_samples'] > 0) &&
+				(!isset($ThisFileInfo['wavpack']['riff_trailer_size']) || ($ThisFileInfo['wavpack']['riff_trailer_size'] <= 0)) &&
+				((@$ThisFileInfo['wavpack']['config_flags']['md5_checksum'] === false) || !empty($ThisFileInfo['md5_data_source']))) {
+					break;
+			}
+
+			$blockheader_offset = ftell($fd) - 32;
+			$blockheader_magic  =                              substr($wavpackheader,  0,  4);
+			$blockheader_size   = getid3_lib::LittleEndian2Int(substr($wavpackheader,  4,  4));
+
+			if ($blockheader_magic != 'wvpk') {
+				$ThisFileInfo['error'][] = 'Expecting "wvpk" at offset '.$blockheader_offset.', found "'.$blockheader_magic.'"';
+				if ((@$ThisFileInfo['audio']['dataformat'] != 'wavpack') && (@$ThisFileInfo['audio']['dataformat'] != 'wvc')) {
+					unset($ThisFileInfo['fileformat']);
+					unset($ThisFileInfo['audio']);
+					unset($ThisFileInfo['wavpack']);
+				}
+				return false;
+			}
+
+
+			if ((@$ThisFileInfo['wavpack']['blockheader']['block_samples'] <= 0) ||
+				(@$ThisFileInfo['wavpack']['blockheader']['total_samples'] <= 0)) {
+				// Also, it is possible that the first block might not have
+				// any samples (block_samples == 0) and in this case you should skip blocks
+				// until you find one with samples because the other information (like
+				// total_samples) are not guaranteed to be correct until (block_samples > 0)
+
+				// Finally, I have defined a format for files in which the length is not known
+				// (for example when raw files are created using pipes). In these cases
+				// total_samples will be -1 and you must seek to the final block to determine
+				// the total number of samples.
+
+
+				$ThisFileInfo['audio']['dataformat']   = 'wavpack';
+				$ThisFileInfo['fileformat']            = 'wavpack';
+				$ThisFileInfo['audio']['lossless']     = true;
+				$ThisFileInfo['audio']['bitrate_mode'] = 'vbr';
+
+				$ThisFileInfo['wavpack']['blockheader']['offset'] = $blockheader_offset;
+				$ThisFileInfo['wavpack']['blockheader']['magic']  = $blockheader_magic;
+				$ThisFileInfo['wavpack']['blockheader']['size']   = $blockheader_size;
+
+				if ($ThisFileInfo['wavpack']['blockheader']['size'] >= 0x100000) {
+					$ThisFileInfo['error'][] = 'Expecting WavPack block size less than "0x100000", found "'.$ThisFileInfo['wavpack']['blockheader']['size'].'" at offset '.$ThisFileInfo['wavpack']['blockheader']['offset'];
+					if ((@$ThisFileInfo['audio']['dataformat'] != 'wavpack') && (@$ThisFileInfo['audio']['dataformat'] != 'wvc')) {
+						unset($ThisFileInfo['fileformat']);
+						unset($ThisFileInfo['audio']);
+						unset($ThisFileInfo['wavpack']);
+					}
+					return false;
+				}
+
+				$ThisFileInfo['wavpack']['blockheader']['minor_version'] = ord($wavpackheader{8});
+				$ThisFileInfo['wavpack']['blockheader']['major_version'] = ord($wavpackheader{9});
+
+				if (($ThisFileInfo['wavpack']['blockheader']['major_version'] != 4) ||
+					(($ThisFileInfo['wavpack']['blockheader']['minor_version'] < 4) &&
+					($ThisFileInfo['wavpack']['blockheader']['minor_version'] > 16))) {
+						$ThisFileInfo['error'][] = 'Expecting WavPack version between "4.2" and "4.16", found version "'.$ThisFileInfo['wavpack']['blockheader']['major_version'].'.'.$ThisFileInfo['wavpack']['blockheader']['minor_version'].'" at offset '.$ThisFileInfo['wavpack']['blockheader']['offset'];
+						if ((@$ThisFileInfo['audio']['dataformat'] != 'wavpack') && (@$ThisFileInfo['audio']['dataformat'] != 'wvc')) {
+							unset($ThisFileInfo['fileformat']);
+							unset($ThisFileInfo['audio']);
+							unset($ThisFileInfo['wavpack']);
+						}
+						return false;
+				}
+
+				$ThisFileInfo['wavpack']['blockheader']['track_number']  = ord($wavpackheader{10}); // unused
+				$ThisFileInfo['wavpack']['blockheader']['index_number']  = ord($wavpackheader{11}); // unused
+				$ThisFileInfo['wavpack']['blockheader']['total_samples'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 12,  4));
+				$ThisFileInfo['wavpack']['blockheader']['block_index']   = getid3_lib::LittleEndian2Int(substr($wavpackheader, 16,  4));
+				$ThisFileInfo['wavpack']['blockheader']['block_samples'] = getid3_lib::LittleEndian2Int(substr($wavpackheader, 20,  4));
+				$ThisFileInfo['wavpack']['blockheader']['flags_raw']     = getid3_lib::LittleEndian2Int(substr($wavpackheader, 24,  4));
+				$ThisFileInfo['wavpack']['blockheader']['crc']           = getid3_lib::LittleEndian2Int(substr($wavpackheader, 28,  4));
+
+				$ThisFileInfo['wavpack']['blockheader']['flags']['bytes_per_sample']     =    1 + ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000003);
+				$ThisFileInfo['wavpack']['blockheader']['flags']['mono']                 = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000004);
+				$ThisFileInfo['wavpack']['blockheader']['flags']['hybrid']               = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000008);
+				$ThisFileInfo['wavpack']['blockheader']['flags']['joint_stereo']         = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000010);
+				$ThisFileInfo['wavpack']['blockheader']['flags']['cross_decorrelation']  = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000020);
+				$ThisFileInfo['wavpack']['blockheader']['flags']['hybrid_noiseshape']    = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000040);
+				$ThisFileInfo['wavpack']['blockheader']['flags']['ieee_32bit_float']     = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000080);
+				$ThisFileInfo['wavpack']['blockheader']['flags']['int_32bit']            = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000100);
+				$ThisFileInfo['wavpack']['blockheader']['flags']['hybrid_bitrate_noise'] = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000200);
+				$ThisFileInfo['wavpack']['blockheader']['flags']['hybrid_balance_noise'] = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000400);
+				$ThisFileInfo['wavpack']['blockheader']['flags']['multichannel_initial'] = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00000800);
+				$ThisFileInfo['wavpack']['blockheader']['flags']['multichannel_final']   = (bool) ($ThisFileInfo['wavpack']['blockheader']['flags_raw'] & 0x00001000);
+
+				$ThisFileInfo['audio']['lossless'] = !$ThisFileInfo['wavpack']['blockheader']['flags']['hybrid'];
+			}
+
+			while (!feof($fd) && (ftell($fd) < ($blockheader_offset + $blockheader_size + 8))) {
+
+				$metablock = array('offset'=>ftell($fd));
+				$metablockheader = fread($fd, 2);
+				if (feof($fd)) {
+					break;
+				}
+				$metablock['id'] = ord($metablockheader{0});
+				$metablock['function_id'] = ($metablock['id'] & 0x3F);
+				$metablock['function_name'] = $this->WavPackMetablockNameLookup($metablock['function_id']);
+
+				// The 0x20 bit in the id of the meta subblocks (which is defined as
+				// ID_OPTIONAL_DATA) is a permanent part of the id. The idea is that
+				// if a decoder encounters an id that it does not know about, it uses
+				// that "ID_OPTIONAL_DATA" flag to determine what to do. If it is set
+				// then the decoder simply ignores the metadata, but if it is zero
+				// then the decoder should quit because it means that an understanding
+				// of the metadata is required to correctly decode the audio.
+				$metablock['non_decoder'] = (bool) ($metablock['id'] & 0x20);
+
+				$metablock['padded_data'] = (bool) ($metablock['id'] & 0x40);
+				$metablock['large_block'] = (bool) ($metablock['id'] & 0x80);
+				if ($metablock['large_block']) {
+					$metablockheader .= fread($fd, 2);
+				}
+				$metablock['size'] = getid3_lib::LittleEndian2Int(substr($metablockheader, 1)) * 2; // size is stored in words
+				$metablock['data'] = null;
+
+				if ($metablock['size'] > 0) {
+
+					switch ($metablock['function_id']) {
+						case 0x21: // ID_RIFF_HEADER
+						case 0x22: // ID_RIFF_TRAILER
+						case 0x23: // ID_REPLAY_GAIN
+						case 0x24: // ID_CUESHEET
+						case 0x25: // ID_CONFIG_BLOCK
+						case 0x26: // ID_MD5_CHECKSUM
+							$metablock['data'] = fread($fd, $metablock['size']);
+
+							if ($metablock['padded_data']) {
+								// padded to the nearest even byte
+								$metablock['size']--;
+								$metablock['data'] = substr($metablock['data'], 0, -1);
+							}
+							break;
+
+						case 0x00: // ID_DUMMY
+						case 0x01: // ID_ENCODER_INFO
+						case 0x02: // ID_DECORR_TERMS
+						case 0x03: // ID_DECORR_WEIGHTS
+						case 0x04: // ID_DECORR_SAMPLES
+						case 0x05: // ID_ENTROPY_VARS
+						case 0x06: // ID_HYBRID_PROFILE
+						case 0x07: // ID_SHAPING_WEIGHTS
+						case 0x08: // ID_FLOAT_INFO
+						case 0x09: // ID_INT32_INFO
+						case 0x0A: // ID_WV_BITSTREAM
+						case 0x0B: // ID_WVC_BITSTREAM
+						case 0x0C: // ID_WVX_BITSTREAM
+						case 0x0D: // ID_CHANNEL_INFO
+							fseek($fd, $metablock['offset'] + ($metablock['large_block'] ? 4 : 2) + $metablock['size'], SEEK_SET);
+							break;
+
+						default:
+							$ThisFileInfo['warning'][] = 'Unexpected metablock type "0x'.str_pad(dechex($metablock['function_id']), 2, '0', STR_PAD_LEFT).'" at offset '.$metablock['offset'];
+							fseek($fd, $metablock['offset'] + ($metablock['large_block'] ? 4 : 2) + $metablock['size'], SEEK_SET);
+							break;
+					}
+
+					switch ($metablock['function_id']) {
+						case 0x21: // ID_RIFF_HEADER
+							getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
+							$original_wav_filesize = getid3_lib::LittleEndian2Int(substr($metablock['data'], 4, 4));
+							getid3_riff::ParseRIFFdata($metablock['data'], $ParsedRIFFheader);
+							$metablock['riff'] = $ParsedRIFFheader['riff'];
+							$metablock['riff']['original_filesize'] = $original_wav_filesize;
+							$ThisFileInfo['wavpack']['riff_trailer_size'] = $original_wav_filesize - $metablock['riff']['WAVE']['data'][0]['size'] - $metablock['riff']['header_size'];
+
+							$ThisFileInfo['audio']['sample_rate'] = $ParsedRIFFheader['riff']['raw']['fmt ']['nSamplesPerSec'];
+							$ThisFileInfo['playtime_seconds']     = $ThisFileInfo['wavpack']['blockheader']['total_samples'] / $ThisFileInfo['audio']['sample_rate'];
+
+							// Safe RIFF header in case there's a RIFF footer later
+							$metablockRIFFheader = $metablock['data'];
+							break;
+
+
+						case 0x22: // ID_RIFF_TRAILER
+							$metablockRIFFfooter = $metablockRIFFheader.$metablock['data'];
+							getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
+
+							$ftell_old = ftell($fd);
+							$startoffset = $metablock['offset'] + ($metablock['large_block'] ? 4 : 2);
+							$ParsedRIFFfooter = array('avdataend'=>$ThisFileInfo['avdataend'], 'fileformat'=>'riff', 'error'=>array(), 'warning'=>array());
+							$metablock['riff'] = getid3_riff::ParseRIFF($fd, $startoffset, $startoffset + $metablock['size'], $ParsedRIFFfooter);
+							fseek($fd, $ftell_old, SEEK_SET);
+
+							if (!empty($metablock['riff']['INFO'])) {
+								getid3_riff::RIFFcommentsParse($metablock['riff']['INFO'], $metablock['comments']);
+								$ThisFileInfo['tags']['riff'] = $metablock['comments'];
+							}
+							break;
+
+
+						case 0x23: // ID_REPLAY_GAIN
+							$ThisFileInfo['warning'][] = 'WavPack "Replay Gain" contents not yet handled by getID3() in metablock at offset '.$metablock['offset'];
+							break;
+
+
+						case 0x24: // ID_CUESHEET
+							$ThisFileInfo['warning'][] = 'WavPack "Cuesheet" contents not yet handled by getID3() in metablock at offset '.$metablock['offset'];
+							break;
+
+
+						case 0x25: // ID_CONFIG_BLOCK
+							$metablock['flags_raw'] = getid3_lib::LittleEndian2Int(substr($metablock['data'], 0, 3));
+
+							$metablock['flags']['adobe_mode']     = (bool) ($metablock['flags_raw'] & 0x000001); // "adobe" mode for 32-bit floats
+							$metablock['flags']['fast_flag']      = (bool) ($metablock['flags_raw'] & 0x000002); // fast mode
+							$metablock['flags']['very_fast_flag'] = (bool) ($metablock['flags_raw'] & 0x000004); // double fast
+							$metablock['flags']['high_flag']      = (bool) ($metablock['flags_raw'] & 0x000008); // high quality mode
+							$metablock['flags']['very_high_flag'] = (bool) ($metablock['flags_raw'] & 0x000010); // double high (not used yet)
+							$metablock['flags']['bitrate_kbps']   = (bool) ($metablock['flags_raw'] & 0x000020); // bitrate is kbps, not bits / sample
+							$metablock['flags']['auto_shaping']   = (bool) ($metablock['flags_raw'] & 0x000040); // automatic noise shaping
+							$metablock['flags']['shape_override'] = (bool) ($metablock['flags_raw'] & 0x000080); // shaping mode specified
+							$metablock['flags']['joint_override'] = (bool) ($metablock['flags_raw'] & 0x000100); // joint-stereo mode specified
+							$metablock['flags']['copy_time']      = (bool) ($metablock['flags_raw'] & 0x000200); // copy file-time from source
+							$metablock['flags']['create_exe']     = (bool) ($metablock['flags_raw'] & 0x000400); // create executable
+							$metablock['flags']['create_wvc']     = (bool) ($metablock['flags_raw'] & 0x000800); // create correction file
+							$metablock['flags']['optimize_wvc']   = (bool) ($metablock['flags_raw'] & 0x001000); // maximize bybrid compression
+							$metablock['flags']['quality_mode']   = (bool) ($metablock['flags_raw'] & 0x002000); // psychoacoustic quality mode
+							$metablock['flags']['raw_flag']       = (bool) ($metablock['flags_raw'] & 0x004000); // raw mode (not implemented yet)
+							$metablock['flags']['calc_noise']     = (bool) ($metablock['flags_raw'] & 0x008000); // calc noise in hybrid mode
+							$metablock['flags']['lossy_mode']     = (bool) ($metablock['flags_raw'] & 0x010000); // obsolete (for information)
+							$metablock['flags']['extra_mode']     = (bool) ($metablock['flags_raw'] & 0x020000); // extra processing mode
+							$metablock['flags']['skip_wvx']       = (bool) ($metablock['flags_raw'] & 0x040000); // no wvx stream w/ floats & big ints
+							$metablock['flags']['md5_checksum']   = (bool) ($metablock['flags_raw'] & 0x080000); // compute & store MD5 signature
+							$metablock['flags']['quiet_mode']     = (bool) ($metablock['flags_raw'] & 0x100000); // don't report progress %
+
+							$ThisFileInfo['wavpack']['config_flags'] = $metablock['flags'];
+
+
+							if ($ThisFileInfo['wavpack']['blockheader']['flags']['hybrid']) {
+								@$ThisFileInfo['audio']['encoder_options'] .= ' -b???';
+							}
+							@$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['adobe_mode']     ? ' -a' : '');
+							@$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['optimize_wvc']   ? ' -cc' : '');
+							@$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['create_exe']     ? ' -e' : '');
+							@$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['fast_flag']      ? ' -f' : '');
+							@$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['joint_override'] ? ' -j?' : '');
+							@$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['high_flag']      ? ' -h' : '');
+							@$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['md5_checksum']   ? ' -m' : '');
+							@$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['calc_noise']     ? ' -n' : '');
+							@$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['shape_override'] ? ' -s?' : '');
+							@$ThisFileInfo['audio']['encoder_options'] .= ($metablock['flags']['extra_mode']     ? ' -x?' : '');
+							if (@$ThisFileInfo['audio']['encoder_options']) {
+							    $ThisFileInfo['audio']['encoder_options'] = trim(@$ThisFileInfo['audio']['encoder_options']);
+							}
+							elseif (isset($ThisFileInfo['audio']['encoder_options'])) {
+							    unset($ThisFileInfo['audio']['encoder_options']);
+							}
+							break;
+
+
+						case 0x26: // ID_MD5_CHECKSUM
+							if (strlen($metablock['data']) == 16) {
+								$ThisFileInfo['md5_data_source'] = strtolower(getid3_lib::PrintHexBytes($metablock['data'], true, false, false));
+							} else {
+								$ThisFileInfo['warning'][] = 'Expecting 16 bytes of WavPack "MD5 Checksum" in metablock at offset '.$metablock['offset'].', but found '.strlen($metablock['data']).' bytes';
+							}
+							break;
+
+
+						case 0x00: // ID_DUMMY
+						case 0x01: // ID_ENCODER_INFO
+						case 0x02: // ID_DECORR_TERMS
+						case 0x03: // ID_DECORR_WEIGHTS
+						case 0x04: // ID_DECORR_SAMPLES
+						case 0x05: // ID_ENTROPY_VARS
+						case 0x06: // ID_HYBRID_PROFILE
+						case 0x07: // ID_SHAPING_WEIGHTS
+						case 0x08: // ID_FLOAT_INFO
+						case 0x09: // ID_INT32_INFO
+						case 0x0A: // ID_WV_BITSTREAM
+						case 0x0B: // ID_WVC_BITSTREAM
+						case 0x0C: // ID_WVX_BITSTREAM
+						case 0x0D: // ID_CHANNEL_INFO
+							unset($metablock);
+							break;
+					}
+
+				}
+				if (!empty($metablock)) {
+					$ThisFileInfo['wavpack']['metablocks'][] = $metablock;
+				}
+
+			}
+
+		}
+
+		$ThisFileInfo['audio']['encoder']         = 'WavPack v'.$ThisFileInfo['wavpack']['blockheader']['major_version'].'.'.str_pad($ThisFileInfo['wavpack']['blockheader']['minor_version'], 2, '0', STR_PAD_LEFT);
+		$ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['wavpack']['blockheader']['flags']['bytes_per_sample'] * 8;
+		$ThisFileInfo['audio']['channels']        = ($ThisFileInfo['wavpack']['blockheader']['flags']['mono'] ? 1 : 2);
+
+		if (@$ThisFileInfo['playtime_seconds']) {
+
+			$ThisFileInfo['audio']['bitrate']     = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds'];
+
+		} else {
+
+			$ThisFileInfo['audio']['dataformat']  = 'wvc';
+
+		}
+
+		return true;
+	}
+
+
+	function WavPackMetablockNameLookup(&$id) {
+		static $WavPackMetablockNameLookup = array(
+			0x00 => 'Dummy',
+			0x01 => 'Encoder Info',
+			0x02 => 'Decorrelation Terms',
+			0x03 => 'Decorrelation Weights',
+			0x04 => 'Decorrelation Samples',
+			0x05 => 'Entropy Variables',
+			0x06 => 'Hybrid Profile',
+			0x07 => 'Shaping Weights',
+			0x08 => 'Float Info',
+			0x09 => 'Int32 Info',
+			0x0A => 'WV Bitstream',
+			0x0B => 'WVC Bitstream',
+			0x0C => 'WVX Bitstream',
+			0x0D => 'Channel Info',
+			0x21 => 'RIFF header',
+			0x22 => 'RIFF trailer',
+			0x23 => 'Replay Gain',
+			0x24 => 'Cuesheet',
+			0x25 => 'Config Block',
+			0x26 => 'MD5 Checksum',
+		);
+		return (@$WavPackMetablockNameLookup[$id]);
+	}
+
+}
+
+
+?>
\ No newline at end of file

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.bmp.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.bmp.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.bmp.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_bmp
 {
 
@@ -27,16 +25,40 @@
 	    $thisfile_bmp_header                  = &$thisfile_bmp['header'];
 	    $thisfile_bmp_header_raw              = &$thisfile_bmp_header['raw'];
 
-		$ThisFileInfo['fileformat']                  = 'bmp';
-		$ThisFileInfo['video']['dataformat']         = 'bmp';
-		$ThisFileInfo['video']['lossless']           = true;
-		$ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
+		// BITMAPFILEHEADER [14 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_62uq.asp
+		// all versions
+		// WORD    bfType;
+		// DWORD   bfSize;
+		// WORD    bfReserved1;
+		// WORD    bfReserved2;
+		// DWORD   bfOffBits;
 
 		fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
 		$offset = 0;
-
 		$BMPheader = fread($fd, 14 + 40);
 
+		$thisfile_bmp_header_raw['identifier']  = substr($BMPheader, $offset, 2);
+		$offset += 2;
+
+		if ($thisfile_bmp_header_raw['identifier'] != 'BM') {
+			$ThisFileInfo['error'][] = 'Expecting "BM" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$thisfile_bmp_header_raw['identifier'].'"';
+			unset($ThisFileInfo['fileformat']);
+			unset($ThisFileInfo['bmp']);
+			return false;
+		}
+
+		$thisfile_bmp_header_raw['filesize']    = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 4));
+		$offset += 4;
+		$thisfile_bmp_header_raw['reserved1']   = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 2));
+		$offset += 2;
+		$thisfile_bmp_header_raw['reserved2']   = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 2));
+		$offset += 2;
+		$thisfile_bmp_header_raw['data_offset'] = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 4));
+		$offset += 4;
+		$thisfile_bmp_header_raw['header_size'] = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 4));
+		$offset += 4;
+
+
 		// check if the hardcoded-to-1 "planes" is at offset 22 or 26
 		$planes22 = getid3_lib::LittleEndian2Int(substr($BMPheader, 22, 2));
 		$planes26 = getid3_lib::LittleEndian2Int(substr($BMPheader, 26, 2));
@@ -58,34 +80,17 @@
 		} elseif ($thisfile_bmp_header_raw['header_size'] == 100) {
 			$thisfile_bmp['type_os']      = 'Windows';
 			$thisfile_bmp['type_version'] = 5;
-		}
-
-
-		// BITMAPFILEHEADER [14 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_62uq.asp
-		// all versions
-		// WORD    bfType;
-		// DWORD   bfSize;
-		// WORD    bfReserved1;
-		// WORD    bfReserved2;
-		// DWORD   bfOffBits;
-		$thisfile_bmp_header_raw['identifier']       =                  substr($BMPheader, $offset, 2);
-		$offset += 2;
-
-		if ($thisfile_bmp_header_raw['identifier'] != 'BM') {
-			$ThisFileInfo['error'][] = 'Expecting "BM" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$thisfile_bmp_header_raw['identifier'].'"';
+		} else {
+			$ThisFileInfo['error'][] = 'Unknown BMP subtype (or not a BMP file)';
 			unset($ThisFileInfo['fileformat']);
-			unset($thisfile_bmp);
+			unset($ThisFileInfo['bmp']);
 			return false;
 		}
 
-		$thisfile_bmp_header_raw['filesize']    = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 4));
-		$offset += 4;
-		$thisfile_bmp_header_raw['reserved1']   = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 2));
-		$offset += 2;
-		$thisfile_bmp_header_raw['reserved2']   = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 2));
-		$offset += 2;
-		$thisfile_bmp_header_raw['data_offset'] = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 4));
-		$offset += 4;
+		$ThisFileInfo['fileformat']                  = 'bmp';
+		$ThisFileInfo['video']['dataformat']         = 'bmp';
+		$ThisFileInfo['video']['lossless']           = true;
+		$ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
 
 		if ($thisfile_bmp['type_os'] == 'OS/2') {
 
@@ -98,8 +103,6 @@
 			// WORD   NumPlanes;        /* Number of bit planes (color depth) */
 			// WORD   BitsPerPixel;     /* Number of bits per pixel per plane */
 
-			$thisfile_bmp_header_raw['header_size']    = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 4));
-			$offset += 4;
 			$thisfile_bmp_header_raw['width']          = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 2));
 			$offset += 2;
 			$thisfile_bmp_header_raw['height']         = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 2));
@@ -182,8 +185,6 @@
 			// DWORD  biClrUsed;
 			// DWORD  biClrImportant;
 
-			$thisfile_bmp_header_raw['header_size']      = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 4));
-			$offset += 4;
 			$thisfile_bmp_header_raw['width']            = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 4), true);
 			$offset += 4;
 			$thisfile_bmp_header_raw['height']           = getid3_lib::LittleEndian2Int(substr($BMPheader, $offset, 4), true);
@@ -211,7 +212,8 @@
 			$ThisFileInfo['video']['codec']           = $thisfile_bmp_header['compression'].' '.$thisfile_bmp_header_raw['bits_per_pixel'].'-bit';
 			$ThisFileInfo['video']['bits_per_sample'] = $thisfile_bmp_header_raw['bits_per_pixel'];
 
-			if ($thisfile_bmp['type_version'] >= 4) {
+			if (($thisfile_bmp['type_version'] >= 4) || ($thisfile_bmp_header_raw['compression'] == 3)) {
+				// should only be v4+, but BMPs with type_version==1 and BI_BITFIELDS compression have been seen
 				$BMPheader .= fread($fd, 44);
 
 				// BITMAPV4HEADER - [44 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_2k1e.asp
@@ -296,9 +298,6 @@
 					// BYTE    rgbGreen;
 					// BYTE    rgbRed;
 					// BYTE    rgbReserved;
-					//$thisfile_bmp['palette']['blue'][$i]   = getid3_lib::LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
-					//$thisfile_bmp['palette']['green'][$i] = getid3_lib::LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
-					//$thisfile_bmp['palette']['red'][$i]  = getid3_lib::LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
 					$blue  = getid3_lib::LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
 					$green = getid3_lib::LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
 					$red   = getid3_lib::LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
@@ -307,7 +306,7 @@
 					} else {
 						$paletteoffset++; // padding byte
 					}
-					$thisfile_bmp['palette'][$i] = (($red << 16) | ($green << 8) | ($blue));
+					$thisfile_bmp['palette'][$i] = (($red << 16) | ($green << 8) | $blue);
 				}
 			}
 		}
@@ -317,14 +316,14 @@
 			$RowByteLength = ceil(($thisfile_bmp_header_raw['width'] * ($thisfile_bmp_header_raw['bits_per_pixel'] / 8)) / 4) * 4; // round up to nearest DWORD boundry
 			$BMPpixelData = fread($fd, $thisfile_bmp_header_raw['height'] * $RowByteLength);
 			$pixeldataoffset = 0;
-			switch ($thisfile_bmp_header_raw['compression']) {
+			switch (@$thisfile_bmp_header_raw['compression']) {
 
 				case 0: // BI_RGB
 					switch ($thisfile_bmp_header_raw['bits_per_pixel']) {
 						case 1:
 							for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
 								for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col = $col) {
-									$paletteindexbyte = getid3_lib::LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
+									$paletteindexbyte = ord($BMPpixelData{$pixeldataoffset++});
 									for ($i = 7; $i >= 0; $i--) {
 										$paletteindex = ($paletteindexbyte & (0x01 << $i)) >> $i;
 										$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
@@ -341,7 +340,7 @@
 						case 4:
 							for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
 								for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col = $col) {
-									$paletteindexbyte = getid3_lib::LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
+									$paletteindexbyte = ord($BMPpixelData{$pixeldataoffset++});
 									for ($i = 1; $i >= 0; $i--) {
 										$paletteindex = ($paletteindexbyte & (0x0F << (4 * $i))) >> (4 * $i);
 										$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
@@ -358,7 +357,7 @@
 						case 8:
 							for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
 								for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
-									$paletteindex = getid3_lib::LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
+									$paletteindex = ord($BMPpixelData{$pixeldataoffset++});
 									$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
 								}
 								while (($pixeldataoffset % 4) != 0) {
@@ -369,16 +368,23 @@
 							break;
 
 						case 24:
+							for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
+								for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
+									$thisfile_bmp['data'][$row][$col] = (ord($BMPpixelData{$pixeldataoffset+2}) << 16) | (ord($BMPpixelData{$pixeldataoffset+1}) << 8) | ord($BMPpixelData{$pixeldataoffset});
+									$pixeldataoffset += 3;
+								}
+								while (($pixeldataoffset % 4) != 0) {
+									// lines are padded to nearest DWORD
+									$pixeldataoffset++;
+								}
+							}
+							break;
+
 						case 32:
 							for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
 								for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
-									$blue  = getid3_lib::LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
-									$green = getid3_lib::LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
-									$red   = getid3_lib::LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
-									if ($thisfile_bmp_header_raw['bits_per_pixel'] == 32) {
-										$paletteoffset++; // filler byte
-									}
-									$thisfile_bmp['data'][$row][$col] = (($red << 16) | ($green << 8) | ($blue));
+									$thisfile_bmp['data'][$row][$col] = (ord($BMPpixelData{$pixeldataoffset+3}) << 24) | (ord($BMPpixelData{$pixeldataoffset+2}) << 16) | (ord($BMPpixelData{$pixeldataoffset+1}) << 8) | ord($BMPpixelData{$pixeldataoffset});
+									$pixeldataoffset += 4;
 								}
 								while (($pixeldataoffset % 4) != 0) {
 									// lines are padded to nearest DWORD
@@ -388,6 +394,8 @@
 							break;
 
 						case 16:
+							// ?
+							break;
 
 						default:
 							$ThisFileInfo['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
@@ -581,9 +589,9 @@
 									$pixelvalue = getid3_lib::LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset, $thisfile_bmp_header_raw['bits_per_pixel'] / 8));
 									$pixeldataoffset += $thisfile_bmp_header_raw['bits_per_pixel'] / 8;
 
-									$red   = round(((($pixelvalue & $thisfile_bmp_header_raw['red_mask'])   >> $redshift)   / ($thisfile_bmp_header_raw['red_mask']   >> $redshift))   * 255);
-									$green = round(((($pixelvalue & $thisfile_bmp_header_raw['green_mask']) >> $greenshift) / ($thisfile_bmp_header_raw['green_mask'] >> $greenshift)) * 255);
-									$blue  = round(((($pixelvalue & $thisfile_bmp_header_raw['blue_mask'])  >> $blueshift)  / ($thisfile_bmp_header_raw['blue_mask']  >> $blueshift))  * 255);
+									$red   = intval(round(((($pixelvalue & $thisfile_bmp_header_raw['red_mask'])   >> $redshift)   / ($thisfile_bmp_header_raw['red_mask']   >> $redshift))   * 255));
+									$green = intval(round(((($pixelvalue & $thisfile_bmp_header_raw['green_mask']) >> $greenshift) / ($thisfile_bmp_header_raw['green_mask'] >> $greenshift)) * 255));
+									$blue  = intval(round(((($pixelvalue & $thisfile_bmp_header_raw['blue_mask'])  >> $blueshift)  / ($thisfile_bmp_header_raw['blue_mask']  >> $blueshift))  * 255));
 									$thisfile_bmp['data'][$row][$col] = (($red << 16) | ($green << 8) | ($blue));
 								}
 								while (($pixeldataoffset % 4) != 0) {
@@ -616,7 +624,7 @@
 			echo 'ERROR: no pixel data<BR>';
 			return false;
 		}
-		set_time_limit(round($BMPinfo['resolution_x'] * $BMPinfo['resolution_y'] / 10000));
+		set_time_limit(intval(round($BMPinfo['resolution_x'] * $BMPinfo['resolution_y'] / 10000)));
 		if ($im = ImageCreateTrueColor($BMPinfo['resolution_x'], $BMPinfo['resolution_y'])) {
 			for ($row = 0; $row < $BMPinfo['resolution_y']; $row++) {
 				for ($col = 0; $col < $BMPinfo['resolution_x']; $col++) {

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.gif.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.gif.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.gif.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_gif
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.jpg.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.jpg.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.jpg.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_jpg
 {
 
@@ -50,13 +48,13 @@
 
 				} else {
 
-					$ThisFileInfo['warning'][] = 'EXIF parsing only available when compiled with --enable-exif (or php_exif.dll enabled for Windows)';
+					$ThisFileInfo['warning'][] = 'EXIF parsing only available when '.(GETID3_OS_ISWINDOWS ? 'php_exif.dll enabled' : 'compiled with --enable-exif');
 
 				}
 
 			} else {
 
-				$ThisFileInfo['warning'][] = 'EXIF parsing only available in PHP v4.2.0 and higher (you are using PHP v'.phpversion().') compiled with --enable-exif (or php_exif.dll enabled for Windows)';
+				$ThisFileInfo['warning'][] = 'EXIF parsing only available in PHP v4.2.0 and higher compiled with --enable-exif (or php_exif.dll enabled for Windows). You are using PHP v'.phpversion();
 
 			}
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.pcd.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.pcd.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.pcd.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_pcd
 {
 	function getid3_pcd(&$fd, &$ThisFileInfo, $ExtractData=0) {
@@ -65,8 +63,8 @@
 
 				$PCD_data_Y1 = fread($fd, $PCD_width);
 				$PCD_data_Y2 = fread($fd, $PCD_width);
-				$PCD_data_Cb = fread($fd, round($PCD_width / 2));
-				$PCD_data_Cr = fread($fd, round($PCD_width / 2));
+				$PCD_data_Cb = fread($fd, intval(round($PCD_width / 2)));
+				$PCD_data_Cr = fread($fd, intval(round($PCD_width / 2)));
 
 				for ($x = 0; $x < $PCD_width; $x++) {
 					if ($PCDisVertical) {
@@ -114,10 +112,12 @@
 		foreach ($RGBcolor as $rgbname => $dummy) {
 			$RGBcolor[$rgbname] = max(0,
 										min(255,
-											round(
-												($YCbCr_constants[$rgbname]['Y'] * $Y) +
-												($YCbCr_constants[$rgbname]['Cb'] * ($Cb - 156)) +
-												($YCbCr_constants[$rgbname]['Cr'] * ($Cr - 137))
+											intval(
+												round(
+													($YCbCr_constants[$rgbname]['Y'] * $Y) +
+													($YCbCr_constants[$rgbname]['Cb'] * ($Cb - 156)) +
+													($YCbCr_constants[$rgbname]['Cr'] * ($Cr - 137))
+												)
 											)
 										)
 									);

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.png.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.png.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.png.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_png
 {
 
@@ -113,8 +111,8 @@
 
 						case 2:
 							$thisfile_png_chunk_type_text['transparent_color_red']   = getid3_lib::BigEndian2Int(substr($thisfile_png_chunk_type_text['header']['data'], 0, 2));
-							$thisfile_png_chunk_type_text['transparent_color_green'] = getid3_lib::BigEndian2Int(substr($thisfile_png_chunk_type_text['header']['data'], 0, 2));
-							$thisfile_png_chunk_type_text['transparent_color_blue']  = getid3_lib::BigEndian2Int(substr($thisfile_png_chunk_type_text['header']['data'], 0, 2));
+							$thisfile_png_chunk_type_text['transparent_color_green'] = getid3_lib::BigEndian2Int(substr($thisfile_png_chunk_type_text['header']['data'], 2, 2));
+							$thisfile_png_chunk_type_text['transparent_color_blue']  = getid3_lib::BigEndian2Int(substr($thisfile_png_chunk_type_text['header']['data'], 4, 2));
 							break;
 
 						case 3:

Added: plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.tiff.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.tiff.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.graphic.tiff.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -0,0 +1,221 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info at getid3.org>               //
+//  available at http://getid3.sourceforge.net                 //
+//            or http://www.getid3.org                         //
+/////////////////////////////////////////////////////////////////
+// See readme.txt for more details                             //
+/////////////////////////////////////////////////////////////////
+//                                                             //
+// module.archive.tiff.php                                     //
+// module for analyzing TIFF files                             //
+// dependencies: NONE                                          //
+//                                                            ///
+/////////////////////////////////////////////////////////////////
+
+
+class getid3_tiff
+{
+
+	function getid3_tiff(&$fd, &$ThisFileInfo) {
+
+		fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
+		$TIFFheader = fread($fd, 4);
+
+		switch (substr($TIFFheader, 0, 2)) {
+			case 'II':
+				$ThisFileInfo['tiff']['byte_order'] = 'Intel';
+				break;
+			case 'MM':
+				$ThisFileInfo['tiff']['byte_order'] = 'Motorola';
+				break;
+			default:
+				$ThisFileInfo['error'][] = 'Invalid TIFF byte order identifier ('.substr($TIFFheader, 0, 2).') at offset '.$ThisFileInfo['avdataoffset'];
+				return false;
+				break;
+		}
+
+		$ThisFileInfo['fileformat']          = 'tiff';
+		$ThisFileInfo['video']['dataformat'] = 'tiff';
+		$ThisFileInfo['video']['lossless']   = true;
+		$ThisFileInfo['tiff']['ifd']         = array();
+		$CurrentIFD                          = array();
+
+		$FieldTypeByteLength = array(1=>1, 2=>1, 3=>2, 4=>4, 5=>8);
+
+		$nextIFDoffset = $this->TIFFendian2Int(fread($fd, 4), $ThisFileInfo['tiff']['byte_order']);
+
+		while ($nextIFDoffset > 0) {
+
+			$CurrentIFD['offset'] = $nextIFDoffset;
+
+			fseek($fd, $ThisFileInfo['avdataoffset'] + $nextIFDoffset, SEEK_SET);
+			$CurrentIFD['fieldcount'] = $this->TIFFendian2Int(fread($fd, 2), $ThisFileInfo['tiff']['byte_order']);
+
+			for ($i = 0; $i < $CurrentIFD['fieldcount']; $i++) {
+				$CurrentIFD['fields'][$i]['raw']['tag']    = $this->TIFFendian2Int(fread($fd, 2), $ThisFileInfo['tiff']['byte_order']);
+				$CurrentIFD['fields'][$i]['raw']['type']   = $this->TIFFendian2Int(fread($fd, 2), $ThisFileInfo['tiff']['byte_order']);
+				$CurrentIFD['fields'][$i]['raw']['length'] = $this->TIFFendian2Int(fread($fd, 4), $ThisFileInfo['tiff']['byte_order']);
+				$CurrentIFD['fields'][$i]['raw']['offset'] =                       fread($fd, 4);
+
+				switch ($CurrentIFD['fields'][$i]['raw']['type']) {
+					case 1: // BYTE  An 8-bit unsigned integer.
+						if ($CurrentIFD['fields'][$i]['raw']['length'] <= 4) {
+							$CurrentIFD['fields'][$i]['value']  = $this->TIFFendian2Int(substr($CurrentIFD['fields'][$i]['raw']['offset'], 0, 1), $ThisFileInfo['tiff']['byte_order']);
+						} else {
+							$CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $ThisFileInfo['tiff']['byte_order']);
+						}
+						break;
+
+					case 2: // ASCII 8-bit bytes  that store ASCII codes; the last byte must be null.
+						if ($CurrentIFD['fields'][$i]['raw']['length'] <= 4) {
+							$CurrentIFD['fields'][$i]['value']  = substr($CurrentIFD['fields'][$i]['raw']['offset'], 3);
+						} else {
+							$CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $ThisFileInfo['tiff']['byte_order']);
+						}
+						break;
+
+					case 3: // SHORT A 16-bit (2-byte) unsigned integer.
+						if ($CurrentIFD['fields'][$i]['raw']['length'] <= 2) {
+							$CurrentIFD['fields'][$i]['value']  = $this->TIFFendian2Int(substr($CurrentIFD['fields'][$i]['raw']['offset'], 0, 2), $ThisFileInfo['tiff']['byte_order']);
+						} else {
+							$CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $ThisFileInfo['tiff']['byte_order']);
+						}
+						break;
+
+					case 4: // LONG  A 32-bit (4-byte) unsigned integer.
+						if ($CurrentIFD['fields'][$i]['raw']['length'] <= 1) {
+							$CurrentIFD['fields'][$i]['value']  = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $ThisFileInfo['tiff']['byte_order']);
+						} else {
+							$CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['offset'], $ThisFileInfo['tiff']['byte_order']);
+						}
+						break;
+
+					case 5: // RATIONAL   Two LONG_s:  the first represents the numerator of a fraction, the second the denominator.
+						break;
+				}
+			}
+
+			$ThisFileInfo['tiff']['ifd'][] = $CurrentIFD;
+			$CurrentIFD = array();
+			$nextIFDoffset = $this->TIFFendian2Int(fread($fd, 4), $ThisFileInfo['tiff']['byte_order']);
+
+		}
+
+		foreach ($ThisFileInfo['tiff']['ifd'] as $IFDid => $IFDarray) {
+			foreach ($IFDarray['fields'] as $key => $fieldarray) {
+				switch ($fieldarray['raw']['tag']) {
+					case 256: // ImageWidth
+					case 257: // ImageLength
+					case 258: // BitsPerSample
+					case 259: // Compression
+						if (!isset($fieldarray['value'])) {
+							fseek($fd, $fieldarray['offset'], SEEK_SET);
+							$ThisFileInfo['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'] = fread($fd, $fieldarray['raw']['length'] * $FieldTypeByteLength[$fieldarray['raw']['type']]);
+
+						}
+						break;
+
+					case 270: // ImageDescription
+					case 271: // Make
+					case 272: // Model
+					case 305: // Software
+					case 306: // DateTime
+					case 315: // Artist
+					case 316: // HostComputer
+						if (isset($fieldarray['value'])) {
+							$ThisFileInfo['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'] = $fieldarray['value'];
+						} else {
+							fseek($fd, $fieldarray['offset'], SEEK_SET);
+							$ThisFileInfo['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'] = fread($fd, $fieldarray['raw']['length'] * $FieldTypeByteLength[$fieldarray['raw']['type']]);
+
+						}
+						break;
+				}
+				switch ($fieldarray['raw']['tag']) {
+					case 256: // ImageWidth
+						$ThisFileInfo['video']['resolution_x'] = $fieldarray['value'];
+						break;
+
+					case 257: // ImageLength
+						$ThisFileInfo['video']['resolution_y'] = $fieldarray['value'];
+						break;
+
+					case 258: // BitsPerSample
+						if (isset($fieldarray['value'])) {
+							$ThisFileInfo['video']['bits_per_sample'] = $fieldarray['value'];
+						} else {
+							$ThisFileInfo['video']['bits_per_sample'] = 0;
+							for ($i = 0; $i < $fieldarray['raw']['length']; $i++) {
+								$ThisFileInfo['video']['bits_per_sample'] += $this->TIFFendian2Int(substr($ThisFileInfo['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'], $i * $FieldTypeByteLength[$fieldarray['raw']['type']], $FieldTypeByteLength[$fieldarray['raw']['type']]), $ThisFileInfo['tiff']['byte_order']);
+							}
+						}
+						break;
+
+					case 259: // Compression
+						$ThisFileInfo['video']['codec'] = $this->TIFFcompressionMethod($fieldarray['value']);
+						break;
+
+					case 270: // ImageDescription
+					case 271: // Make
+					case 272: // Model
+					case 305: // Software
+					case 306: // DateTime
+					case 315: // Artist
+					case 316: // HostComputer
+						@$ThisFileInfo['tiff']['comments'][$this->TIFFcommentName($fieldarray['raw']['tag'])][] = $ThisFileInfo['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'];
+						break;
+
+					default:
+						break;
+				}
+			}
+		}
+
+		return true;
+	}
+
+
+	function TIFFendian2Int($bytestring, $byteorder) {
+		if ($byteorder == 'Intel') {
+			return getid3_lib::LittleEndian2Int($bytestring);
+		} elseif ($byteorder == 'Motorola') {
+			return getid3_lib::BigEndian2Int($bytestring);
+		}
+		return false;
+	}
+
+	function TIFFcompressionMethod($id) {
+		static $TIFFcompressionMethod = array();
+		if (empty($TIFFcompressionMethod)) {
+			$TIFFcompressionMethod = array(
+				1     => 'Uncompressed',
+				2     => 'Huffman',
+				3     => 'Fax - CCITT 3',
+				5     => 'LZW',
+				32773 => 'PackBits',
+			);
+		}
+		return (isset($TIFFcompressionMethod[$id]) ? $TIFFcompressionMethod[$id] : 'unknown/invalid ('.$id.')');
+	}
+
+	function TIFFcommentName($id) {
+		static $TIFFcommentName = array();
+		if (empty($TIFFcommentName)) {
+			$TIFFcommentName = array(
+				270 => 'imagedescription',
+				271 => 'make',
+				272 => 'model',
+				305 => 'software',
+				306 => 'datetime',
+				315 => 'artist',
+				316 => 'hostcomputer',
+			);
+		}
+		return (isset($TIFFcommentName[$id]) ? $TIFFcommentName[$id] : 'unknown/invalid ('.$id.')');
+	}
+
+}
+
+
+?>
\ No newline at end of file

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.misc.exe.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.misc.exe.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.misc.exe.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,19 +13,44 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_exe
 {
 
 	function getid3_exe(&$fd, &$ThisFileInfo) {
 
+		fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
+		$EXEheader = fread($fd, 28);
+
+		if (substr($EXEheader, 0, 2) != 'MZ') {
+			$ThisFileInfo['error'][] = 'Expecting "MZ" at offset '.$ThisFileInfo['avdataoffset'].', found "'.substr($EXEheader, 0, 2).'" instead.';
+			return false;
+		}
+
 		$ThisFileInfo['fileformat'] = 'exe';
+		$ThisFileInfo['exe']['mz']['magic'] = 'MZ';
 
-		$ThisFileInfo['error'][] = 'EXE parsing not enabled in this version of getID3()';
-		return false;
+		$ThisFileInfo['exe']['mz']['raw']['last_page_size']          = getid3_lib::LittleEndian2Int(substr($EXEheader,  2, 2));
+		$ThisFileInfo['exe']['mz']['raw']['page_count']              = getid3_lib::LittleEndian2Int(substr($EXEheader,  4, 2));
+		$ThisFileInfo['exe']['mz']['raw']['relocation_count']        = getid3_lib::LittleEndian2Int(substr($EXEheader,  6, 2));
+		$ThisFileInfo['exe']['mz']['raw']['header_paragraphs']       = getid3_lib::LittleEndian2Int(substr($EXEheader,  8, 2));
+		$ThisFileInfo['exe']['mz']['raw']['min_memory_paragraphs']   = getid3_lib::LittleEndian2Int(substr($EXEheader, 10, 2));
+		$ThisFileInfo['exe']['mz']['raw']['max_memory_paragraphs']   = getid3_lib::LittleEndian2Int(substr($EXEheader, 12, 2));
+		$ThisFileInfo['exe']['mz']['raw']['initial_ss']              = getid3_lib::LittleEndian2Int(substr($EXEheader, 14, 2));
+		$ThisFileInfo['exe']['mz']['raw']['initial_sp']              = getid3_lib::LittleEndian2Int(substr($EXEheader, 16, 2));
+		$ThisFileInfo['exe']['mz']['raw']['checksum']                = getid3_lib::LittleEndian2Int(substr($EXEheader, 18, 2));
+		$ThisFileInfo['exe']['mz']['raw']['cs_ip']                   = getid3_lib::LittleEndian2Int(substr($EXEheader, 20, 4));
+		$ThisFileInfo['exe']['mz']['raw']['relocation_table_offset'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 24, 2));
+		$ThisFileInfo['exe']['mz']['raw']['overlay_number']          = getid3_lib::LittleEndian2Int(substr($EXEheader, 26, 2));
 
+		$ThisFileInfo['exe']['mz']['byte_size']          = (($ThisFileInfo['exe']['mz']['raw']['page_count'] - 1)) * 512 + $ThisFileInfo['exe']['mz']['raw']['last_page_size'];
+		$ThisFileInfo['exe']['mz']['header_size']        = $ThisFileInfo['exe']['mz']['raw']['header_paragraphs'] * 16;
+		$ThisFileInfo['exe']['mz']['memory_minimum']     = $ThisFileInfo['exe']['mz']['raw']['min_memory_paragraphs'] * 16;
+		$ThisFileInfo['exe']['mz']['memory_recommended'] = $ThisFileInfo['exe']['mz']['raw']['max_memory_paragraphs'] * 16;
+
+$ThisFileInfo['error'][] = 'EXE parsing not enabled in this version of getID3()';
+return false;
+
 	}
 
 }

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.misc.iso.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.misc.iso.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.misc.iso.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_iso
 {
 
@@ -78,12 +76,12 @@
 
 
 		$thisfile_iso_primaryVD_raw['volume_descriptor_version']     = getid3_lib::LittleEndian2Int(substr($ISOheader,    6, 1));
-		$thisfile_iso_primaryVD_raw['unused_1']                      =                              substr($ISOheader,    7, 1);
+		//$thisfile_iso_primaryVD_raw['unused_1']                      =                              substr($ISOheader,    7, 1);
 		$thisfile_iso_primaryVD_raw['system_identifier']             =                              substr($ISOheader,    8, 32);
 		$thisfile_iso_primaryVD_raw['volume_identifier']             =                              substr($ISOheader,   40, 32);
-		$thisfile_iso_primaryVD_raw['unused_2']                      =                              substr($ISOheader,   72, 8);
+		//$thisfile_iso_primaryVD_raw['unused_2']                      =                              substr($ISOheader,   72, 8);
 		$thisfile_iso_primaryVD_raw['volume_space_size']             = getid3_lib::LittleEndian2Int(substr($ISOheader,   80, 4));
-		$thisfile_iso_primaryVD_raw['unused_3']                      =                              substr($ISOheader,   88, 32);
+		//$thisfile_iso_primaryVD_raw['unused_3']                      =                              substr($ISOheader,   88, 32);
 		$thisfile_iso_primaryVD_raw['volume_set_size']               = getid3_lib::LittleEndian2Int(substr($ISOheader,  120, 2));
 		$thisfile_iso_primaryVD_raw['volume_sequence_number']        = getid3_lib::LittleEndian2Int(substr($ISOheader,  124, 2));
 		$thisfile_iso_primaryVD_raw['logical_block_size']            = getid3_lib::LittleEndian2Int(substr($ISOheader,  128, 2));
@@ -105,7 +103,7 @@
 		$thisfile_iso_primaryVD_raw['volume_expiration_date_time']   =                              substr($ISOheader,  847, 17);
 		$thisfile_iso_primaryVD_raw['volume_effective_date_time']    =                              substr($ISOheader,  864, 17);
 		$thisfile_iso_primaryVD_raw['file_structure_version']        = getid3_lib::LittleEndian2Int(substr($ISOheader,  881, 1));
-		$thisfile_iso_primaryVD_raw['unused_4']                      = getid3_lib::LittleEndian2Int(substr($ISOheader,  882, 1));
+		//$thisfile_iso_primaryVD_raw['unused_4']                      = getid3_lib::LittleEndian2Int(substr($ISOheader,  882, 1));
 		$thisfile_iso_primaryVD_raw['application_data']              =                              substr($ISOheader,  883, 512);
 		//$thisfile_iso_primaryVD_raw['unused_5']                      =                              substr($ISOheader, 1395, 653);
 
@@ -150,10 +148,10 @@
 		}
 
 		$thisfile_iso_supplementaryVD_raw['volume_descriptor_version'] = getid3_lib::LittleEndian2Int(substr($ISOheader,    6, 1));
-		$thisfile_iso_supplementaryVD_raw['unused_1']                  =                              substr($ISOheader,    7, 1);
+		//$thisfile_iso_supplementaryVD_raw['unused_1']                  =                              substr($ISOheader,    7, 1);
 		$thisfile_iso_supplementaryVD_raw['system_identifier']         =                              substr($ISOheader,    8, 32);
 		$thisfile_iso_supplementaryVD_raw['volume_identifier']         =                              substr($ISOheader,   40, 32);
-		$thisfile_iso_supplementaryVD_raw['unused_2']                  =                              substr($ISOheader,   72, 8);
+		//$thisfile_iso_supplementaryVD_raw['unused_2']                  =                              substr($ISOheader,   72, 8);
 		$thisfile_iso_supplementaryVD_raw['volume_space_size']         = getid3_lib::LittleEndian2Int(substr($ISOheader,   80, 4));
 		if ($thisfile_iso_supplementaryVD_raw['volume_space_size'] == 0) {
 			// Supplementary Volume Descriptor not used
@@ -161,7 +159,7 @@
 			//return false;
 		}
 
-		$thisfile_iso_supplementaryVD_raw['unused_3']                       =                              substr($ISOheader,   88, 32);
+		//$thisfile_iso_supplementaryVD_raw['unused_3']                       =                              substr($ISOheader,   88, 32);
 		$thisfile_iso_supplementaryVD_raw['volume_set_size']                = getid3_lib::LittleEndian2Int(substr($ISOheader,  120, 2));
 		$thisfile_iso_supplementaryVD_raw['volume_sequence_number']         = getid3_lib::LittleEndian2Int(substr($ISOheader,  124, 2));
 		$thisfile_iso_supplementaryVD_raw['logical_block_size']             = getid3_lib::LittleEndian2Int(substr($ISOheader,  128, 2));
@@ -183,7 +181,7 @@
 		$thisfile_iso_supplementaryVD_raw['volume_expiration_date_time']    =                              substr($ISOheader,  847, 17);
 		$thisfile_iso_supplementaryVD_raw['volume_effective_date_time']     =                              substr($ISOheader,  864, 17);
 		$thisfile_iso_supplementaryVD_raw['file_structure_version']         = getid3_lib::LittleEndian2Int(substr($ISOheader,  881, 1));
-		$thisfile_iso_supplementaryVD_raw['unused_4']                       = getid3_lib::LittleEndian2Int(substr($ISOheader,  882, 1));
+		//$thisfile_iso_supplementaryVD_raw['unused_4']                       = getid3_lib::LittleEndian2Int(substr($ISOheader,  882, 1));
 		$thisfile_iso_supplementaryVD_raw['application_data']               =                              substr($ISOheader,  883, 512);
 		//$thisfile_iso_supplementaryVD_raw['unused_5']                       =                              substr($ISOheader, 1395, 653);
 
@@ -274,7 +272,6 @@
 			$TextEncoding = 'ISO-8859-1'; // Latin-1
 		}
 
-
 		fseek($fd, $directorydata['location_bytes'], SEEK_SET);
 		$DirectoryRecordData = fread($fd, 1);
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.apetag.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.apetag.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.apetag.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,6 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
 class getid3_apetag
 {
 
@@ -105,7 +102,7 @@
 		// shortcut
 		$ThisFileInfo['replay_gain'] = array();
 		$thisfile_replaygain = &$ThisFileInfo['replay_gain'];
-
+		
 		for ($i = 0; $i < $thisfile_ape['footer']['raw']['tag_items']; $i++) {
 			$value_size = getid3_lib::LittleEndian2Int(substr($APEtagData, $offset, 4));
 			$offset += 4;

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.id3v1.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.id3v1.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.id3v1.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,9 +13,7 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_id3v1
 {
 

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.id3v2.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.id3v2.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.id3v2.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -15,9 +15,6 @@
 
 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v1.php', __FILE__, true);
 
-/**
- * \ingroup getid3
- */
 class getid3_id3v2
 {
 
@@ -47,8 +44,8 @@
 		// shortcuts
 		$ThisFileInfo['id3v2']['header'] = true;
 		$thisfile_id3v2                  = &$ThisFileInfo['id3v2'];
-		$thisfile_id3v2['flags'] = array();
-		$thisfile_id3v2_flags    = &$thisfile_id3v2['flags'];
+		$thisfile_id3v2['flags']         =  array();
+		$thisfile_id3v2_flags            = &$thisfile_id3v2['flags'];
 
 
 		fseek($fd, $StartingOffset, SEEK_SET);
@@ -169,6 +166,7 @@
 			$sizeofframes -= 10; // footer takes last 10 bytes of ID3v2 header, after frame data, before audio
 		}
 		if ($sizeofframes > 0) {
+
 			$framedata = fread($fd, $sizeofframes); // read all frames from file into $framedata variable
 
 			//    if entire frame data is unsynched, de-unsynch it now (ID3v2.3.x)
@@ -379,7 +377,7 @@
 		if (isset($thisfile_id3v2['comments']['track'])) {
 			foreach ($thisfile_id3v2['comments']['track'] as $key => $value) {
 				if (strstr($value, '/')) {
-					list($thisfile_id3v2['comments']['track'][$key], $thisfile_id3v2['comments']['totaltracks'][$key]) = explode('/', $thisfile_id3v2['comments']['track'][$key]);
+					list($thisfile_id3v2['comments']['tracknum'][$key], $thisfile_id3v2['comments']['totaltracks'][$key]) = explode('/', $thisfile_id3v2['comments']['track'][$key]);
 				}
 			}
 		}
@@ -500,7 +498,13 @@
 			//    Frame-level de-compression
 			if ($parsedFrame['flags']['compression']) {
 				$parsedFrame['decompressed_size'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 4));
-				$parsedFrame['data'] = gzuncompress(substr($parsedFrame['data'], 4));
+				if (!function_exists('gzuncompress')) {
+					$ThisFileInfo['warning'][] = 'gzuncompress() support required to decompress ID3v2 frame "'.$parsedFrame['frame_name'].'"';
+				} elseif ($decompresseddata = @gzuncompress(substr($parsedFrame['data'], 4))) {
+					$parsedFrame['data'] = $decompresseddata;
+				} else {
+					$ThisFileInfo['warning'][] = 'gzuncompress() failed on compressed contents of ID3v2 frame "'.$parsedFrame['frame_name'].'"';
+				}
 			}
 		}
 
@@ -543,6 +547,7 @@
 
 			$frame_offset = 0;
 			$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
+
 			if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
 				$ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
 			}
@@ -874,32 +879,40 @@
 			// Short content descrip. <text string according to encoding> $00 (00)
 			// The actual text        <full text string according to encoding>
 
-			$frame_offset = 0;
-			$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
-			if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
-				$ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
-			}
-			$frame_language = substr($parsedFrame['data'], $frame_offset, 3);
-			$frame_offset += 3;
-			$frame_terminatorpos = strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
-			if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)), 1)) === 0) {
-				$frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00
-			}
-			$frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
-			if (ord($frame_description) === 0) {
-				$frame_description = '';
-			}
-			$frame_text = (string) substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)));
+			if (strlen($parsedFrame['data']) < 5) {
 
-			$parsedFrame['encodingid']   = $frame_textencoding;
-			$parsedFrame['encoding']     = $this->TextEncodingNameLookup($frame_textencoding);
+				$ThisFileInfo['warning'][] = 'Invalid data (too short) for "'.$parsedFrame['frame_name'].'" frame at offset '.$parsedFrame['dataoffset'];
 
-			$parsedFrame['language']     = $frame_language;
-			$parsedFrame['languagename'] = $this->LanguageLookup($frame_language, false);
-			$parsedFrame['description']  = $frame_description;
-			$parsedFrame['data']         = $frame_text;
-			if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
-				$ThisFileInfo['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $ThisFileInfo['id3v2']['encoding'], $parsedFrame['data']);
+			} else {
+
+				$frame_offset = 0;
+				$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
+				if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) {
+					$ThisFileInfo['warning'][] = 'Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding';
+				}
+				$frame_language = substr($parsedFrame['data'], $frame_offset, 3);
+				$frame_offset += 3;
+				$frame_terminatorpos = strpos($parsedFrame['data'], $this->TextEncodingTerminatorLookup($frame_textencoding), $frame_offset);
+				if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)), 1)) === 0) {
+					$frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00
+				}
+				$frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset);
+				if (ord($frame_description) === 0) {
+					$frame_description = '';
+				}
+				$frame_text = (string) substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)));
+
+				$parsedFrame['encodingid']   = $frame_textencoding;
+				$parsedFrame['encoding']     = $this->TextEncodingNameLookup($frame_textencoding);
+
+				$parsedFrame['language']     = $frame_language;
+				$parsedFrame['languagename'] = $this->LanguageLookup($frame_language, false);
+				$parsedFrame['description']  = $frame_description;
+				$parsedFrame['data']         = $frame_text;
+				if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
+					$ThisFileInfo['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $ThisFileInfo['id3v2']['encoding'], $parsedFrame['data']);
+				}
+
 			}
 
 		} elseif (($id3v2_majorversion >= 4) && ($parsedFrame['frame_name'] == 'RVA2')) { // 4.11  RVA2 Relative volume adjustment (2) (ID3v2.4+ only)
@@ -1190,7 +1203,7 @@
 
 			$imagechunkcheck = getid3_lib::GetDataImageSize($parsedFrame['data']);
 			if (($imagechunkcheck[2] >= 1) && ($imagechunkcheck[2] <= 3)) {
-				$parsedFrame['image_mime']       = getid3_lib::ImageTypesLookup($imagechunkcheck[2]);
+				$parsedFrame['image_mime']       = 'image/'.getid3_lib::ImageTypesLookup($imagechunkcheck[2]);
 				if ($imagechunkcheck[0]) {
 					$parsedFrame['image_width']  = $imagechunkcheck[0];
 				}
@@ -2928,7 +2941,7 @@
 			WCP	copyright
 			WOAF	url_file
 			WOAR	url_artist
-			WOAS	url_souce
+			WOAS	url_source
 			WORS	url_station
 			WPB	url_publisher
 			WPUB	url_publisher
@@ -2958,7 +2971,7 @@
 	function TextEncodingNameLookup($encoding) {
 		// http://www.id3.org/id3v2.4.0-structure.txt
 		static $TextEncodingNameLookup = array(0=>'ISO-8859-1', 1=>'UTF-16', 2=>'UTF-16BE', 3=>'UTF-8', 255=>'UTF-16BE');
-		return @$TextEncodingNameLookup[$encoding];
+		return (isset($TextEncodingNameLookup[$encoding]) ? $TextEncodingNameLookup[$encoding] : 'ISO-8859-1');
 	}
 
 	function IsValidID3v2FrameName($framename, $id3v2majorversion) {

Modified: plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.lyrics3.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.lyrics3.php	2005-07-14 14:06:18 UTC (rev 2321)
+++ plog/branches/plog-1.0.2/class/gallery/getid3/module.tag.lyrics3.php	2005-07-14 14:16:41 UTC (rev 2322)
@@ -13,17 +13,15 @@
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
-/**
- * \ingroup getid3
- */
+
 class getid3_lyrics3
 {
 
 	function getid3_lyrics3(&$fd, &$ThisFileInfo) {
 		// http://www.volweb.cz/str/tags.htm
 
-		fseek($fd, (0 - 128 - 9 - 6), SEEK_END); // end - ID3v1 - LYRICSEND - [Lyrics3size]
-		$lyrics3_id3v1 = fread($fd, (128 + 9 + 6));
+		fseek($fd, (0 - 128 - 9 - 6), SEEK_END);          // end - ID3v1 - LYRICSEND - [Lyrics3size]
+		$lyrics3_id3v1 = fread($fd, 128 + 9 + 6);
 		$lyrics3lsz    = substr($lyrics3_id3v1,  0,   6); // Lyrics3size
 		$lyrics3end    = substr($lyrics3_id3v1,  6,   9); // LYRICSEND or LYRICS200
 		$id3v1tag      = substr($lyrics3_id3v1, 15, 128); // ID3v1
@@ -110,6 +108,9 @@
 		// http://www.volweb.cz/str/tags.htm
 
 		fseek($fd, $endoffset, SEEK_SET);
+		if ($length <= 0) {
+			return false;
+		}
 		$rawdata = fread($fd, $length);
 
 		if (substr($rawdata, 0, 11) != 'LYRICSBEGIN') {
@@ -154,7 +155,7 @@
 					while (strlen($rawdata) > 0) {
 						$fieldname = substr($rawdata, 0, 3);
 						$fieldsize = (int) substr($rawdata, 3, 5);
-						$ParsedLyrics3['raw']["$fieldname"] = substr($rawdata, 8, $fieldsize);
+						$ParsedLyrics3['raw'][$fieldname] = substr($rawdata, 8, $fieldsize);
 						$rawdata = substr($rawdata, 3 + 5 + $fieldsize);
 					}
 
@@ -163,15 +164,15 @@
 						$flagnames = array('lyrics', 'timestamps', 'inhibitrandom');
 						foreach ($flagnames as $flagname) {
 							if (strlen($ParsedLyrics3['raw']['IND']) > ++$i) {
-								$ParsedLyrics3['flags']["$flagname"] = $this->IntString2Bool(substr($ParsedLyrics3['raw']['IND'], $i, 1));
+								$ParsedLyrics3['flags'][$flagname] = $this->IntString2Bool(substr($ParsedLyrics3['raw']['IND'], $i, 1));
 							}
 						}
 					}
 
 					$fieldnametranslation = array('ETT'=>'title', 'EAR'=>'artist', 'EAL'=>'album', 'INF'=>'comment', 'AUT'=>'author');
 					foreach ($fieldnametranslation as $key => $value) {
-						if (isset($ParsedLyrics3['raw']["$key"])) {
-							$ParsedLyrics3['comments']["$value"][] = trim($ParsedLyrics3['raw']["$key"]);
+						if (isset($ParsedLyrics3['raw'][$key])) {
+							$ParsedLyrics3['comments'][$value][] = trim($ParsedLyrics3['raw'][$key]);
 						}
 					}
 
@@ -180,9 +181,9 @@
 						foreach ($imagestrings as $key => $imagestring) {
 							if (strpos($imagestring, '||') !== false) {
 								$imagearray = explode('||', $imagestring);
-								$ParsedLyrics3['images']["$key"]['filename']     = $imagearray[0];
-								$ParsedLyrics3['images']["$key"]['description']  = $imagearray[1];
-								$ParsedLyrics3['images']["$key"]['timestamp']    = $this->Lyrics3Timestamp2Seconds($imagearray[2]);
+								$ParsedLyrics3['images'][$key]['filename']     = $imagearray[0];
+								$ParsedLyrics3['images'][$key]['description']  = $imagearray[1];
+								$ParsedLyrics3['images'][$key]['timestamp']    = $this->Lyrics3Timestamp2Seconds($imagearray[2]);
 							}
 						}
 					}
@@ -235,7 +236,7 @@
 				$thislinetimestamps[] = $this->Lyrics3Timestamp2Seconds($regs[0]);
 				$lyricline = str_replace($regs[0], '', $lyricline);
 			}
-			$notimestamplyricsarray["$key"] = $lyricline;
+			$notimestamplyricsarray[$key] = $lyricline;
 			if (isset($thislinetimestamps) && is_array($thislinetimestamps)) {
 				sort($thislinetimestamps);
 				foreach ($thislinetimestamps as $timestampkey => $timestamp) {




More information about the pLog-svn mailing list