ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
getid3_lib Class Reference

getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g // More...

+ Collaboration diagram for getid3_lib:

Static Public Member Functions

static PrintHexBytes ($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
 
static trunc ($floatnumber)
 
static safe_inc (&$variable, $increment=1)
 
static CastAsInt ($floatnum)
 
static intValueSupported ($num)
 
static DecimalizeFraction ($fraction)
 
static DecimalBinary2Float ($binarynumerator)
 
static NormalizeBinaryPoint ($binarypointnumber, $maxbits=52)
 
static Float2BinaryDecimal ($floatvalue)
 
static Float2String ($floatvalue, $bits)
 
static LittleEndian2Float ($byteword)
 
static BigEndian2Float ($byteword)
 
static BigEndian2Int ($byteword, $synchsafe=false, $signed=false)
 
static LittleEndian2Int ($byteword, $signed=false)
 
static BigEndian2Bin ($byteword)
 
static BigEndian2String ($number, $minbytes=1, $synchsafe=false, $signed=false)
 
static Dec2Bin ($number)
 
static Bin2Dec ($binstring, $signed=false)
 
static Bin2String ($binstring)
 
static LittleEndian2String ($number, $minbytes=1, $synchsafe=false)
 
static array_merge_clobber ($array1, $array2)
 
static array_merge_noclobber ($array1, $array2)
 
static flipped_array_merge_noclobber ($array1, $array2)
 
static ksort_recursive (&$theArray)
 
static fileextension ($filename, $numextensions=1)
 
static PlaytimeString ($seconds)
 
static DateMac2Unix ($macdate)
 
static FixedPoint8_8 ($rawdata)
 
static FixedPoint16_16 ($rawdata)
 
static FixedPoint2_30 ($rawdata)
 
static CreateDeepArray ($ArrayPath, $Separator, $Value)
 
static array_max ($arraydata, $returnkey=false)
 
static array_min ($arraydata, $returnkey=false)
 
static XML2array ($XMLstring)
 
static SimpleXMLelement2array ($XMLobject)
 
static hash_data ($file, $offset, $end, $algorithm)
 
static CopyFileParts ($filename_source, $filename_dest, $offset, $length)
 
static iconv_fallback_int_utf8 ($charval)
 
static iconv_fallback_iso88591_utf8 ($string, $bom=false)
 
static iconv_fallback_iso88591_utf16be ($string, $bom=false)
 
static iconv_fallback_iso88591_utf16le ($string, $bom=false)
 
static iconv_fallback_iso88591_utf16 ($string)
 
static iconv_fallback_utf8_iso88591 ($string)
 
static iconv_fallback_utf8_utf16be ($string, $bom=false)
 
static iconv_fallback_utf8_utf16le ($string, $bom=false)
 
static iconv_fallback_utf8_utf16 ($string)
 
static iconv_fallback_utf16be_utf8 ($string)
 
static iconv_fallback_utf16le_utf8 ($string)
 
static iconv_fallback_utf16be_iso88591 ($string)
 
static iconv_fallback_utf16le_iso88591 ($string)
 
static iconv_fallback_utf16_iso88591 ($string)
 
static iconv_fallback_utf16_utf8 ($string)
 
static iconv_fallback ($in_charset, $out_charset, $string)
 
static recursiveMultiByteCharString2HTML ($data, $charset='ISO-8859-1')
 
static MultiByteCharString2HTML ($string, $charset='ISO-8859-1')
 
static RGADnameLookup ($namecode)
 
static RGADoriginatorLookup ($originatorcode)
 
static RGADadjustmentLookup ($rawadjustment, $signbit)
 
static RGADgainString ($namecode, $originatorcode, $replaygain)
 
static RGADamplitude2dB ($amplitude)
 
static GetDataImageSize ($imgData, &$imageinfo=array())
 
static ImageExtFromMime ($mime_type)
 
static ImageTypesLookup ($imagetypeid)
 
static CopyTagsToComments (&$ThisFileInfo)
 
static EmbeddedLookup ($key, $begin, $end, $file, $name)
 
static IncludeDependency ($filename, $sourcefile, $DieOnFailure=false)
 
static trimNullByte ($string)
 
static getFileSizeSyscall ($path)
 
static mb_basename ($path, $suffix=null)
 Workaround for Bug #37268 (https://bugs.php.net/bug.php?id=37268) More...
 

Detailed Description

getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //

Definition at line 15 of file getid3.lib.php.

Member Function Documentation

◆ array_max()

static getid3_lib::array_max (   $arraydata,
  $returnkey = false 
)
static

Definition at line 507 of file getid3.lib.php.

507 {
508 $maxvalue = false;
509 $maxkey = false;
510 foreach ($arraydata as $key => $value) {
511 if (!is_array($value)) {
512 if ($value > $maxvalue) {
513 $maxvalue = $value;
514 $maxkey = $key;
515 }
516 }
517 }
518 return ($returnkey ? $maxkey : $maxvalue);
519 }
$key
Definition: croninfo.php:18

References $key.

Referenced by getid3_mp3\getOnlyMPEGaudioInfoBruteForce().

+ Here is the caller graph for this function:

◆ array_merge_clobber()

static getid3_lib::array_merge_clobber (   $array1,
  $array2 
)
static

Definition at line 384 of file getid3.lib.php.

384 {
385 // written by kcØhireability*com
386 // taken from http://www.php.net/manual/en/function.array-merge-recursive.php
387 if (!is_array($array1) || !is_array($array2)) {
388 return false;
389 }
390 $newarray = $array1;
391 foreach ($array2 as $key => $val) {
392 if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
393 $newarray[$key] = self::array_merge_clobber($newarray[$key], $val);
394 } else {
395 $newarray[$key] = $val;
396 }
397 }
398 return $newarray;
399 }
static array_merge_clobber($array1, $array2)
Definition: getid3.lib.php:384

References $key, and array_merge_clobber().

Referenced by getid3_gzip\Analyze(), getid3_rar\Analyze(), getid3_tar\Analyze(), getid3_zip\Analyze(), array_merge_clobber(), and getid3_iso\ParseDirectoryRecord().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ array_merge_noclobber()

static getid3_lib::array_merge_noclobber (   $array1,
  $array2 
)
static

Definition at line 402 of file getid3.lib.php.

402 {
403 if (!is_array($array1) || !is_array($array2)) {
404 return false;
405 }
406 $newarray = $array1;
407 foreach ($array2 as $key => $val) {
408 if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
409 $newarray[$key] = self::array_merge_noclobber($newarray[$key], $val);
410 } elseif (!isset($newarray[$key])) {
411 $newarray[$key] = $val;
412 }
413 }
414 return $newarray;
415 }
static array_merge_noclobber($array1, $array2)
Definition: getid3.lib.php:402

References $key, and array_merge_noclobber().

Referenced by getid3_asf\Analyze(), getid3_riff\Analyze(), and array_merge_noclobber().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ array_min()

static getid3_lib::array_min (   $arraydata,
  $returnkey = false 
)
static

Definition at line 521 of file getid3.lib.php.

521 {
522 $minvalue = false;
523 $minkey = false;
524 foreach ($arraydata as $key => $value) {
525 if (!is_array($value)) {
526 if ($value > $minvalue) {
527 $minvalue = $value;
528 $minkey = $key;
529 }
530 }
531 }
532 return ($returnkey ? $minkey : $minvalue);
533 }

References $key.

◆ BigEndian2Bin()

static getid3_lib::BigEndian2Bin (   $byteword)
static

Definition at line 297 of file getid3.lib.php.

297 {
298 $binvalue = '';
299 $bytewordlen = strlen($byteword);
300 for ($i = 0; $i < $bytewordlen; $i++) {
301 $binvalue .= str_pad(decbin(ord($byteword{$i})), 8, '0', STR_PAD_LEFT);
302 }
303 return $binvalue;
304 }
$i
Definition: disco.tpl.php:19

References $i.

Referenced by getid3_mpeg\Analyze(), getid3_ac3\Analyze(), getid3_dts\Analyze(), BigEndian2Float(), FixedPoint2_30(), getid3_aac\getAACADIFheaderFilepointer(), getid3_id3v2\ParseID3v2Frame(), and getid3_flac\parseSTREAMINFO().

+ Here is the caller graph for this function:

◆ BigEndian2Float()

static getid3_lib::BigEndian2Float (   $byteword)
static

Definition at line 185 of file getid3.lib.php.

185 {
186 // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
187 // http://www.psc.edu/general/software/packages/ieee/ieee.html
188 // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
189
190 $bitword = self::BigEndian2Bin($byteword);
191 if (!$bitword) {
192 return 0;
193 }
194 $signbit = $bitword{0};
195
196 switch (strlen($byteword) * 8) {
197 case 32:
198 $exponentbits = 8;
199 $fractionbits = 23;
200 break;
201
202 case 64:
203 $exponentbits = 11;
204 $fractionbits = 52;
205 break;
206
207 case 80:
208 // 80-bit Apple SANE format
209 // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
210 $exponentstring = substr($bitword, 1, 15);
211 $isnormalized = intval($bitword{16});
212 $fractionstring = substr($bitword, 17, 63);
213 $exponent = pow(2, self::Bin2Dec($exponentstring) - 16383);
214 $fraction = $isnormalized + self::DecimalBinary2Float($fractionstring);
215 $floatvalue = $exponent * $fraction;
216 if ($signbit == '1') {
217 $floatvalue *= -1;
218 }
219 return $floatvalue;
220 break;
221
222 default:
223 return false;
224 break;
225 }
226 $exponentstring = substr($bitword, 1, $exponentbits);
227 $fractionstring = substr($bitword, $exponentbits + 1, $fractionbits);
228 $exponent = self::Bin2Dec($exponentstring);
229 $fraction = self::Bin2Dec($fractionstring);
230
231 if (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction != 0)) {
232 // Not a Number
233 $floatvalue = false;
234 } elseif (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction == 0)) {
235 if ($signbit == '1') {
236 $floatvalue = '-infinity';
237 } else {
238 $floatvalue = '+infinity';
239 }
240 } elseif (($exponent == 0) && ($fraction == 0)) {
241 if ($signbit == '1') {
242 $floatvalue = -0;
243 } else {
244 $floatvalue = 0;
245 }
246 $floatvalue = ($signbit ? 0 : -0);
247 } elseif (($exponent == 0) && ($fraction != 0)) {
248 // These are 'unnormalized' values
249 $floatvalue = pow(2, (-1 * (pow(2, $exponentbits - 1) - 2))) * self::DecimalBinary2Float($fractionstring);
250 if ($signbit == '1') {
251 $floatvalue *= -1;
252 }
253 } elseif ($exponent != 0) {
254 $floatvalue = pow(2, ($exponent - (pow(2, $exponentbits - 1) - 1))) * (1 + self::DecimalBinary2Float($fractionstring));
255 if ($signbit == '1') {
256 $floatvalue *= -1;
257 }
258 }
259 return (float) $floatvalue;
260 }
static BigEndian2Bin($byteword)
Definition: getid3.lib.php:297
static DecimalBinary2Float($binarynumerator)
Definition: getid3.lib.php:102
static Bin2Dec($binstring, $signed=false)
Definition: getid3.lib.php:342

