/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
+// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
// //
// getid3.lib.php - part of getID3() //
}
} else {
throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits ('.strlen($byteword).') in self::BigEndian2Int()');
- break;
}
}
return self::CastAsInt($intvalue);
}
if (is_readable($filename_source) && is_file($filename_source) && ($fp_src = fopen($filename_source, 'rb'))) {
if (($fp_dest = fopen($filename_dest, 'wb'))) {
- if (fseek($fp_src, $offset, SEEK_SET) == 0) {
+ if (fseek($fp_src, $offset) == 0) {
$byteslefttowrite = $length;
while (($byteslefttowrite > 0) && ($buffer = fread($fp_src, min($byteslefttowrite, getID3::FREAD_BUFFER_SIZE)))) {
$byteswritten = fwrite($fp_dest, $buffer, $byteslefttowrite);
throw new Exception('PHP does not have iconv() support - cannot convert from '.$in_charset.' to '.$out_charset);
}
+ public static function recursiveMultiByteCharString2HTML($data, $charset='ISO-8859-1') {
+ if (is_string($data)) {
+ return self::MultiByteCharString2HTML($data, $charset);
+ } elseif (is_array($data)) {
+ $return_data = array();
+ foreach ($data as $key => $value) {
+ $return_data[$key] = self::recursiveMultiByteCharString2HTML($value, $charset);
+ }
+ return $return_data;
+ }
+ // integer, float, objects, resources, etc
+ return $data;
+ }
public static function MultiByteCharString2HTML($string, $charset='ISO-8859-1') {
$string = (string) $string; // in case trying to pass a numeric (float, int) string, would otherwise return an empty string
$newvaluelength = strlen(trim($value));
foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
$oldvaluelength = strlen(trim($existingvalue));
- if (($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {
+ if ((strlen($existingvalue) > 10) && ($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {
$ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
- break 2;
+ //break 2;
+ break;
}
}
}
if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
$value = (is_string($value) ? trim($value) : $value);
- $ThisFileInfo['comments'][$tagname][] = $value;
+ if (!is_numeric($key)) {
+ $ThisFileInfo['comments'][$tagname][$key] = $value;
+ } else {
+ $ThisFileInfo['comments'][$tagname][] = $value;
+ }
}
}
}
}
// Copy to ['comments_html']
- foreach ($ThisFileInfo['comments'] as $field => $values) {
- if ($field == 'picture') {
- // pictures can take up a lot of space, and we don't need multiple copies of them
- // let there be a single copy in [comments][picture], and not elsewhere
- continue;
- }
- foreach ($values as $index => $value) {
- if (is_array($value)) {
- $ThisFileInfo['comments_html'][$field][$index] = $value;
- } else {
- $ThisFileInfo['comments_html'][$field][$index] = str_replace('�', '', self::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
+ if (!empty($ThisFileInfo['comments'])) {
+ foreach ($ThisFileInfo['comments'] as $field => $values) {
+ if ($field == 'picture') {
+ // pictures can take up a lot of space, and we don't need multiple copies of them
+ // let there be a single copy in [comments][picture], and not elsewhere
+ continue;
+ }
+ foreach ($values as $index => $value) {
+ if (is_array($value)) {
+ $ThisFileInfo['comments_html'][$field][$index] = $value;
+ } else {
+ $ThisFileInfo['comments_html'][$field][$index] = str_replace('�', '', self::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
+ }
}
}
}
+
}
return true;
}
}
return $filesize;
}
+
+
+ /**
+ * Workaround for Bug #37268 (https://bugs.php.net/bug.php?id=37268)
+ * @param string $path A path.
+ * @param string $suffix If the name component ends in suffix this will also be cut off.
+ * @return string
+ */
+ public static function mb_basename($path, $suffix = null) {
+ $splited = preg_split('#/#', rtrim($path, '/ '));
+ return substr(basename('X'.$splited[count($splited) - 1], $suffix), 1);
+ }
+
}
\ No newline at end of file