本文整理匯總了PHP中getid3_lib::iconv_fallback方法的典型用法代碼示例。如果您正苦於以下問題:PHP getid3_lib::iconv_fallback方法的具體用法?PHP getid3_lib::iconv_fallback怎麽用?PHP getid3_lib::iconv_fallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類getid3_lib
的用法示例。
在下文中一共展示了getid3_lib::iconv_fallback方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ParseDirectoryRecord
function ParseDirectoryRecord(&$fd, $directorydata, &$ThisFileInfo)
{
if (isset($ThisFileInfo['iso']['supplementary_volume_descriptor'])) {
$TextEncoding = 'UTF-16BE';
// Big-Endian Unicode
} else {
$TextEncoding = 'ISO-8859-1';
// Latin-1
}
fseek($fd, $directorydata['location_bytes'], SEEK_SET);
$DirectoryRecordData = fread($fd, 1);
while (ord($DirectoryRecordData[0]) > 33) {
$DirectoryRecordData .= fread($fd, ord($DirectoryRecordData[0]) - 1);
$ThisDirectoryRecord['raw']['length'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 0, 1));
$ThisDirectoryRecord['raw']['extended_attribute_length'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 1, 1));
$ThisDirectoryRecord['raw']['offset_logical'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 2, 4));
$ThisDirectoryRecord['raw']['filesize'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 10, 4));
$ThisDirectoryRecord['raw']['recording_date_time'] = substr($DirectoryRecordData, 18, 7);
$ThisDirectoryRecord['raw']['file_flags'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 25, 1));
$ThisDirectoryRecord['raw']['file_unit_size'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 26, 1));
$ThisDirectoryRecord['raw']['interleave_gap_size'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 27, 1));
$ThisDirectoryRecord['raw']['volume_sequence_number'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 28, 2));
$ThisDirectoryRecord['raw']['file_identifier_length'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 32, 1));
$ThisDirectoryRecord['raw']['file_identifier'] = substr($DirectoryRecordData, 33, $ThisDirectoryRecord['raw']['file_identifier_length']);
$ThisDirectoryRecord['file_identifier_ascii'] = getid3_lib::iconv_fallback($TextEncoding, $ThisFileInfo['encoding'], $ThisDirectoryRecord['raw']['file_identifier']);
$ThisDirectoryRecord['filesize'] = $ThisDirectoryRecord['raw']['filesize'];
$ThisDirectoryRecord['offset_bytes'] = $ThisDirectoryRecord['raw']['offset_logical'] * 2048;
$ThisDirectoryRecord['file_flags']['hidden'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x1);
$ThisDirectoryRecord['file_flags']['directory'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x2);
$ThisDirectoryRecord['file_flags']['associated'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x4);
$ThisDirectoryRecord['file_flags']['extended'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x8);
$ThisDirectoryRecord['file_flags']['permissions'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x10);
$ThisDirectoryRecord['file_flags']['multiple'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x80);
$ThisDirectoryRecord['recording_timestamp'] = $this->ISOtime2UNIXtime($ThisDirectoryRecord['raw']['recording_date_time']);
if ($ThisDirectoryRecord['file_flags']['directory']) {
$ThisDirectoryRecord['filename'] = $directorydata['full_path'];
} else {
$ThisDirectoryRecord['filename'] = $directorydata['full_path'] . $this->ISOstripFilenameVersion($ThisDirectoryRecord['file_identifier_ascii']);
$ThisFileInfo['iso']['files'] = getid3_lib::array_merge_clobber($ThisFileInfo['iso']['files'], getid3_lib::CreateDeepArray($ThisDirectoryRecord['filename'], '/', $ThisDirectoryRecord['filesize']));
}
$DirectoryRecord[] = $ThisDirectoryRecord;
$DirectoryRecordData = fread($fd, 1);
}
return $DirectoryRecord;
}
示例2: TrimConvert
function TrimConvert($string)
{
// remove terminator, only if present (it should be, but...)
if (substr($string, strlen($string) - 2, 2) == "") {
$string = substr($string, 0, strlen($string) - 2);
}
// convert
return trim(getid3_lib::iconv_fallback('UTF-16LE', 'ISO-8859-1', $string), ' ');
}
示例3: CharConvert
function CharConvert(&$array, $encoding)
{
// identical encoding - end here
if ($encoding == $this->encoding) {
return;
}
// loop thru array
foreach ($array as $key => $value) {
// go recursive
if (is_array($value)) {
$this->CharConvert($array[$key], $encoding);
} elseif (is_string($value)) {
$array[$key] = trim(getid3_lib::iconv_fallback($encoding, $this->encoding, $value));
}
}
}
示例4: ParseID3v2Frame
//.........這裏部分代碼省略.........
// Identifier <up to 64 bytes binary data>
$frame_terminatorpos = strpos($parsedFrame['data'], "");
$frame_idstring = substr($parsedFrame['data'], 0, $frame_terminatorpos);
$parsedFrame['ownerid'] = $frame_idstring;
$parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen(""));
unset($parsedFrame['data']);
} elseif ($id3v2_majorversion >= 3 && $parsedFrame['frame_name'] == 'TXXX' || $id3v2_majorversion == 2 && $parsedFrame['frame_name'] == 'TXX') {
// 4.2.2 TXX User defined text information frame
// There may be more than one 'TXXX' frame in each tag,
// but only one with the same description.
// <Header for 'User defined text information frame', ID: 'TXXX'>
// Text encoding $xx
// Description <text string according to encoding> $00 (00)
// Value <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_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 = '';
}
$parsedFrame['encodingid'] = $frame_textencoding;
$parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding);
$parsedFrame['description'] = $frame_description;
$parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen($this->TextEncodingTerminatorLookup($frame_textencoding)));
if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
$ThisFileInfo['id3v2']['comments'][$parsedFrame['framenameshort']][] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $ThisFileInfo['id3v2']['encoding'], $parsedFrame['data']));
}
unset($parsedFrame['data']);
} elseif ($parsedFrame['frame_name'][0] == 'T') {
// 4.2. T??[?] Text information frame
// There may only be one text information frame of its kind in an tag.
// <Header for 'Text information frame', ID: 'T000' - 'TZZZ',
// excluding 'TXXX' described in 4.2.6.>
// Text encoding $xx
// Information <text string(s) 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';
}
$parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset);
$parsedFrame['encodingid'] = $frame_textencoding;
$parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding);
if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
// remove possible terminating \x00 (put by encoding id or software bug)
$string = getid3_lib::iconv_fallback($parsedFrame['encoding'], $ThisFileInfo['id3v2']['encoding'], $parsedFrame['data']);
if ($string[strlen($string) - 1] == "") {
$string = substr($string, 0, strlen($string) - 1);
}
$ThisFileInfo['id3v2']['comments'][$parsedFrame['framenameshort']][] = $string;
unset($string);
}
} elseif ($id3v2_majorversion >= 3 && $parsedFrame['frame_name'] == 'WXXX' || $id3v2_majorversion == 2 && $parsedFrame['frame_name'] == 'WXX') {
// 4.3.2 WXX User defined URL link frame
// There may be more than one 'WXXX' frame in each tag,
// but only one with the same description
// <Header for 'User defined URL link frame', ID: 'WXXX'>
// Text encoding $xx
示例5: TrimConvert
public static function TrimConvert($string)
{
return trim(getid3_lib::iconv_fallback('UTF-16LE', 'ISO-8859-1', self::TrimTerm($string)), ' ');
}
開發者ID:richardbota,項目名稱:WordPress-Theme-Development-with-Bootstrap,代碼行數:4,代碼來源:module.audio-video.asf.php
示例6: FormatDataForReal
function FormatDataForReal()
{
$tag_data_real['title'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['TITLE']));
$tag_data_real['artist'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['ARTIST']));
$tag_data_real['copyright'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['COPYRIGHT']));
$tag_data_real['comment'] = getid3_lib::iconv_fallback($this->tag_encoding, 'ISO-8859-1', @implode(' ', @$this->tag_data['COMMENT']));
$this->MergeExistingTagData('real', $tag_data_real);
return $tag_data_real;
}
示例7: getmicrotime
if (isset($fileinformation['playtime_seconds']) && $fileinformation['playtime_seconds'] > 0) {
$TotalScannedPlaytimeFiles++;
}
if (isset($fileinformation['bitrate']) && $fileinformation['bitrate'] > 0) {
$TotalScannedBitrateFiles++;
}
}
}
$endtime = getmicrotime();
closedir($handle);
echo 'done<br>';
echo 'Directory scanned in ' . number_format($endtime - $starttime, 2) . ' seconds.<br>';
flush();
$columnsintable = 14;
echo '<table class="table" cellspacing="0" cellpadding="3">';
echo '<tr bgcolor="#' . $getID3checkColor_Head . '"><th colspan="' . $columnsintable . '">Files in ' . getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-8', $currentfulldir) . '</th></tr>';
$rowcounter = 0;
foreach ($DirectoryContents as $dirname => $val) {
if (isset($DirectoryContents[$dirname]['dir']) && is_array($DirectoryContents[$dirname]['dir'])) {
uksort($DirectoryContents[$dirname]['dir'], 'MoreNaturalSort');
foreach ($DirectoryContents[$dirname]['dir'] as $filename => $fileinfo) {
echo '<tr bgcolor="#' . ($rowcounter++ % 2 ? $getID3checkColor_DirectoryLight : $getID3checkColor_DirectoryDark) . '">';
if ($filename == '..') {
echo '<td colspan="' . $columnsintable . '">';
echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="get">';
echo 'Parent directory: ';
echo '<input type="text" name="listdirectory" size="50" style="background-color: ' . $getID3checkColor_DirectoryDark . ';" value="';
if (GETID3_OS_ISWINDOWS) {
echo htmlentities(str_replace('\\', '/', realpath($dirname . $filename)), ENT_QUOTES);
} else {
echo htmlentities(realpath($dirname . $filename), ENT_QUOTES);
示例8: ParseID3v2Frame
//.........這裏部分代碼省略.........
// but only one with the same 'Owner identifier'.
// <Header for 'Unique file identifier', ID: 'UFID'>
// Owner identifier <text string> $00
// Identifier <up to 64 bytes binary data>
$exploded = explode("", $parsedFrame['data'], 2);
$parsedFrame['ownerid'] = isset($exploded[0]) ? $exploded[0] : '';
$parsedFrame['data'] = isset($exploded[1]) ? $exploded[1] : '';
} elseif ($id3v2_majorversion >= 3 && $parsedFrame['frame_name'] == 'TXXX' || $id3v2_majorversion == 2 && $parsedFrame['frame_name'] == 'TXX') {
// 4.2.2 TXX User defined text information frame
// There may be more than one 'TXXX' frame in each tag,
// but only one with the same description.
// <Header for 'User defined text information frame', ID: 'TXXX'>
// Text encoding $xx
// Description <text string according to encoding> $00 (00)
// Value <text string according to encoding>
$frame_offset = 0;
$frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1));
$frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding);
if ($id3v2_majorversion <= 3 && $frame_textencoding > 1 || $id3v2_majorversion == 4 && $frame_textencoding > 3) {
$info['warning'][] = 'Invalid text encoding byte (' . $frame_textencoding . ') in frame "' . $parsedFrame['frame_name'] . '" - defaulting to ISO-8859-1 encoding';
$frame_textencoding_terminator = "";
}
$frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset);
if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator), 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 = '';
}
$parsedFrame['encodingid'] = $frame_textencoding;
$parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding);
$parsedFrame['description'] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $frame_description));
$parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator));
if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
$commentkey = $parsedFrame['description'] ? $parsedFrame['description'] : (isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) ? count($info['id3v2']['comments'][$parsedFrame['framenameshort']]) : 0);
if (!isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) || !array_key_exists($commentkey, $info['id3v2']['comments'][$parsedFrame['framenameshort']])) {
$info['id3v2']['comments'][$parsedFrame['framenameshort']][$commentkey] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']));
} else {
$info['id3v2']['comments'][$parsedFrame['framenameshort']][] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']));
}
}
//unset($parsedFrame['data']); do not unset, may be needed elsewhere, e.g. for replaygain
} elseif ($parsedFrame['frame_name'][0] == 'T') {
// 4.2. T??[?] Text information frame
// There may only be one text information frame of its kind in an tag.
// <Header for 'Text information frame', ID: 'T000' - 'TZZZ',
// excluding 'TXXX' described in 4.2.6.>
// Text encoding $xx
// Information <text string(s) 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) {
$info['warning'][] = 'Invalid text encoding byte (' . $frame_textencoding . ') in frame "' . $parsedFrame['frame_name'] . '" - defaulting to ISO-8859-1 encoding';
}
$parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset);
$parsedFrame['encodingid'] = $frame_textencoding;
$parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding);
if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
// ID3v2.3 specs say that TPE1 (and others) can contain multiple artist values separated with /
// This of course breaks when an artist name contains slash character, e.g. "AC/DC"
// MP3tag (maybe others) implement alternative system where multiple artists are null-separated, which makes more sense
// getID3 will split null-separated artists into multiple artists and leave slash-separated ones to the user
switch ($parsedFrame['encoding']) {
case 'UTF-16':
示例9: clean_ID3info_results_r
protected function clean_ID3info_results_r(&$arr, $flags)
{
if (is_array($arr)) {
// heuristic #1: fold all the quickatoms subatoms using their hierarchy and name fields; this is a tree rewrite
if (array_key_exists('quicktime', $arr) && is_array($arr['quicktime'])) {
$inject = array();
$this->fold_quicktime_subatoms($arr['quicktime'], $inject, 'quicktime');
// can't use array_splice on associative arrays, so we rewrite $arr now:
$newarr = array();
foreach ($arr as $key => &$value) {
$newarr[$key] = $value;
if ($key === 'quicktime') {
foreach ($inject as $ik => &$iv) {
$newarr[$ik] = $iv;
}
}
}
$arr = $newarr;
unset($inject);
unset($newarr);
}
$activity = true;
while ($activity) {
$activity = false;
// assume there's nothing to do anymore. Prove us wrong now...
// heuristic #2: when the number of items in the array which are themselves arrays is 80%, contract the set
$todo = array();
foreach ($arr as $key => &$value) {
if (is_array($value)) {
$acnt = 0;
foreach ($value as $sk => &$sv) {
if (is_array($sv)) {
$acnt++;
}
}
// the floor() here helps to fold single-element arrays alongside! :-)
if (floor(0.5 * count($value)) <= $acnt) {
$todo[] = $key;
}
}
}
if (count($todo) > 0) {
$inject = array();
foreach ($arr as $key => &$value) {
if (is_array($value) && in_array($key, $todo)) {
unset($todo[$key]);
foreach ($value as $sk => &$sv) {
$nk = $key . '.' . $sk;
// pull up single entry subsubarrays at the same time!
if (is_array($sv) && count($sv) == 1) {
foreach ($sv as $sk2 => &$sv2) {
$nk .= '.' . $sk2;
$inject[$nk] = $sv2;
}
} else {
$inject[$nk] = $sv;
}
}
} else {
$inject[$key] = $value;
}
}
$arr = $inject;
$activity = true;
}
}
foreach ($arr as $key => &$value) {
if ($key === 'data' && isset($arr['image_mime'])) {
// when this is a valid image, it's already available as a thumbnail, most probably
$imageinfo = array();
$imagechunkcheck = getid3_lib::GetDataImageSize($value, $imageinfo);
if (is_array($imagechunkcheck) && isset($imagechunkcheck[2]) && in_array($imagechunkcheck[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
if ($flags & MTFM_CLEAN_ID3_STRIP_EMBEDDED_IMAGES) {
$value = new BinaryDataContainer('(embedded image ' . image_type_to_extension($imagechunkcheck[2]) . ' data...)');
} else {
$value = new EmbeddedImageContainer($imagechunkcheck, $value);
}
} else {
if ($flags & MTFM_CLEAN_ID3_STRIP_EMBEDDED_IMAGES) {
$value = new BinaryDataContainer('(unidentified image data ... ' . (is_string($value) ? 'length = ' . strlen($value) : '') . ' -- ' . print_r($imagechunkcheck) . ')');
} else {
$this->clean_ID3info_results_r($value, $flags);
}
}
} else {
if (isset($arr[$key . '_guid'])) {
// convert guid raw binary data to hex:
$temp = unpack('H*', $value);
$value = new BinaryDataContainer($temp[1]);
} else {
if ($key === 'non_intra_quant' || $key === 'error_correct_type') {
// convert raw binary data to hex in 32 bit chunks:
$temp = unpack('H*', $value);
$temp = str_split($temp[1], 8);
$value = new BinaryDataContainer(implode(' ', $temp));
} else {
if ($key === 'data' && is_string($value) && isset($arr['frame_name']) && isset($arr['encoding']) && isset($arr['datalength'])) {
$str = $this->mkSafeUTF8(trim(strtr(getid3_lib::iconv_fallback($arr['encoding'], 'UTF-8', $value), "", ' ')));
$temp = unpack('H*', $value);
$temp = str_split($temp[1], 8);
//.........這裏部分代碼省略.........
示例10: GenerateID3v2Tag
public function GenerateID3v2Tag($noerrorsonly = true)
{
$this->ID3v2FrameIsAllowed(null, '');
// clear static array in case this isn't the first call to $this->GenerateID3v2Tag()
$tagstring = '';
if (is_array($this->tag_data)) {
foreach ($this->tag_data as $frame_name => $frame_rawinputdata) {
foreach ($frame_rawinputdata as $irrelevantindex => $source_data_array) {
if (getid3_id3v2::IsValidID3v2FrameName($frame_name, $this->majorversion)) {
unset($frame_length);
unset($frame_flags);
$frame_data = false;
if ($this->ID3v2FrameIsAllowed($frame_name, $source_data_array)) {
if (array_key_exists('description', $source_data_array) && array_key_exists('encodingid', $source_data_array) && array_key_exists('encoding', $this->tag_data)) {
$source_data_array['description'] = getid3_lib::iconv_fallback($this->tag_data['encoding'], $source_data_array['encoding'], $source_data_array['description']);
}
if ($frame_data = $this->GenerateID3v2FrameData($frame_name, $source_data_array)) {
$FrameUnsynchronisation = false;
if ($this->majorversion >= 4) {
// frame-level unsynchronisation
$unsynchdata = $frame_data;
if ($this->id3v2_use_unsynchronisation) {
$unsynchdata = $this->Unsynchronise($frame_data);
}
if (strlen($unsynchdata) != strlen($frame_data)) {
// unsynchronisation needed
$FrameUnsynchronisation = true;
$frame_data = $unsynchdata;
if (isset($TagUnsynchronisation) && $TagUnsynchronisation === false) {
// only set to true if ALL frames are unsynchronised
} else {
$TagUnsynchronisation = true;
}
} else {
if (isset($TagUnsynchronisation)) {
$TagUnsynchronisation = false;
}
}
unset($unsynchdata);
$frame_length = getid3_lib::BigEndian2String(strlen($frame_data), 4, true);
} else {
$frame_length = getid3_lib::BigEndian2String(strlen($frame_data), 4, false);
}
$frame_flags = $this->GenerateID3v2FrameFlags($this->ID3v2FrameFlagsLookupTagAlter($frame_name), $this->ID3v2FrameFlagsLookupFileAlter($frame_name), false, false, false, false, $FrameUnsynchronisation, false);
}
} else {
$this->errors[] = 'Frame "' . $frame_name . '" is NOT allowed';
}
if ($frame_data === false) {
$this->errors[] = '$this->GenerateID3v2FrameData() failed for "' . $frame_name . '"';
if ($noerrorsonly) {
return false;
} else {
unset($frame_name);
}
}
} else {
// ignore any invalid frame names, including 'title', 'header', etc
$this->warnings[] = 'Ignoring invalid ID3v2 frame type: "' . $frame_name . '"';
unset($frame_name);
unset($frame_length);
unset($frame_flags);
unset($frame_data);
}
if (isset($frame_name) && isset($frame_length) && isset($frame_flags) && isset($frame_data)) {
$tagstring .= $frame_name . $frame_length . $frame_flags . $frame_data;
}
}
}
if (!isset($TagUnsynchronisation)) {
$TagUnsynchronisation = false;
}
if ($this->majorversion <= 3 && $this->id3v2_use_unsynchronisation) {
// tag-level unsynchronisation
$unsynchdata = $this->Unsynchronise($tagstring);
if (strlen($unsynchdata) != strlen($tagstring)) {
// unsynchronisation needed
$TagUnsynchronisation = true;
$tagstring = $unsynchdata;
}
}
while ($this->paddedlength < strlen($tagstring) + getid3_id3v2::ID3v2HeaderLength($this->majorversion)) {
$this->paddedlength += 1024;
}
$footer = false;
// ID3v2 footers not yet supported in getID3()
if (!$footer && $this->paddedlength > strlen($tagstring) + getid3_id3v2::ID3v2HeaderLength($this->majorversion)) {
// pad up to $paddedlength bytes if unpadded tag is shorter than $paddedlength
// "Furthermore it MUST NOT have any padding when a tag footer is added to the tag."
if ($this->paddedlength - strlen($tagstring) - getid3_id3v2::ID3v2HeaderLength($this->majorversion) > 0) {
$tagstring .= str_repeat("", $this->paddedlength - strlen($tagstring) - getid3_id3v2::ID3v2HeaderLength($this->majorversion));
}
}
if ($this->id3v2_use_unsynchronisation && substr($tagstring, strlen($tagstring) - 1, 1) == "ÿ") {
// special unsynchronisation case:
// if last byte == $FF then appended a $00
$TagUnsynchronisation = true;
$tagstring .= "";
}
$tagheader = 'ID3';
//.........這裏部分代碼省略.........
示例11: FormatDataForVorbisComment
function FormatDataForVorbisComment()
{
$tag_data_vorbiscomment = $this->tag_data;
// check for multi-line comment values - split out to multiple comments if neccesary
// and convert data to UTF-8 strings
foreach ($tag_data_vorbiscomment as $tag_key => $valuearray) {
foreach ($valuearray as $key => $value) {
str_replace("\r", "\n", $value);
if (strstr($value, "\n")) {
unset($tag_data_vorbiscomment[$tag_key][$key]);
$multilineexploded = explode("\n", $value);
foreach ($multilineexploded as $newcomment) {
if (strlen(trim($newcomment)) > 0) {
$tag_data_vorbiscomment[$tag_key][] = getid3_lib::iconv_fallback($this->tag_encoding, 'UTF-8', $newcomment);
}
}
} elseif (is_string($value) || is_numeric($value)) {
$tag_data_vorbiscomment[$tag_key][$key] = getid3_lib::iconv_fallback($this->tag_encoding, 'UTF-8', $value);
} else {
$this->warnings[] = '$data[' . $tag_key . '][' . $key . '] is not a string value - all of $data[' . $tag_key . '] NOT written to VorbisComment tag';
unset($tag_data_vorbiscomment[$tag_key]);
break;
}
}
}
$this->MergeExistingTagData('vorbiscomment', $tag_data_vorbiscomment);
return $tag_data_vorbiscomment;
}