References BigEndian2Bin(), Bin2Dec(), and DecimalBinary2Float().

Referenced by getid3_riff\Analyze(), LittleEndian2Float(), getid3_matroska\parseEBML(), getid3_id3v2\ParseID3v2Frame(), and AMFStream\readDouble().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BigEndian2Int()

static getid3_lib::BigEndian2Int (   $byteword,
  $synchsafe = false,
  $signed = false 
)
static

Definition at line 263 of file getid3.lib.php.

263 {
264 $intvalue = 0;
265 $bytewordlen = strlen($byteword);
266 if ($bytewordlen == 0) {
267 return false;
268 }
269 for ($i = 0; $i < $bytewordlen; $i++) {
270 if ($synchsafe) { // disregard MSB, effectively 7-bit bytes
271 //$intvalue = $intvalue | (ord($byteword{$i}) & 0x7F) << (($bytewordlen - 1 - $i) * 7); // faster, but runs into problems past 2^31 on 32-bit systems
272 $intvalue += (ord($byteword{$i}) & 0x7F) * pow(2, ($bytewordlen - 1 - $i) * 7);
273 } else {
274 $intvalue += ord($byteword{$i}) * pow(256, ($bytewordlen - 1 - $i));
275 }
276 }
277 if ($signed && !$synchsafe) {
278 // synchsafe ints are not allowed to be signed
279 if ($bytewordlen <= PHP_INT_SIZE) {
280 $signMaskBit = 0x80 << (8 * ($bytewordlen - 1));
281 if ($intvalue & $signMaskBit) {
282 $intvalue = 0 - ($intvalue & ($signMaskBit - 1));
283 }
284 } else {
285 throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits ('.strlen($byteword).') in self::BigEndian2Int()');
286 }
287 }
288 return self::CastAsInt($intvalue);
289 }
static CastAsInt($floatnum)
Definition: getid3.lib.php:65

References $i, and CastAsInt().

Referenced by getID3\analyze(), getid3_szip\Analyze(), getid3_flv\Analyze(), getid3_quicktime\Analyze(), getid3_real\Analyze(), getid3_riff\Analyze(), getid3_swf\Analyze(), getid3_ts\Analyze(), getid3_aa\Analyze(), getid3_ac3\Analyze(), getid3_au\Analyze(), getid3_avr\Analyze(), getid3_lpac\Analyze(), getid3_midi\Analyze(), getid3_ogg\Analyze(), getid3_vqf\Analyze(), getid3_png\Analyze(), getid3_id3v2\Analyze(), getid3_mp3\decodeMPEGaudioHeader(), getid3_matroska\EBML2Int(), getid3_riff\EitherEndian2Int(), FixedPoint16_16(), FixedPoint8_8(), getid3_aac\getAACADTSheaderFilepointer(), AVCSequenceParameterSetReader\getBit(), getid3_matroska\HandleEMBLClusterBlock(), getid3_matroska\HandleEMBLSimpleTag(), iconv_fallback_utf16be_iso88591(), iconv_fallback_utf16be_utf8(), LittleEndian2Int(), getid3_mp3\MPEGaudioHeaderDecode(), MultiByteCharString2HTML(), getid3_flac\parseAPPLICATION(), getid3_flac\parseCUESHEET(), getid3_matroska\parseEBML(), getid3_id3v2\ParseID3v2Frame(), getid3_flac\parseMETAdata(), getid3_mpc\ParseMPCsv8(), getid3_real\ParseOldRAheader(), getid3_flac\parsePICTURE(), getid3_flac\parseSEEKTABLE(), getid3_flac\parseSTREAMINFO(), getid3_quicktime\QuicktimeParseAtom(), getid3_quicktime\QuicktimeParseContainerAtom(), getid3_quicktime\QuicktimeParseNikonNCTG(), AMFStream\readByte(), and getid3_tiff\TIFFendian2Int().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BigEndian2String()

static getid3_lib::BigEndian2String (   $number,
  $minbytes = 1,
  $synchsafe = false,
  $signed = false 
)
static

Definition at line 307 of file getid3.lib.php.

307 {
308 if ($number < 0) {
309 throw new Exception('ERROR: self::BigEndian2String() does not support negative numbers');
310 }
311 $maskbyte = (($synchsafe || $signed) ? 0x7F : 0xFF);
312 $intstring = '';
313 if ($signed) {
314 if ($minbytes > PHP_INT_SIZE) {
315 throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits in self::BigEndian2String()');
316 }
317 $number = $number & (0x80 << (8 * ($minbytes - 1)));
318 }
319 while ($number != 0) {
320 $quotient = ($number / ($maskbyte + 1));
321 $intstring = chr(ceil(($quotient - floor($quotient)) * $maskbyte)).$intstring;
322 $number = floor($quotient);
323 }
324 return str_pad($intstring, $minbytes, "\x00", STR_PAD_LEFT);
325 }

Referenced by Float2String(), getid3_write_real\GenerateCONTchunk(), getid3_write_id3v2\GenerateID3v2FrameData(), getid3_write_id3v2\GenerateID3v2Tag(), getid3_write_real\GeneratePROPchunk(), and getid3_write_real\GenerateRMFchunk().

+ Here is the caller graph for this function:

◆ Bin2Dec()

static getid3_lib::Bin2Dec (   $binstring,
  $signed = false 
)
static

Definition at line 342 of file getid3.lib.php.

342 {
343 $signmult = 1;
344 if ($signed) {
345 if ($binstring{0} == '1') {
346 $signmult = -1;
347 }
348 $binstring = substr($binstring, 1);
349 }
350 $decvalue = 0;
351 for ($i = 0; $i < strlen($binstring); $i++) {
352 $decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
353 }
354 return self::CastAsInt($decvalue * $signmult);
355 }

References $i, and CastAsInt().

Referenced by getid3_riff\Analyze(), getid3_swf\Analyze(), getid3_ac3\Analyze(), BigEndian2Float(), DecimalBinary2Float(), FixedPoint2_30(), getid3_aac\getAACADIFheaderFilepointer(), getid3_id3v2\ParseID3v2Frame(), and getid3_flac\parseSTREAMINFO().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Bin2String()

static getid3_lib::Bin2String (   $binstring)
static

Definition at line 358 of file getid3.lib.php.

358 {
359 // return 'hi' for input of '0110100001101001'
360 $string = '';
361 $binstringreversed = strrev($binstring);
362 for ($i = 0; $i < strlen($binstringreversed); $i += 8) {
363 $string = chr(self::Bin2Dec(strrev(substr($binstringreversed, $i, 8)))).$string;
364 }
365 return $string;
366 }

References $i.

Referenced by getid3_aac\getAACADIFheaderFilepointer().

+ Here is the caller graph for this function:

◆ CastAsInt()

static getid3_lib::CastAsInt (   $floatnum)
static

Definition at line 65 of file getid3.lib.php.

65 {
66 // convert to float if not already
67 $floatnum = (float) $floatnum;
68
69 // convert a float to type int, only if possible
70 if (self::trunc($floatnum) == $floatnum) {
71 // it's not floating point
72 if (self::intValueSupported($floatnum)) {
73 // it's within int range
74 $floatnum = (int) $floatnum;
75 }
76 }
77 return $floatnum;
78 }

Referenced by getid3_flv\Analyze(), getid3_riff\Analyze(), getid3_voc\Analyze(), getid3_id3v2\Analyze(), BigEndian2Int(), Bin2Dec(), getid3_jpg\CastAsAppropriate(), DateMac2Unix(), getid3_mp3\getOnlyMPEGaudioInfo(), and getid3_mpc\ParseMPCsv7().

+ Here is the caller graph for this function:

◆ CopyFileParts()

static getid3_lib::CopyFileParts (   $filename_source,
  $filename_dest,
  $offset,
  $length 
)
static

Definition at line 648 of file getid3.lib.php.

648 {
649 if (!self::intValueSupported($offset + $length)) {
650 throw new Exception('cannot copy file portion, it extends beyond the '.round(PHP_INT_MAX / 1073741824).'GB limit');
651 }
652 if (is_readable($filename_source) && is_file($filename_source) && ($fp_src = fopen($filename_source, 'rb'))) {
653 if (($fp_dest = fopen($filename_dest, 'wb'))) {
654 if (fseek($fp_src, $offset) == 0) {
655 $byteslefttowrite = $length;
656 while (($byteslefttowrite > 0) && ($buffer = fread($fp_src, min($byteslefttowrite, getID3::FREAD_BUFFER_SIZE)))) {
657 $byteswritten = fwrite($fp_dest, $buffer, $byteslefttowrite);
658 $byteslefttowrite -= $byteswritten;
659 }
660 return true;
661 } else {
662 throw new Exception('failed to seek to offset '.$offset.' in '.$filename_source);
663 }
664 fclose($fp_dest);
665 } else {
666 throw new Exception('failed to create file for writing '.$filename_dest);
667 }
668 fclose($fp_src);
669 } else {
670 throw new Exception('failed to open file for reading '.$filename_source);
671 }
672 return false;
673 }
const FREAD_BUFFER_SIZE
Definition: getid3.php:116

References getID3\FREAD_BUFFER_SIZE.

Referenced by hash_data().

+ Here is the caller graph for this function:

◆ CopyTagsToComments()

static getid3_lib::CopyTagsToComments ( $ThisFileInfo)
static

Definition at line 1239 of file getid3.lib.php.

1239 {
1240
1241 // Copy all entries from ['tags'] into common ['comments']
1242 if (!empty($ThisFileInfo['tags'])) {
1243 foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
1244 foreach ($tagarray as $tagname => $tagdata) {
1245 foreach ($tagdata as $key => $value) {
1246 if (!empty($value)) {
1247 if (empty($ThisFileInfo['comments'][$tagname])) {
1248
1249 // fall through and append value
1250
1251 } elseif ($tagtype == 'id3v1') {
1252
1253 $newvaluelength = strlen(trim($value));
1254 foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
1255 $oldvaluelength = strlen(trim($existingvalue));
1256 if (($newvaluelength <= $oldvaluelength) && (substr($existingvalue, 0, $newvaluelength) == trim($value))) {
1257 // new value is identical but shorter-than (or equal-length to) one already in comments - skip
1258 break 2;
1259 }
1260 }
1261
1262 } elseif (!is_array($value)) {
1263
1264 $newvaluelength = strlen(trim($value));
1265 foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
1266 $oldvaluelength = strlen(trim($existingvalue));
1267 if ((strlen($existingvalue) > 10) && ($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {
1268 $ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
1269 //break 2;
1270 break;
1271 }
1272 }
1273
1274 }
1275 if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
1276 $value = (is_string($value) ? trim($value) : $value);
1277 if (!is_int($key) && !ctype_digit($key)) {
1278 $ThisFileInfo['comments'][$tagname][$key] = $value;
1279 } else {
1280 if (isset($ThisFileInfo['comments'][$tagname])) {
1281 $ThisFileInfo['comments'][$tagname] = array($value);
1282 } else {
1283 $ThisFileInfo['comments'][$tagname][] = $value;
1284 }
1285 }
1286 }
1287 }
1288 }
1289 }
1290 }
1291
1292 // attempt to standardize spelling of returned keys
1293 $StandardizeFieldNames = array(
1294 'tracknumber' => 'track_number',
1295 'track' => 'track_number',
1296 );
1297 foreach ($StandardizeFieldNames as $badkey => $goodkey) {
1298 if (array_key_exists($badkey, $ThisFileInfo['comments']) && !array_key_exists($goodkey, $ThisFileInfo['comments'])) {
1299 $ThisFileInfo['comments'][$goodkey] = $ThisFileInfo['comments'][$badkey];
1300 unset($ThisFileInfo['comments'][$badkey]);
1301 }
1302 }
1303
1304 // Copy to ['comments_html']
1305 if (!empty($ThisFileInfo['comments'])) {
1306 foreach ($ThisFileInfo['comments'] as $field => $values) {
1307 if ($field == 'picture') {
1308 // pictures can take up a lot of space, and we don't need multiple copies of them
1309 // let there be a single copy in [comments][picture], and not elsewhere
1310 continue;
1311 }
1312 foreach ($values as $index => $value) {
1313 if (is_array($value)) {
1314 $ThisFileInfo['comments_html'][$field][$index] = $value;
1315 } else {
1316 $ThisFileInfo['comments_html'][$field][$index] = str_replace('&#0;', '', self::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
1317 }
1318 }
1319 }
1320 }
1321
1322 }
1323 return true;
1324 }
$index
Definition: metadata.php:60
$values

References $index, $key, and $values.

◆ CreateDeepArray()

static getid3_lib::CreateDeepArray (   $ArrayPath,
  $Separator,
  $Value 
)
static

Definition at line 491 of file getid3.lib.php.

491 {
492 // assigns $Value to a nested array path:
493 // $foo = self::CreateDeepArray('/path/to/my', '/', 'file.txt')
494 // is the same as:
495 // $foo = array('path'=>array('to'=>'array('my'=>array('file.txt'))));
496 // or
497 // $foo['path']['to']['my'] = 'file.txt';
498 $ArrayPath = ltrim($ArrayPath, $Separator);
499 if (($pos = strpos($ArrayPath, $Separator)) !== false) {
500 $ReturnedArray[substr($ArrayPath, 0, $pos)] = self::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
501 } else {
502 $ReturnedArray[$ArrayPath] = $Value;
503 }
504 return $ReturnedArray;
505 }
static CreateDeepArray($ArrayPath, $Separator, $Value)
Definition: getid3.lib.php:491

References CreateDeepArray().

Referenced by getid3_gzip\Analyze(), getid3_rar\Analyze(), getid3_tar\Analyze(), getid3_zip\Analyze(), CreateDeepArray(), and getid3_iso\ParseDirectoryRecord().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DateMac2Unix()

static getid3_lib::DateMac2Unix (   $macdate)
static

Definition at line 468 of file getid3.lib.php.

468 {
469 // Macintosh timestamp: seconds since 00:00h January 1, 1904
470 // UNIX timestamp: seconds since 00:00h January 1, 1970
471 return self::CastAsInt($macdate - 2082844800);
472 }

References CastAsInt().

Referenced by getid3_riff\Analyze(), and getid3_quicktime\QuicktimeParseAtom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Dec2Bin()

static getid3_lib::Dec2Bin (   $number)
static

Definition at line 328 of file getid3.lib.php.

328 {
329 while ($number >= 256) {
330 $bytes[] = (($number / 256) - (floor($number / 256))) * 256;
331 $number = floor($number / 256);
332 }
333 $bytes[] = $number;
334 $binstring = '';
335 for ($i = 0; $i < count($bytes); $i++) {
336 $binstring = (($i == count($bytes) - 1) ? decbin($bytes[$i]) : str_pad(decbin($bytes[$i]), 8, '0', STR_PAD_LEFT)).$binstring;
337 }
338 return $binstring;
339 }

References $i.

Referenced by getid3_riff\Analyze(), getid3_write_id3v2\GenerateID3v2FrameData(), and getid3_id3v2\ParseID3v2Frame().

+ Here is the caller graph for this function:

◆ DecimalBinary2Float()

static getid3_lib::DecimalBinary2Float (   $binarynumerator)
static

Definition at line 102 of file getid3.lib.php.

102 {
103 $numerator = self::Bin2Dec($binarynumerator);
104 $denominator = self::Bin2Dec('1'.str_repeat('0', strlen($binarynumerator)));
105 return ($numerator / $denominator);
106 }

References Bin2Dec().

Referenced by BigEndian2Float().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DecimalizeFraction()

static getid3_lib::DecimalizeFraction (   $fraction)
static

Definition at line 96 of file getid3.lib.php.

96 {
97 list($numerator, $denominator) = explode('/', $fraction);
98 return $numerator / ($denominator ? $denominator : 1);
99 }

Referenced by getid3_jpg\Analyze(), and getid3_jpg\CastAsAppropriate().

+ Here is the caller graph for this function:

◆ EmbeddedLookup()

static getid3_lib::EmbeddedLookup (   $key,
  $begin,
  $end,
  $file,
  $name 
)
static

Definition at line 1327 of file getid3.lib.php.

1327 {
1328
1329 // Cached
1330 static $cache;
1331 if (isset($cache[$file][$name])) {
1332 return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
1333 }
1334
1335 // Init
1336 $keylength = strlen($key);
1337 $line_count = $end - $begin - 7;
1338
1339 // Open php file
1340 $fp = fopen($file, 'r');
1341
1342 // Discard $begin lines
1343 for ($i = 0; $i < ($begin + 3); $i++) {
1344 fgets($fp, 1024);
1345 }
1346
1347 // Loop thru line
1348 while (0 < $line_count--) {
1349
1350 // Read line
1351 $line = ltrim(fgets($fp, 1024), "\t ");
1352
1353 // METHOD A: only cache the matching key - less memory but slower on next lookup of not-previously-looked-up key
1354 //$keycheck = substr($line, 0, $keylength);
1355 //if ($key == $keycheck) {
1356 // $cache[$file][$name][$keycheck] = substr($line, $keylength + 1);
1357 // break;
1358 //}
1359
1360 // METHOD B: cache all keys in this lookup - more memory but faster on next lookup of not-previously-looked-up key
1361 //$cache[$file][$name][substr($line, 0, $keylength)] = trim(substr($line, $keylength + 1));
1362 $explodedLine = explode("\t", $line, 2);
1363 $ThisKey = (isset($explodedLine[0]) ? $explodedLine[0] : '');
1364 $ThisValue = (isset($explodedLine[1]) ? $explodedLine[1] : '');
1365 $cache[$file][$name][$ThisKey] = trim($ThisValue);
1366 }
1367
1368 // Close and return
1369 fclose($fp);
1370 return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
1371 }

References $end, $i, $key, and $name.

Referenced by getid3_riff\fourccLookup(), getid3_id3v2\FrameNameLongLookup(), getid3_id3v2\FrameNameShortLookup(), getid3_midi\GeneralMIDIinstrumentLookup(), getid3_midi\GeneralMIDIpercussionLookup(), getid3_id3v2\LanguageLookup(), getid3_id3v2\LookupCurrencyCountry(), getid3_id3v2\LookupCurrencyUnits(), getid3_riff\waveSNDMtagLookup(), and getid3_riff\wFormatTagLookup().

+ Here is the caller graph for this function:

◆ fileextension()

static getid3_lib::fileextension (   $filename,
  $numextensions = 1 
)
static

Definition at line 442 of file getid3.lib.php.

442 {
443 if (strstr($filename, '.')) {
444 $reversedfilename = strrev($filename);
445 $offset = 0;
446 for ($i = 0; $i < $numextensions; $i++) {
447 $offset = strpos($reversedfilename, '.', $offset + 1);
448 if ($offset === false) {
449 return '';
450 }
451 }
452 return strrev(substr($reversedfilename, 0, $offset));
453 }
454 return '';
455 }
$filename
Definition: buildRTE.php:89

References $filename, and $i.

Referenced by getid3_optimfrog\ParseOptimFROGheader45().

+ Here is the caller graph for this function:

◆ FixedPoint16_16()

static getid3_lib::FixedPoint16_16 (   $rawdata)
static

Definition at line 480 of file getid3.lib.php.

480 {
481 return self::BigEndian2Int(substr($rawdata, 0, 2)) + (float) (self::BigEndian2Int(substr($rawdata, 2, 2)) / pow(2, 16));
482 }
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:263

References BigEndian2Int().

Referenced by getid3_riff\Analyze(), and getid3_quicktime\QuicktimeParseAtom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FixedPoint2_30()

static getid3_lib::FixedPoint2_30 (   $rawdata)
static

Definition at line 485 of file getid3.lib.php.

485 {
486 $binarystring = self::BigEndian2Bin($rawdata);
487 return self::Bin2Dec(substr($binarystring, 0, 2)) + (float) (self::Bin2Dec(substr($binarystring, 2, 30)) / pow(2, 30));
488 }

References BigEndian2Bin(), and Bin2Dec().

Referenced by getid3_bmp\Analyze(), and getid3_quicktime\QuicktimeParseAtom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FixedPoint8_8()

static getid3_lib::FixedPoint8_8 (   $rawdata)
static

Definition at line 475 of file getid3.lib.php.

475 {
476 return self::BigEndian2Int(substr($rawdata, 0, 1)) + (float) (self::BigEndian2Int(substr($rawdata, 1, 1)) / pow(2, 8));
477 }

References BigEndian2Int().

Referenced by getid3_quicktime\QuicktimeParseAtom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flipped_array_merge_noclobber()

static getid3_lib::flipped_array_merge_noclobber (   $array1,
  $array2 
)
static

Definition at line 417 of file getid3.lib.php.

417 {
418 if (!is_array($array1) || !is_array($array2)) {
419 return false;
420 }
421 # naturally, this only works non-recursively
422 $newarray = array_flip($array1);
423 foreach (array_flip($array2) as $key => $val) {
424 if (!isset($newarray[$key])) {
425 $newarray[$key] = count($newarray);
426 }
427 }
428 return array_flip($newarray);
429 }

References $key.

◆ Float2BinaryDecimal()

static getid3_lib::Float2BinaryDecimal (   $floatvalue)
static

Definition at line 133 of file getid3.lib.php.

133 {
134 // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
135 $maxbits = 128; // to how many bits of precision should the calculations be taken?
136 $intpart = self::trunc($floatvalue);
137 $floatpart = abs($floatvalue - $intpart);
138 $pointbitstring = '';
139 while (($floatpart != 0) && (strlen($pointbitstring) < $maxbits)) {
140 $floatpart *= 2;
141 $pointbitstring .= (string) self::trunc($floatpart);
142 $floatpart -= self::trunc($floatpart);
143 }
144 $binarypointnumber = decbin($intpart).'.'.$pointbitstring;
145 return $binarypointnumber;
146 }
static trunc($floatnumber)
Definition: getid3.lib.php:39

References trunc().

+ Here is the call graph for this function:

◆ Float2String()

static getid3_lib::Float2String (   $floatvalue,
  $bits 
)
static

Definition at line 149 of file getid3.lib.php.

149 {
150 // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee-expl.html
151 switch ($bits) {
152 case 32:
153 $exponentbits = 8;
154 $fractionbits = 23;
155 break;
156
157 case 64:
158 $exponentbits = 11;
159 $fractionbits = 52;
160 break;
161
162 default:
163 return false;
164 break;
165 }
166 if ($floatvalue >= 0) {
167 $signbit = '0';
168 } else {
169 $signbit = '1';
170 }
171 $normalizedbinary = self::NormalizeBinaryPoint(self::Float2BinaryDecimal($floatvalue), $fractionbits);
172 $biasedexponent = pow(2, $exponentbits - 1) - 1 + $normalizedbinary['exponent']; // (127 or 1023) +/- exponent
173 $exponentbitstring = str_pad(decbin($biasedexponent), $exponentbits, '0', STR_PAD_LEFT);
174 $fractionbitstring = str_pad(substr($normalizedbinary['normalized'], 2), $fractionbits, '0', STR_PAD_RIGHT);
175
176 return self::BigEndian2String(self::Bin2Dec($signbit.$exponentbitstring.$fractionbitstring), $bits % 8, false);
177 }
static BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:307
static NormalizeBinaryPoint($binarypointnumber, $maxbits=52)
Definition: getid3.lib.php:109

References BigEndian2String(), and NormalizeBinaryPoint().

Referenced by getid3_write_id3v2\GenerateID3v2FrameData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDataImageSize()

static getid3_lib::GetDataImageSize (   $imgData,
$imageinfo = array() 
)
static

Definition at line 1179 of file getid3.lib.php.

1179 {
1180 static $tempdir = '';
1181 if (empty($tempdir)) {
1182 if (function_exists('sys_get_temp_dir')) {
1183 $tempdir = sys_get_temp_dir(); // https://github.com/JamesHeinrich/getID3/issues/52
1184 }
1185
1186 // yes this is ugly, feel free to suggest a better way
1187 if (include_once(dirname(__FILE__).'/getid3.php')) {
1188 if ($getid3_temp = new getID3()) {
1189 if ($getid3_temp_tempdir = $getid3_temp->tempdir) {
1190 $tempdir = $getid3_temp_tempdir;
1191 }
1192 unset($getid3_temp, $getid3_temp_tempdir);
1193 }
1194 }
1195 }
1196 $GetDataImageSize = false;
1197 if ($tempfilename = tempnam($tempdir, 'gI3')) {
1198 if (is_writable($tempfilename) && is_file($tempfilename) && ($tmp = fopen($tempfilename, 'wb'))) {
1199 fwrite($tmp, $imgData);
1200 fclose($tmp);
1201 $GetDataImageSize = @getimagesize($tempfilename, $imageinfo);
1202 if (($GetDataImageSize === false) || !isset($GetDataImageSize[0]) || !isset($GetDataImageSize[1])) {
1203 return false;
1204 }
1205 $GetDataImageSize['height'] = $GetDataImageSize[0];
1206 $GetDataImageSize['width'] = $GetDataImageSize[1];
1207 }
1208 unlink($tempfilename);
1209 }
1210 return $GetDataImageSize;
1211 }

Referenced by getid3_apetag\Analyze(), getid3_asf\ASF_WMpicture(), getid3_id3v2\ParseID3v2Frame(), and getid3_ogg\ParseVorbisComments().

+ Here is the caller graph for this function:

◆ getFileSizeSyscall()

static getid3_lib::getFileSizeSyscall (   $path)
static

Definition at line 1397 of file getid3.lib.php.

1397 {
1398 $filesize = false;
1399
1400 if (GETID3_OS_ISWINDOWS) {
1401 if (class_exists('COM')) { // From PHP 5.3.15 and 5.4.5, COM and DOTNET is no longer built into the php core.you have to add COM support in php.ini:
1402 $filesystem = new COM('Scripting.FileSystemObject');
1403 $file = $filesystem->GetFile($path);
1404 $filesize = $file->Size();
1405 unset($filesystem, $file);
1406 } else {
1407 $commandline = 'for %I in ('.escapeshellarg($path).') do @echo %~zI';
1408 }
1409 } else {
1410 $commandline = 'ls -l '.escapeshellarg($path).' | awk \'{print $5}\'';
1411 }
1412 if (isset($commandline)) {
1413 $output = trim(`$commandline`);
1414 if (ctype_digit($output)) {
1415 $filesize = (float) $output;
1416 }
1417 }
1418 return $filesize;
1419 }
$path
Definition: aliased.php:25

References Sabre\VObject\$output, and $path.

Referenced by getID3\openfile().

+ Here is the caller graph for this function:

◆ hash_data()

static getid3_lib::hash_data (   $file,
  $offset,
  $end,
  $algorithm 
)
static

Definition at line 562 of file getid3.lib.php.

562 {
563 static $tempdir = '';
564 if (!self::intValueSupported($end)) {
565 return false;
566 }
567 switch ($algorithm) {
568 case 'md5':
569 $hash_function = 'md5_file';
570 $unix_call = 'md5sum';
571 $windows_call = 'md5sum.exe';
572 $hash_length = 32;
573 break;
574
575 case 'sha1':
576 $hash_function = 'sha1_file';
577 $unix_call = 'sha1sum';
578 $windows_call = 'sha1sum.exe';
579 $hash_length = 40;
580 break;
581
582 default:
583 throw new Exception('Invalid algorithm ('.$algorithm.') in self::hash_data()');
584 break;
585 }
586 $size = $end - $offset;
587 while (true) {
588 if (GETID3_OS_ISWINDOWS) {
589
590 // It seems that sha1sum.exe for Windows only works on physical files, does not accept piped data
591 // Fall back to create-temp-file method:
592 if ($algorithm == 'sha1') {
593 break;
594 }
595
596 $RequiredFiles = array('cygwin1.dll', 'head.exe', 'tail.exe', $windows_call);
597 foreach ($RequiredFiles as $required_file) {
598 if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
599 // helper apps not available - fall back to old method
600 break 2;
601 }
602 }
603 $commandline = GETID3_HELPERAPPSDIR.'head.exe -c '.$end.' '.escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $file)).' | ';
604 $commandline .= GETID3_HELPERAPPSDIR.'tail.exe -c '.$size.' | ';
605 $commandline .= GETID3_HELPERAPPSDIR.$windows_call;
606
607 } else {
608
609 $commandline = 'head -c'.$end.' '.escapeshellarg($file).' | ';
610 $commandline .= 'tail -c'.$size.' | ';
611 $commandline .= $unix_call;
612
613 }
614 if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
615 //throw new Exception('PHP running in Safe Mode - backtick operator not available, using slower non-system-call '.$algorithm.' algorithm');
616 break;
617 }
618 return substr(`$commandline`, 0, $hash_length);
619 }
620
621 if (empty($tempdir)) {
622 // yes this is ugly, feel free to suggest a better way
623 require_once(dirname(__FILE__).'/getid3.php');
624 $getid3_temp = new getID3();
625 $tempdir = $getid3_temp->tempdir;
626 unset($getid3_temp);
627 }
628 // try to create a temporary file in the system temp directory - invalid dirname should force to system temp dir
629 if (($data_filename = tempnam($tempdir, 'gI3')) === false) {
630 // can't find anywhere to create a temp file, just fail
631 return false;
632 }
633
634 // Init
635 $result = false;
636
637 // copy parts of file
638 try {
639 self::CopyFileParts($file, $data_filename, $offset, $end - $offset);
640 $result = $hash_function($data_filename);
641 } catch (Exception $e) {
642 throw new Exception('self::CopyFileParts() failed in getid_lib::hash_data(): '.$e->getMessage());
643 }
644 unlink($data_filename);
645 return $result;
646 }
$result
$size
Definition: RandomTest.php:84
static CopyFileParts($filename_source, $filename_dest, $offset, $length)
Definition: getid3.lib.php:648

References $end, $result, $size, and CopyFileParts().

Referenced by getID3\getHashdata().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iconv_fallback()

static getid3_lib::iconv_fallback (   $in_charset,
  $out_charset,
  $string 
)
static

Definition at line 957 of file getid3.lib.php.

957 {
958
959 if ($in_charset == $out_charset) {
960 return $string;
961 }
962
963 // mb_convert_encoding() availble
964 if (function_exists('mb_convert_encoding')) {
965 if ($converted_string = @mb_convert_encoding($string, $out_charset, $in_charset)) {
966 switch ($out_charset) {
967 case 'ISO-8859-1':
968 $converted_string = rtrim($converted_string, "\x00");
969 break;
970 }
971 return $converted_string;
972 }
973 return $string;
974 }
975 // iconv() availble
976 else if (function_exists('iconv')) {
977 if ($converted_string = @iconv($in_charset, $out_charset.'//TRANSLIT', $string)) {
978 switch ($out_charset) {
979 case 'ISO-8859-1':
980 $converted_string = rtrim($converted_string, "\x00");
981 break;
982 }
983 return $converted_string;
984 }
985
986 // iconv() may sometimes fail with "illegal character in input string" error message
987 // and return an empty string, but returning the unconverted string is more useful
988 return $string;
989 }
990
991
992 // neither mb_convert_encoding or iconv() is available
993 static $ConversionFunctionList = array();
994 if (empty($ConversionFunctionList)) {
995 $ConversionFunctionList['ISO-8859-1']['UTF-8'] = 'iconv_fallback_iso88591_utf8';
996 $ConversionFunctionList['ISO-8859-1']['UTF-16'] = 'iconv_fallback_iso88591_utf16';
997 $ConversionFunctionList['ISO-8859-1']['UTF-16BE'] = 'iconv_fallback_iso88591_utf16be';
998 $ConversionFunctionList['ISO-8859-1']['UTF-16LE'] = 'iconv_fallback_iso88591_utf16le';
999 $ConversionFunctionList['UTF-8']['ISO-8859-1'] = 'iconv_fallback_utf8_iso88591';
1000 $ConversionFunctionList['UTF-8']['UTF-16'] = 'iconv_fallback_utf8_utf16';
1001 $ConversionFunctionList['UTF-8']['UTF-16BE'] = 'iconv_fallback_utf8_utf16be';
1002 $ConversionFunctionList['UTF-8']['UTF-16LE'] = 'iconv_fallback_utf8_utf16le';
1003 $ConversionFunctionList['UTF-16']['ISO-8859-1'] = 'iconv_fallback_utf16_iso88591';
1004 $ConversionFunctionList['UTF-16']['UTF-8'] = 'iconv_fallback_utf16_utf8';
1005 $ConversionFunctionList['UTF-16LE']['ISO-8859-1'] = 'iconv_fallback_utf16le_iso88591';
1006 $ConversionFunctionList['UTF-16LE']['UTF-8'] = 'iconv_fallback_utf16le_utf8';
1007 $ConversionFunctionList['UTF-16BE']['ISO-8859-1'] = 'iconv_fallback_utf16be_iso88591';
1008 $ConversionFunctionList['UTF-16BE']['UTF-8'] = 'iconv_fallback_utf16be_utf8';
1009 }
1010 if (isset($ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)])) {
1011 $ConversionFunction = $ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)];
1012 return self::$ConversionFunction($string);
1013 }
1014 throw new Exception('PHP does not has mb_convert_encoding() or iconv() support - cannot convert from '.$in_charset.' to '.$out_charset);
1015 }

Referenced by getID3\CharConvert(), getid3_writetags\FormatDataForAPE(), getid3_writetags\FormatDataForID3v1(), getid3_writetags\FormatDataForID3v2(), getid3_writetags\FormatDataForReal(), getid3_writetags\FormatDataForVorbisComment(), getid3_write_id3v2\GenerateID3v2Tag(), getid3_iso\ParseDirectoryRecord(), getid3_id3v2\ParseID3v2Frame(), getid3_iso\ParsePathTable(), getid3_asf\TrimConvert(), and getid3_asf\WMpictureTypeLookup().

+ Here is the caller graph for this function:

◆ iconv_fallback_int_utf8()

static getid3_lib::iconv_fallback_int_utf8 (   $charval)
static

Definition at line 675 of file getid3.lib.php.

675 {
676 if ($charval < 128) {
677 // 0bbbbbbb
678 $newcharstring = chr($charval);
679 } elseif ($charval < 2048) {
680 // 110bbbbb 10bbbbbb
681 $newcharstring = chr(($charval >> 6) | 0xC0);
682 $newcharstring .= chr(($charval & 0x3F) | 0x80);
683 } elseif ($charval < 65536) {
684 // 1110bbbb 10bbbbbb 10bbbbbb
685 $newcharstring = chr(($charval >> 12) | 0xE0);
686 $newcharstring .= chr(($charval >> 6) | 0xC0);
687 $newcharstring .= chr(($charval & 0x3F) | 0x80);
688 } else {
689 // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
690 $newcharstring = chr(($charval >> 18) | 0xF0);
691 $newcharstring .= chr(($charval >> 12) | 0xC0);
692 $newcharstring .= chr(($charval >> 6) | 0xC0);
693 $newcharstring .= chr(($charval & 0x3F) | 0x80);
694 }
695 return $newcharstring;
696 }

Referenced by iconv_fallback_iso88591_utf8(), iconv_fallback_utf16be_utf8(), and iconv_fallback_utf16le_utf8().

+ Here is the caller graph for this function:

◆ iconv_fallback_iso88591_utf16()

static getid3_lib::iconv_fallback_iso88591_utf16 (   $string)
static

Definition at line 740 of file getid3.lib.php.

740 {
741 return self::iconv_fallback_iso88591_utf16le($string, true);
742 }
static iconv_fallback_iso88591_utf16le($string, $bom=false)
Definition: getid3.lib.php:728

References iconv_fallback_iso88591_utf16le().

+ Here is the call graph for this function:

◆ iconv_fallback_iso88591_utf16be()

static getid3_lib::iconv_fallback_iso88591_utf16be (   $string,
  $bom = false 
)
static

Definition at line 716 of file getid3.lib.php.

716 {
717 $newcharstring = '';
718 if ($bom) {
719 $newcharstring .= "\xFE\xFF";
720 }
721 for ($i = 0; $i < strlen($string); $i++) {
722 $newcharstring .= "\x00".$string{$i};
723 }
724 return $newcharstring;
725 }

References $i.

◆ iconv_fallback_iso88591_utf16le()

static getid3_lib::iconv_fallback_iso88591_utf16le (   $string,
  $bom = false 
)
static

Definition at line 728 of file getid3.lib.php.

728 {
729 $newcharstring = '';
730 if ($bom) {
731 $newcharstring .= "\xFF\xFE";
732 }
733 for ($i = 0; $i < strlen($string); $i++) {
734 $newcharstring .= $string{$i}."\x00";
735 }
736 return $newcharstring;
737 }

References $i.

Referenced by iconv_fallback_iso88591_utf16().

+ Here is the caller graph for this function:

◆ iconv_fallback_iso88591_utf8()

static getid3_lib::iconv_fallback_iso88591_utf8 (   $string,
  $bom = false 
)
static

Definition at line 699 of file getid3.lib.php.

699 {
700 if (function_exists('utf8_encode')) {
701 return utf8_encode($string);
702 }
703 // utf8_encode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
704 $newcharstring = '';
705 if ($bom) {
706 $newcharstring .= "\xEF\xBB\xBF";
707 }
708 for ($i = 0; $i < strlen($string); $i++) {
709 $charval = ord($string{$i});
710 $newcharstring .= self::iconv_fallback_int_utf8($charval);
711 }
712 return $newcharstring;
713 }
static iconv_fallback_int_utf8($charval)
Definition: getid3.lib.php:675

References $i, and iconv_fallback_int_utf8().

Referenced by getid3_id3v2\ParseID3v2Frame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iconv_fallback_utf16_iso88591()

static getid3_lib::iconv_fallback_utf16_iso88591 (   $string)
static

Definition at line 936 of file getid3.lib.php.

936 {
937 $bom = substr($string, 0, 2);
938 if ($bom == "\xFE\xFF") {
939 return self::iconv_fallback_utf16be_iso88591(substr($string, 2));
940 } elseif ($bom == "\xFF\xFE") {
941 return self::iconv_fallback_utf16le_iso88591(substr($string, 2));
942 }
943 return $string;
944 }
static iconv_fallback_utf16le_iso88591($string)
Definition: getid3.lib.php:922
static iconv_fallback_utf16be_iso88591($string)
Definition: getid3.lib.php:908

References iconv_fallback_utf16be_iso88591(), and iconv_fallback_utf16le_iso88591().

+ Here is the call graph for this function:

◆ iconv_fallback_utf16_utf8()

static getid3_lib::iconv_fallback_utf16_utf8 (   $string)
static

Definition at line 947 of file getid3.lib.php.

947 {
948 $bom = substr($string, 0, 2);
949 if ($bom == "\xFE\xFF") {
950 return self::iconv_fallback_utf16be_utf8(substr($string, 2));
951 } elseif ($bom == "\xFF\xFE") {
952 return self::iconv_fallback_utf16le_utf8(substr($string, 2));
953 }
954 return $string;
955 }
static iconv_fallback_utf16le_utf8($string)
Definition: getid3.lib.php:894
static iconv_fallback_utf16be_utf8($string)
Definition: getid3.lib.php:880

References iconv_fallback_utf16be_utf8(), and iconv_fallback_utf16le_utf8().

+ Here is the call graph for this function:

◆ iconv_fallback_utf16be_iso88591()

static getid3_lib::iconv_fallback_utf16be_iso88591 (   $string)
static

Definition at line 908 of file getid3.lib.php.

908 {
909 if (substr($string, 0, 2) == "\xFE\xFF") {
910 // strip BOM
911 $string = substr($string, 2);
912 }
913 $newcharstring = '';
914 for ($i = 0; $i < strlen($string); $i += 2) {
915 $charval = self::BigEndian2Int(substr($string, $i, 2));
916 $newcharstring .= (($charval < 256) ? chr($charval) : '?');
917 }
918 return $newcharstring;
919 }

References $i, and BigEndian2Int().

Referenced by iconv_fallback_utf16_iso88591().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iconv_fallback_utf16be_utf8()

static getid3_lib::iconv_fallback_utf16be_utf8 (   $string)
static

Definition at line 880 of file getid3.lib.php.

880 {
881 if (substr($string, 0, 2) == "\xFE\xFF") {
882 // strip BOM
883 $string = substr($string, 2);
884 }
885 $newcharstring = '';
886 for ($i = 0; $i < strlen($string); $i += 2) {
887 $charval = self::BigEndian2Int(substr($string, $i, 2));
888 $newcharstring .= self::iconv_fallback_int_utf8($charval);
889 }
890 return $newcharstring;
891 }

References $i, BigEndian2Int(), and iconv_fallback_int_utf8().

Referenced by iconv_fallback_utf16_utf8().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iconv_fallback_utf16le_iso88591()

static getid3_lib::iconv_fallback_utf16le_iso88591 (   $string)
static

Definition at line 922 of file getid3.lib.php.

922 {
923 if (substr($string, 0, 2) == "\xFF\xFE") {
924 // strip BOM
925 $string = substr($string, 2);
926 }
927 $newcharstring = '';
928 for ($i = 0; $i < strlen($string); $i += 2) {
929 $charval = self::LittleEndian2Int(substr($string, $i, 2));
930 $newcharstring .= (($charval < 256) ? chr($charval) : '?');
931 }
932 return $newcharstring;
933 }
static LittleEndian2Int($byteword, $signed=false)
Definition: getid3.lib.php:292

References $i, and LittleEndian2Int().

Referenced by iconv_fallback_utf16_iso88591().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iconv_fallback_utf16le_utf8()

static getid3_lib::iconv_fallback_utf16le_utf8 (   $string)
static

Definition at line 894 of file getid3.lib.php.

894 {
895 if (substr($string, 0, 2) == "\xFF\xFE") {
896 // strip BOM
897 $string = substr($string, 2);
898 }
899 $newcharstring = '';
900 for ($i = 0; $i < strlen($string); $i += 2) {
901 $charval = self::LittleEndian2Int(substr($string, $i, 2));
902 $newcharstring .= self::iconv_fallback_int_utf8($charval);
903 }
904 return $newcharstring;
905 }

References $i, iconv_fallback_int_utf8(), and LittleEndian2Int().

Referenced by iconv_fallback_utf16_utf8().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iconv_fallback_utf8_iso88591()

static getid3_lib::iconv_fallback_utf8_iso88591 (   $string)
static

Definition at line 745 of file getid3.lib.php.

745 {
746 if (function_exists('utf8_decode')) {
747 return utf8_decode($string);
748 }
749 // utf8_decode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
750 $newcharstring = '';
751 $offset = 0;
752 $stringlength = strlen($string);
753 while ($offset < $stringlength) {
754 if ((ord($string{$offset}) | 0x07) == 0xF7) {
755 // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
756 $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
757 ((ord($string{($offset + 1)}) & 0x3F) << 12) &
758 ((ord($string{($offset + 2)}) & 0x3F) << 6) &
759 (ord($string{($offset + 3)}) & 0x3F);
760 $offset += 4;
761 } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
762 // 1110bbbb 10bbbbbb 10bbbbbb
763 $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
764 ((ord($string{($offset + 1)}) & 0x3F) << 6) &
765 (ord($string{($offset + 2)}) & 0x3F);
766 $offset += 3;
767 } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
768 // 110bbbbb 10bbbbbb
769 $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
770 (ord($string{($offset + 1)}) & 0x3F);
771 $offset += 2;
772 } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
773 // 0bbbbbbb
774 $charval = ord($string{$offset});
775 $offset += 1;
776 } else {
777 // error? throw some kind of warning here?
778 $charval = false;
779 $offset += 1;
780 }
781 if ($charval !== false) {
782 $newcharstring .= (($charval < 256) ? chr($charval) : '?');
783 }
784 }
785 return $newcharstring;
786 }

◆ iconv_fallback_utf8_utf16()

static getid3_lib::iconv_fallback_utf8_utf16 (   $string)
static

Definition at line 875 of file getid3.lib.php.

875 {
876 return self::iconv_fallback_utf8_utf16le($string, true);
877 }
static iconv_fallback_utf8_utf16le($string, $bom=false)
Definition: getid3.lib.php:832

References iconv_fallback_utf8_utf16le().

+ Here is the call graph for this function:

◆ iconv_fallback_utf8_utf16be()

static getid3_lib::iconv_fallback_utf8_utf16be (   $string,
  $bom = false 
)
static

Definition at line 789 of file getid3.lib.php.

789 {
790 $newcharstring = '';
791 if ($bom) {
792 $newcharstring .= "\xFE\xFF";
793 }
794 $offset = 0;
795 $stringlength = strlen($string);
796 while ($offset < $stringlength) {
797 if ((ord($string{$offset}) | 0x07) == 0xF7) {
798 // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
799 $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
800 ((ord($string{($offset + 1)}) & 0x3F) << 12) &
801 ((ord($string{($offset + 2)}) & 0x3F) << 6) &
802 (ord($string{($offset + 3)}) & 0x3F);
803 $offset += 4;
804 } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
805 // 1110bbbb 10bbbbbb 10bbbbbb
806 $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
807 ((ord($string{($offset + 1)}) & 0x3F) << 6) &
808 (ord($string{($offset + 2)}) & 0x3F);
809 $offset += 3;
810 } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
811 // 110bbbbb 10bbbbbb
812 $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
813 (ord($string{($offset + 1)}) & 0x3F);
814 $offset += 2;
815 } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
816 // 0bbbbbbb
817 $charval = ord($string{$offset});
818 $offset += 1;
819 } else {
820 // error? throw some kind of warning here?
821 $charval = false;
822 $offset += 1;
823 }
824 if ($charval !== false) {
825 $newcharstring .= (($charval < 65536) ? self::BigEndian2String($charval, 2) : "\x00".'?');
826 }
827 }
828 return $newcharstring;
829 }

◆ iconv_fallback_utf8_utf16le()

static getid3_lib::iconv_fallback_utf8_utf16le (   $string,
  $bom = false 
)
static

Definition at line 832 of file getid3.lib.php.

832 {
833 $newcharstring = '';
834 if ($bom) {
835 $newcharstring .= "\xFF\xFE";
836 }
837 $offset = 0;
838 $stringlength = strlen($string);
839 while ($offset < $stringlength) {
840 if ((ord($string{$offset}) | 0x07) == 0xF7) {
841 // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
842 $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
843 ((ord($string{($offset + 1)}) & 0x3F) << 12) &
844 ((ord($string{($offset + 2)}) & 0x3F) << 6) &
845 (ord($string{($offset + 3)}) & 0x3F);
846 $offset += 4;
847 } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
848 // 1110bbbb 10bbbbbb 10bbbbbb
849 $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
850 ((ord($string{($offset + 1)}) & 0x3F) << 6) &
851 (ord($string{($offset + 2)}) & 0x3F);
852 $offset += 3;
853 } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
854 // 110bbbbb 10bbbbbb
855 $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
856 (ord($string{($offset + 1)}) & 0x3F);
857 $offset += 2;
858 } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
859 // 0bbbbbbb
860 $charval = ord($string{$offset});
861 $offset += 1;
862 } else {
863 // error? maybe throw some warning here?
864 $charval = false;
865 $offset += 1;
866 }
867 if ($charval !== false) {
868 $newcharstring .= (($charval < 65536) ? self::LittleEndian2String($charval, 2) : '?'."\x00");
869 }
870 }
871 return $newcharstring;
872 }

Referenced by iconv_fallback_utf8_utf16().

+ Here is the caller graph for this function:

◆ ImageExtFromMime()

static getid3_lib::ImageExtFromMime (   $mime_type)
static

Definition at line 1213 of file getid3.lib.php.

1213 {
1214 // temporary way, works OK for now, but should be reworked in the future
1215 return str_replace(array('image/', 'x-', 'jpeg'), array('', '', 'jpg'), $mime_type);
1216 }

◆ ImageTypesLookup()

static getid3_lib::ImageTypesLookup (   $imagetypeid)
static

Definition at line 1218 of file getid3.lib.php.

1218 {
1219 static $ImageTypesLookup = array();
1220 if (empty($ImageTypesLookup)) {
1221 $ImageTypesLookup[1] = 'gif';
1222 $ImageTypesLookup[2] = 'jpeg';
1223 $ImageTypesLookup[3] = 'png';
1224 $ImageTypesLookup[4] = 'swf';
1225 $ImageTypesLookup[5] = 'psd';
1226 $ImageTypesLookup[6] = 'bmp';
1227 $ImageTypesLookup[7] = 'tiff (little-endian)';
1228 $ImageTypesLookup[8] = 'tiff (big-endian)';
1229 $ImageTypesLookup[9] = 'jpc';
1230 $ImageTypesLookup[10] = 'jp2';
1231 $ImageTypesLookup[11] = 'jpx';
1232 $ImageTypesLookup[12] = 'jb2';
1233 $ImageTypesLookup[13] = 'swc';
1234 $ImageTypesLookup[14] = 'iff';
1235 }
1236 return (isset($ImageTypesLookup[$imagetypeid]) ? $ImageTypesLookup[$imagetypeid] : '');
1237 }

◆ IncludeDependency()

static getid3_lib::IncludeDependency (   $filename,
  $sourcefile,
  $DieOnFailure = false 
)
static

Definition at line 1373 of file getid3.lib.php.

1373 {
1374 global $GETID3_ERRORARRAY;
1375
1376 if (file_exists($filename)) {
1377 if (include_once($filename)) {
1378 return true;
1379 } else {
1380 $diemessage = basename($sourcefile).' depends on '.$filename.', which has errors';
1381 }
1382 } else {
1383 $diemessage = basename($sourcefile).' depends on '.$filename.', which is missing';
1384 }
1385 if ($DieOnFailure) {
1386 throw new Exception($diemessage);
1387 } else {
1388 $GETID3_ERRORARRAY[] = $diemessage;
1389 }
1390 return false;
1391 }

References $filename.

Referenced by getid3_matroska\Analyze(), getid3_riff\Analyze(), getid3_shorten\Analyze(), getid3_wavpack\Analyze(), getid3_jpg\Analyze(), getid3_lyrics3\Analyze(), and getid3_writetags\WriteTags().

+ Here is the caller graph for this function:

◆ intValueSupported()

static getid3_lib::intValueSupported (   $num)
static

Definition at line 80 of file getid3.lib.php.

80 {
81 // check if integers are 64-bit
82 static $hasINT64 = null;
83 if ($hasINT64 === null) { // 10x faster than is_null()
84 $hasINT64 = is_int(pow(2, 31)); // 32-bit int are limited to (2^31)-1
85 if (!$hasINT64 && !defined('PHP_INT_MIN')) {
86 define('PHP_INT_MIN', ~PHP_INT_MAX);
87 }
88 }
89 // if integers are 64-bit - no other check required
90 if ($hasINT64 || (($num <= PHP_INT_MAX) && ($num >= PHP_INT_MIN))) {
91 return true;
92 }
93 return false;
94 }

Referenced by getid3_zip\Analyze(), getid3_quicktime\Analyze(), getid3_bonk\Analyze(), getid3_ogg\Analyze(), getid3_apetag\Analyze(), getid3_id3v1\Analyze(), getid3_lyrics3\Analyze(), getid3_handler\fread(), getid3_handler\fseek(), getid3_aac\getAACADTSheaderFilepointer(), getid3_lyrics3\getLyrics3Data(), getID3\openfile(), getid3_write_id3v1\RemoveID3v1(), getid3_write_id3v2\RemoveID3v2(), getid3_write_id3v1\WriteID3v1(), and getid3_write_id3v2\WriteID3v2().

+ Here is the caller graph for this function:

◆ ksort_recursive()

static getid3_lib::ksort_recursive ( $theArray)
static

Definition at line 432 of file getid3.lib.php.

432 {
433 ksort($theArray);
434 foreach ($theArray as $key => $value) {
435 if (is_array($value)) {
436 self::ksort_recursive($theArray[$key]);
437 }
438 }
439 return true;
440 }
static ksort_recursive(&$theArray)
Definition: getid3.lib.php:432

References $key, and ksort_recursive().

Referenced by ksort_recursive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LittleEndian2Float()

static getid3_lib::LittleEndian2Float (   $byteword)
static

Definition at line 180 of file getid3.lib.php.

180 {
181 return self::BigEndian2Float(strrev($byteword));
182 }
static BigEndian2Float($byteword)
Definition: getid3.lib.php:185

References BigEndian2Float().

Referenced by getid3_riff\Analyze(), and getid3_mp3\decodeMPEGaudioHeader().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LittleEndian2Int()

static getid3_lib::LittleEndian2Int (   $byteword,
  $signed = false 
)
static

Definition at line 292 of file getid3.lib.php.

292 {
293 return self::BigEndian2Int(strrev($byteword), false, $signed);
294 }

References BigEndian2Int().

Referenced by getid3_gzip\Analyze(), getid3_asf\Analyze(), getid3_flv\Analyze(), getid3_riff\Analyze(), getid3_swf\Analyze(), getid3_ac3\Analyze(), getid3_bonk\Analyze(), getid3_dsf\Analyze(), getid3_dss\Analyze(), getid3_la\Analyze(), getid3_monkey\Analyze(), getid3_ogg\Analyze(), getid3_rkau\Analyze(), getid3_shorten\Analyze(), getid3_tta\Analyze(), getid3_voc\Analyze(), getid3_wavpack\Analyze(), getid3_bmp\Analyze(), getid3_efax\Analyze(), getid3_gif\Analyze(), getid3_exe\Analyze(), getid3_apetag\Analyze(), getid3_asf\ASF_WMpicture(), getid3_riff\EitherEndian2Int(), getid3_nsv\getNSVfHeaderFilepointer(), getid3_nsv\getNSVsHeaderFilepointer(), getid3_bonk\HandleBonkTags(), getid3_asf\HeaderExtensionObjectDataParse(), iconv_fallback_utf16le_iso88591(), iconv_fallback_utf16le_utf8(), MultiByteCharString2HTML(), getid3_apetag\parseAPEheaderFooter(), getid3_bink\ParseBink(), getid3_iso\ParseDirectoryRecord(), getid3_mpc\ParseMPCsv6(), getid3_mpc\ParseMPCsv7(), getid3_ogg\ParseOggPageHeader(), getid3_optimfrog\ParseOptimFROGheader42(), getid3_optimfrog\ParseOptimFROGheader45(), getid3_ogg\ParseOpusPageHeader(), getid3_iso\ParsePathTable(), getid3_iso\ParsePrimaryVolumeDescriptor(), getid3_riff\ParseRIFF(), getid3_riff\ParseRIFFAMV(), getid3_iso\ParseSupplementaryVolumeDescriptor(), getid3_ogg\ParseVorbisComments(), getid3_ogg\ParseVorbisPageHeader(), getid3_riff\parseWavPackHeader(), getid3_tiff\TIFFendian2Int(), getid3_zip\ZIPparseCentralDirectory(), getid3_zip\ZIPparseEndOfCentralDirectory(), and getid3_zip\ZIPparseLocalFileHeader().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LittleEndian2String()

static getid3_lib::LittleEndian2String (   $number,
  $minbytes = 1,
  $synchsafe = false 
)
static

Definition at line 369 of file getid3.lib.php.

369 {
370 $intstring = '';
371 while ($number > 0) {
372 if ($synchsafe) {
373 $intstring = $intstring.chr($number & 127);
374 $number >>= 7;
375 } else {
376 $intstring = $intstring.chr($number & 255);
377 $number >>= 8;
378 }
379 }
380 return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
381 }

Referenced by getid3_write_apetag\GenerateAPEtag(), getid3_write_apetag\GenerateAPEtagHeaderFooter(), and getid3_riff\ParseRIFFdata().

+ Here is the caller graph for this function:

◆ mb_basename()

static getid3_lib::mb_basename (   $path,
  $suffix = null 
)
static

Workaround for Bug #37268 (https://bugs.php.net/bug.php?id=37268)

Parameters
string$pathA path.
string$suffixIf the name component ends in suffix this will also be cut off.
Returns
string

Definition at line 1428 of file getid3.lib.php.

1428 {
1429 $splited = preg_split('#/#', rtrim($path, '/ '));
1430 return substr(basename('X'.$splited[count($splited) - 1], $suffix), 1);
1431 }

References $path.

Referenced by getID3\openfile().

+ Here is the caller graph for this function:

◆ MultiByteCharString2HTML()

static getid3_lib::MultiByteCharString2HTML (   $string,
  $charset = 'ISO-8859-1' 
)
static

Definition at line 1031 of file getid3.lib.php.

1031 {
1032 $string = (string) $string; // in case trying to pass a numeric (float, int) string, would otherwise return an empty string
1033 $HTMLstring = '';
1034
1035 switch (strtolower($charset)) {
1036 case '1251':
1037 case '1252':
1038 case '866':
1039 case '932':
1040 case '936':
1041 case '950':
1042 case 'big5':
1043 case 'big5-hkscs':
1044 case 'cp1251':
1045 case 'cp1252':
1046 case 'cp866':
1047 case 'euc-jp':
1048 case 'eucjp':
1049 case 'gb2312':
1050 case 'ibm866':
1051 case 'iso-8859-1':
1052 case 'iso-8859-15':
1053 case 'iso8859-1':
1054 case 'iso8859-15':
1055 case 'koi8-r':
1056 case 'koi8-ru':
1057 case 'koi8r':
1058 case 'shift_jis':
1059 case 'sjis':
1060 case 'win-1251':
1061 case 'windows-1251':
1062 case 'windows-1252':
1063 $HTMLstring = htmlentities($string, ENT_COMPAT, $charset);
1064 break;
1065
1066 case 'utf-8':
1067 $strlen = strlen($string);
1068 for ($i = 0; $i < $strlen; $i++) {
1069 $char_ord_val = ord($string{$i});
1070 $charval = 0;
1071 if ($char_ord_val < 0x80) {
1072 $charval = $char_ord_val;
1073 } elseif ((($char_ord_val & 0xF0) >> 4) == 0x0F && $i+3 < $strlen) {
1074 $charval = (($char_ord_val & 0x07) << 18);
1075 $charval += ((ord($string{++$i}) & 0x3F) << 12);
1076 $charval += ((ord($string{++$i}) & 0x3F) << 6);
1077 $charval += (ord($string{++$i}) & 0x3F);
1078 } elseif ((($char_ord_val & 0xE0) >> 5) == 0x07 && $i+2 < $strlen) {
1079 $charval = (($char_ord_val & 0x0F) << 12);
1080 $charval += ((ord($string{++$i}) & 0x3F) << 6);
1081 $charval += (ord($string{++$i}) & 0x3F);
1082 } elseif ((($char_ord_val & 0xC0) >> 6) == 0x03 && $i+1 < $strlen) {
1083 $charval = (($char_ord_val & 0x1F) << 6);
1084 $charval += (ord($string{++$i}) & 0x3F);
1085 }
1086 if (($charval >= 32) && ($charval <= 127)) {
1087 $HTMLstring .= htmlentities(chr($charval));
1088 } else {
1089 $HTMLstring .= '&#'.$charval.';';
1090 }
1091 }
1092 break;
1093
1094 case 'utf-16le':
1095 for ($i = 0; $i < strlen($string); $i += 2) {
1096 $charval = self::LittleEndian2Int(substr($string, $i, 2));
1097 if (($charval >= 32) && ($charval <= 127)) {
1098 $HTMLstring .= chr($charval);
1099 } else {
1100 $HTMLstring .= '&#'.$charval.';';
1101 }
1102 }
1103 break;
1104
1105 case 'utf-16be':
1106 for ($i = 0; $i < strlen($string); $i += 2) {
1107 $charval = self::BigEndian2Int(substr($string, $i, 2));
1108 if (($charval >= 32) && ($charval <= 127)) {
1109 $HTMLstring .= chr($charval);
1110 } else {
1111 $HTMLstring .= '&#'.$charval.';';
1112 }
1113 }
1114 break;
1115
1116 default:
1117 $HTMLstring = 'ERROR: Character set "'.$charset.'" not supported in MultiByteCharString2HTML()';
1118 break;
1119 }
1120 return $HTMLstring;
1121 }

References $i, BigEndian2Int(), and LittleEndian2Int().

Referenced by recursiveMultiByteCharString2HTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ NormalizeBinaryPoint()

static getid3_lib::NormalizeBinaryPoint (   $binarypointnumber,
  $maxbits = 52 
)
static

Definition at line 109 of file getid3.lib.php.

109 {
110 // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
111 if (strpos($binarypointnumber, '.') === false) {
112 $binarypointnumber = '0.'.$binarypointnumber;
113 } elseif ($binarypointnumber{0} == '.') {
114 $binarypointnumber = '0'.$binarypointnumber;
115 }
116 $exponent = 0;
117 while (($binarypointnumber{0} != '1') || (substr($binarypointnumber, 1, 1) != '.')) {
118 if (substr($binarypointnumber, 1, 1) == '.') {
119 $exponent--;
120 $binarypointnumber = substr($binarypointnumber, 2, 1).'.'.substr($binarypointnumber, 3);
121 } else {
122 $pointpos = strpos($binarypointnumber, '.');
123 $exponent += ($pointpos - 1);
124 $binarypointnumber = str_replace('.', '', $binarypointnumber);
125 $binarypointnumber = $binarypointnumber{0}.'.'.substr($binarypointnumber, 1);
126 }
127 }
128 $binarypointnumber = str_pad(substr($binarypointnumber, 0, $maxbits + 2), $maxbits + 2, '0', STR_PAD_RIGHT);
129 return array('normalized'=>$binarypointnumber, 'exponent'=>(int) $exponent);
130 }

Referenced by Float2String().

+ Here is the caller graph for this function:

◆ PlaytimeString()

static getid3_lib::PlaytimeString (   $seconds)
static

Definition at line 458 of file getid3.lib.php.

458 {
459 $sign = (($seconds < 0) ? '-' : '');
460 $seconds = round(abs($seconds));
461 $H = (int) floor( $seconds / 3600);
462 $M = (int) floor(($seconds - (3600 * $H) ) / 60);
463 $S = (int) round( $seconds - (3600 * $H) - (60 * $M) );
464 return $sign.($H ? $H.':' : '').($H ? str_pad($M, 2, '0', STR_PAD_LEFT) : intval($M)).':'.str_pad($S, 2, 0, STR_PAD_LEFT);
465 }

Referenced by getID3\ChannelsBitratePlaytimeCalculations().

+ Here is the caller graph for this function:

◆ PrintHexBytes()

static getid3_lib::PrintHexBytes (   $string,
  $hex = true,
  $spaces = true,
  $htmlencoding = 'UTF-8' 
)
static

Definition at line 18 of file getid3.lib.php.

18 {
19 $returnstring = '';
20 for ($i = 0; $i < strlen($string); $i++) {
21 if ($hex) {
22 $returnstring .= str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT);
23 } else {
24 $returnstring .= ' '.(preg_match("#[\x20-\x7E]#", $string{$i}) ? $string{$i} : '¤');
25 }
26 if ($spaces) {
27 $returnstring .= ' ';
28 }
29 }
30 if (!empty($htmlencoding)) {
31 if ($htmlencoding === true) {
32 $htmlencoding = 'UTF-8'; // prior to getID3 v1.9.0 the function's 4th parameter was boolean
33 }
34 $returnstring = htmlentities($returnstring, ENT_QUOTES, $htmlencoding);
35 }
36 return $returnstring;
37 }

References $i.

Referenced by getid3_szip\Analyze(), getid3_asf\Analyze(), getid3_bink\Analyze(), getid3_flv\Analyze(), getid3_nsv\Analyze(), getid3_riff\Analyze(), getid3_swf\Analyze(), getid3_ts\Analyze(), getid3_aa\Analyze(), getid3_amr\Analyze(), getid3_au\Analyze(), getid3_avr\Analyze(), getid3_bonk\Analyze(), getid3_dsf\Analyze(), getid3_dss\Analyze(), getid3_dts\Analyze(), getid3_flac\Analyze(), getid3_la\Analyze(), getid3_midi\Analyze(), getid3_monkey\Analyze(), getid3_mpc\Analyze(), getid3_optimfrog\Analyze(), getid3_rkau\Analyze(), getid3_shorten\Analyze(), getid3_tta\Analyze(), getid3_voc\Analyze(), getid3_vqf\Analyze(), getid3_wavpack\Analyze(), getid3_bmp\Analyze(), getid3_efax\Analyze(), getid3_gif\Analyze(), getid3_png\Analyze(), getid3_exe\Analyze(), getid3_msoffice\Analyze(), getid3_mp3\decodeMPEGaudioHeader(), getid3_mp3\FreeFormatFrameLength(), getid3_optimfrog\ParseOptimFROGheader45(), getid3_riff\ParseRIFFAMV(), getid3_quicktime\QuicktimeParseAtom(), and getid3_zip\ZIPparseLocalFileHeader().

+ Here is the caller graph for this function:

◆ recursiveMultiByteCharString2HTML()

static getid3_lib::recursiveMultiByteCharString2HTML (   $data,
  $charset = 'ISO-8859-1' 
)
static

Definition at line 1017 of file getid3.lib.php.

1017 {
1018 if (is_string($data)) {
1019 return self::MultiByteCharString2HTML($data, $charset);
1020 } elseif (is_array($data)) {
1021 $return_data = array();
1022 foreach ($data as $key => $value) {
1023 $return_data[$key] = self::recursiveMultiByteCharString2HTML($value, $charset);
1024 }
1025 return $return_data;
1026 }
1027 // integer, float, objects, resources, etc
1028 return $data;
1029 }
static MultiByteCharString2HTML($string, $charset='ISO-8859-1')
static recursiveMultiByteCharString2HTML($data, $charset='ISO-8859-1')
$data
Definition: bench.php:6

References $data, $key, MultiByteCharString2HTML(), and recursiveMultiByteCharString2HTML().

Referenced by getID3\HandleAllTags(), and recursiveMultiByteCharString2HTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RGADadjustmentLookup()

static getid3_lib::RGADadjustmentLookup (   $rawadjustment,
  $signbit 
)
static

Definition at line 1150 of file getid3.lib.php.

1150 {
1151 $adjustment = $rawadjustment / 10;
1152 if ($signbit == 1) {
1153 $adjustment *= -1;
1154 }
1155 return (float) $adjustment;
1156 }

Referenced by getid3_riff\Analyze(), getid3_mp3\decodeMPEGaudioHeader(), and getid3_id3v2\ParseID3v2Frame().

+ Here is the caller graph for this function:

◆ RGADamplitude2dB()

static getid3_lib::RGADamplitude2dB (   $amplitude)
static

Definition at line 1174 of file getid3.lib.php.

1174 {
1175 return 20 * log10($amplitude);
1176 }

Referenced by getID3\CalculateReplayGain(), getid3_mp3\decodeMPEGaudioHeader(), and getid3_ac3\heavyCompression().

+ Here is the caller graph for this function:

◆ RGADgainString()

static getid3_lib::RGADgainString (   $namecode,
  $originatorcode,
  $replaygain 
)
static

Definition at line 1159 of file getid3.lib.php.

1159 {
1160 if ($replaygain < 0) {
1161 $signbit = '1';
1162 } else {
1163 $signbit = '0';
1164 }
1165 $storedreplaygain = intval(round($replaygain * 10));
1166 $gainstring = str_pad(decbin($namecode), 3, '0', STR_PAD_LEFT);
1167 $gainstring .= str_pad(decbin($originatorcode), 3, '0', STR_PAD_LEFT);
1168 $gainstring .= $signbit;
1169 $gainstring .= str_pad(decbin($storedreplaygain), 9, '0', STR_PAD_LEFT);
1170
1171 return $gainstring;
1172 }

Referenced by getid3_write_id3v2\GenerateID3v2FrameData().

+ Here is the caller graph for this function:

◆ RGADnameLookup()

static getid3_lib::RGADnameLookup (   $namecode)
static

Definition at line 1125 of file getid3.lib.php.

1125 {
1126 static $RGADname = array();
1127 if (empty($RGADname)) {
1128 $RGADname[0] = 'not set';
1129 $RGADname[1] = 'Track Gain Adjustment';
1130 $RGADname[2] = 'Album Gain Adjustment';
1131 }
1132
1133 return (isset($RGADname[$namecode]) ? $RGADname[$namecode] : '');
1134 }

Referenced by getid3_riff\Analyze(), getid3_mp3\decodeMPEGaudioHeader(), and getid3_id3v2\ParseID3v2Frame().

+ Here is the caller graph for this function:

◆ RGADoriginatorLookup()

static getid3_lib::RGADoriginatorLookup (   $originatorcode)
static

Definition at line 1137 of file getid3.lib.php.

1137 {
1138 static $RGADoriginator = array();
1139 if (empty($RGADoriginator)) {
1140 $RGADoriginator[0] = 'unspecified';
1141 $RGADoriginator[1] = 'pre-set by artist/producer/mastering engineer';
1142 $RGADoriginator[2] = 'set by user';
1143 $RGADoriginator[3] = 'determined automatically';
1144 }
1145
1146 return (isset($RGADoriginator[$originatorcode]) ? $RGADoriginator[$originatorcode] : '');
1147 }

Referenced by getid3_riff\Analyze(), getid3_mp3\decodeMPEGaudioHeader(), and getid3_id3v2\ParseID3v2Frame().

+ Here is the caller graph for this function:

◆ safe_inc()

static getid3_lib::safe_inc ( $variable,
  $increment = 1 
)
static

Definition at line 56 of file getid3.lib.php.

56 {
57 if (isset($variable)) {
58 $variable += $increment;
59 } else {
60 $variable = $increment;
61 }
62 return true;
63 }

Referenced by getid3_voc\Analyze(), getid3_aac\getAACADTSheaderFilepointer(), getid3_mp3\getOnlyMPEGaudioInfo(), getid3_mp3\getOnlyMPEGaudioInfoBruteForce(), and getid3_flac\parseSEEKTABLE().

+ Here is the caller graph for this function:

◆ SimpleXMLelement2array()

static getid3_lib::SimpleXMLelement2array (   $XMLobject)
static

Definition at line 548 of file getid3.lib.php.

548 {
549 if (!is_object($XMLobject) && !is_array($XMLobject)) {
550 return $XMLobject;
551 }
552 $XMLarray = (is_object($XMLobject) ? get_object_vars($XMLobject) : $XMLobject);
553 foreach ($XMLarray as $key => $value) {
554 $XMLarray[$key] = self::SimpleXMLelement2array($value);
555 }
556 return $XMLarray;
557 }
static SimpleXMLelement2array($XMLobject)
Definition: getid3.lib.php:548

References $key, and SimpleXMLelement2array().

Referenced by SimpleXMLelement2array(), and XML2array().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ trimNullByte()

static getid3_lib::trimNullByte (   $string)
static

Definition at line 1393 of file getid3.lib.php.

1393 {
1394 return trim($string, "\x00");
1395 }

Referenced by getid3_matroska\parseEBML().

+ Here is the caller graph for this function:

◆ trunc()

static getid3_lib::trunc (   $floatnumber)
static

Definition at line 39 of file getid3.lib.php.

39 {
40 // truncates a floating-point number at the decimal point
41 // returns int (if possible, otherwise float)
42 if ($floatnumber >= 1) {
43 $truncatednumber = floor($floatnumber);
44 } elseif ($floatnumber <= -1) {
45 $truncatednumber = ceil($floatnumber);
46 } else {
47 $truncatednumber = 0;
48 }
49 if (self::intValueSupported($truncatednumber)) {
50 $truncatednumber = (int) $truncatednumber;
51 }
52 return $truncatednumber;
53 }

Referenced by getid3_voc\Analyze(), and Float2BinaryDecimal().

+ Here is the caller graph for this function:

◆ XML2array()

static getid3_lib::XML2array (   $XMLstring)
static

Definition at line 535 of file getid3.lib.php.

535 {
536 if (function_exists('simplexml_load_string') && function_exists('libxml_disable_entity_loader')) {
537 // http://websec.io/2012/08/27/Preventing-XEE-in-PHP.html
538 // https://core.trac.wordpress.org/changeset/29378
539 $loader = libxml_disable_entity_loader(true);
540 $XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', LIBXML_NOENT);
541 $return = self::SimpleXMLelement2array($XMLobject);
542 libxml_disable_entity_loader($loader);
543 return $return;
544 }
545 return false;
546 }

References SimpleXMLelement2array().

Referenced by getid3_riff\Analyze().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: