ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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:

Public Member Functions

 PrintHexBytes ($string, $hex=true, $spaces=true, $htmlsafe=true)
 
 SafeStripSlashes ($text)
 
 trunc ($floatnumber)
 
 CastAsInt ($floatnum)
 
 DecimalBinary2Float ($binarynumerator)
 
 NormalizeBinaryPoint ($binarypointnumber, $maxbits=52)
 
 Float2BinaryDecimal ($floatvalue)
 
 Float2String ($floatvalue, $bits)
 
 LittleEndian2Float ($byteword)
 
 BigEndian2Float ($byteword)
 
 BigEndian2Int ($byteword, $synchsafe=false, $signed=false)
 
 LittleEndian2Int ($byteword, $signed=false)
 
 BigEndian2Bin ($byteword)
 
 BigEndian2String ($number, $minbytes=1, $synchsafe=false, $signed=false)
 
 Dec2Bin ($number)
 
 Bin2Dec ($binstring, $signed=false)
 
 Bin2String ($binstring)
 
 LittleEndian2String ($number, $minbytes=1, $synchsafe=false)
 
 array_merge_clobber ($array1, $array2)
 
 array_merge_noclobber ($array1, $array2)
 
 fileextension ($filename, $numextensions=1)
 
 PlaytimeString ($playtimeseconds)
 
 image_type_to_mime_type ($imagetypeid)
 
 DateMac2Unix ($macdate)
 
 FixedPoint8_8 ($rawdata)
 
 FixedPoint16_16 ($rawdata)
 
 FixedPoint2_30 ($rawdata)
 
 CreateDeepArray ($ArrayPath, $Separator, $Value)
 
 array_max ($arraydata, $returnkey=false)
 
 array_min ($arraydata, $returnkey=false)
 
 md5_file ($file)
 
 sha1_file ($file)
 
 hash_data ($file, $offset, $end, $algorithm)
 
 iconv_fallback_int_utf8 ($charval)
 
 iconv_fallback_iso88591_utf8 ($string, $bom=false)
 
 iconv_fallback_iso88591_utf16be ($string, $bom=false)
 
 iconv_fallback_iso88591_utf16le ($string, $bom=false)
 
 iconv_fallback_iso88591_utf16 ($string)
 
 iconv_fallback_utf8_iso88591 ($string)
 
 iconv_fallback_utf8_utf16be ($string, $bom=false)
 
 iconv_fallback_utf8_utf16le ($string, $bom=false)
 
 iconv_fallback_utf8_utf16 ($string)
 
 iconv_fallback_utf16be_utf8 ($string)
 
 iconv_fallback_utf16le_utf8 ($string)
 
 iconv_fallback_utf16be_iso88591 ($string)
 
 iconv_fallback_utf16le_iso88591 ($string)
 
 iconv_fallback_utf16_iso88591 ($string)
 
 iconv_fallback_utf16_utf8 ($string)
 
 iconv_fallback ($in_charset, $out_charset, $string)
 
 MultiByteCharString2HTML ($string, $charset='ISO-8859-1')
 
 RGADnameLookup ($namecode)
 
 RGADoriginatorLookup ($originatorcode)
 
 RGADadjustmentLookup ($rawadjustment, $signbit)
 
 RGADgainString ($namecode, $originatorcode, $replaygain)
 
 RGADamplitude2dB ($amplitude)
 
 GetDataImageSize ($imgData)
 
 ImageTypesLookup ($imagetypeid)
 
 CopyTagsToComments (&$ThisFileInfo)
 
 EmbeddedLookup ($key, $begin, $end, $file, $name)
 
 IncludeDependency ($filename, $sourcefile, $DieOnFailure=false)
 

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 14 of file getid3.lib.php.

Member Function Documentation

◆ array_max() [1/2]

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

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

Referenced by getid3_mp3\getOnlyMPEGaudioInfoBruteForce().

483  {
484  $maxvalue = false;
485  $maxkey = false;
486  foreach ($arraydata as $key => $value) {
487  if (!is_array($value)) {
488  if ($value > $maxvalue) {
489  $maxvalue = $value;
490  $maxkey = $key;
491  }
492  }
493  }
494  return ($returnkey ? $maxkey : $maxvalue);
495  }
+ Here is the caller graph for this function:

◆ array_max() [2/2]

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  }

◆ array_merge_clobber() [1/2]

getid3_lib::array_merge_clobber (   $array1,
  $array2 
)

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

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

358  {
359  // written by kcØhireability*com
360  // taken from http://www.php.net/manual/en/function.array-merge-recursive.php
361  if (!is_array($array1) || !is_array($array2)) {
362  return false;
363  }
364  $newarray = $array1;
365  foreach ($array2 as $key => $val) {
366  if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
367  $newarray[$key] = getid3_lib::array_merge_clobber($newarray[$key], $val);
368  } else {
369  $newarray[$key] = $val;
370  }
371  }
372  return $newarray;
373  }
array_merge_clobber($array1, $array2)
Definition: getid3.lib.php:358
+ Here is the caller graph for this function:

◆ array_merge_clobber() [2/2]

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  }

◆ array_merge_noclobber() [1/2]

getid3_lib::array_merge_noclobber (   $array1,
  $array2 
)

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

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

376  {
377  if (!is_array($array1) || !is_array($array2)) {
378  return false;
379  }
380  $newarray = $array1;
381  foreach ($array2 as $key => $val) {
382  if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
383  $newarray[$key] = getid3_lib::array_merge_noclobber($newarray[$key], $val);
384  } elseif (!isset($newarray[$key])) {
385  $newarray[$key] = $val;
386  }
387  }
388  return $newarray;
389  }
array_merge_noclobber($array1, $array2)
Definition: getid3.lib.php:376
+ Here is the caller graph for this function:

◆ array_merge_noclobber() [2/2]

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  }

◆ array_min() [1/2]

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

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

497  {
498  $minvalue = false;
499  $minkey = false;
500  foreach ($arraydata as $key => $value) {
501  if (!is_array($value)) {
502  if ($value > $minvalue) {
503  $minvalue = $value;
504  $minkey = $key;
505  }
506  }
507  }
508  return ($returnkey ? $minkey : $minvalue);
509  }

◆ array_min() [2/2]

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  }

◆ BigEndian2Bin() [1/2]

getid3_lib::BigEndian2Bin (   $byteword)

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

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

271  {
272  $binvalue = '';
273  $bytewordlen = strlen($byteword);
274  for ($i = 0; $i < $bytewordlen; $i++) {
275  $binvalue .= str_pad(decbin(ord($byteword{$i})), 8, '0', STR_PAD_LEFT);
276  }
277  return $binvalue;
278  }
+ Here is the caller graph for this function:

◆ BigEndian2Bin() [2/2]

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  }

◆ BigEndian2Float() [1/2]

getid3_lib::BigEndian2Float (   $byteword)

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

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

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

159  {
160  // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
161  // http://www.psc.edu/general/software/packages/ieee/ieee.html
162  // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
163 
164  $bitword = getid3_lib::BigEndian2Bin($byteword);
165  $signbit = $bitword{0};
166 
167  switch (strlen($byteword) * 8) {
168  case 32:
169  $exponentbits = 8;
170  $fractionbits = 23;
171  break;
172 
173  case 64:
174  $exponentbits = 11;
175  $fractionbits = 52;
176  break;
177 
178  case 80:
179  // 80-bit Apple SANE format
180  // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
181  $exponentstring = substr($bitword, 1, 15);
182  $isnormalized = intval($bitword{16});
183  $fractionstring = substr($bitword, 17, 63);
184  $exponent = pow(2, getid3_lib::Bin2Dec($exponentstring) - 16383);
185  $fraction = $isnormalized + getid3_lib::DecimalBinary2Float($fractionstring);
186  $floatvalue = $exponent * $fraction;
187  if ($signbit == '1') {
188  $floatvalue *= -1;
189  }
190  return $floatvalue;
191  break;
192 
193  default:
194  return false;
195  break;
196  }
197  $exponentstring = substr($bitword, 1, $exponentbits);
198  $fractionstring = substr($bitword, $exponentbits + 1, $fractionbits);
199  $exponent = getid3_lib::Bin2Dec($exponentstring);
200  $fraction = getid3_lib::Bin2Dec($fractionstring);
201 
202  if (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction != 0)) {
203  // Not a Number
204  $floatvalue = false;
205  } elseif (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction == 0)) {
206  if ($signbit == '1') {
207  $floatvalue = '-infinity';
208  } else {
209  $floatvalue = '+infinity';
210  }
211  } elseif (($exponent == 0) && ($fraction == 0)) {
212  if ($signbit == '1') {
213  $floatvalue = -0;
214  } else {
215  $floatvalue = 0;
216  }
217  $floatvalue = ($signbit ? 0 : -0);
218  } elseif (($exponent == 0) && ($fraction != 0)) {
219  // These are 'unnormalized' values
220  $floatvalue = pow(2, (-1 * (pow(2, $exponentbits - 1) - 2))) * getid3_lib::DecimalBinary2Float($fractionstring);
221  if ($signbit == '1') {
222  $floatvalue *= -1;
223  }
224  } elseif ($exponent != 0) {
225  $floatvalue = pow(2, ($exponent - (pow(2, $exponentbits - 1) - 1))) * (1 + getid3_lib::DecimalBinary2Float($fractionstring));
226  if ($signbit == '1') {
227  $floatvalue *= -1;
228  }
229  }
230  return (float) $floatvalue;
231  }
Bin2Dec($binstring, $signed=false)
Definition: getid3.lib.php:316
DecimalBinary2Float($binarynumerator)
Definition: getid3.lib.php:76
BigEndian2Bin($byteword)
Definition: getid3.lib.php:271
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BigEndian2Float() [2/2]

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  }

◆ BigEndian2Int() [1/2]

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

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

References CastAsInt().

Referenced by getid3_vqf\Analyze(), getid3_au\Analyze(), getid3_avr\Analyze(), getid3_ts\Analyze(), getid3_aa\Analyze(), getid3_szip\Analyze(), getid3_png\Analyze(), getid3_lpac\Analyze(), getid3_ogg\Analyze(), getid3_real\Analyze(), getid3_swf\Analyze(), getid3_id3v2\Analyze(), getid3_midi\Analyze(), getid3_quicktime\Analyze(), getid3_riff\Analyze(), getid3_flv\Analyze(), getID3\analyze(), getid3_mp3\decodeMPEGaudioHeader(), getid3_matroska\EBML2Int(), getid3_riff\EitherEndian2Int(), FixedPoint16_16(), FixedPoint8_8(), getid3_flac\FLACparseAPPLICATION(), getid3_flac\FLACparseCUESHEET(), getid3_flac\FLACparseMETAdata(), getid3_flac\FLACparseSEEKTABLE(), getid3_flac\FLACparseSTREAMINFO(), getid3_aac\getAACADTSheaderFilepointer(), AVCSequenceParameterSetReader\getBit(), getid3_au\getid3_au(), getid3_avr\getid3_avr(), getid3_flv\getid3_flv(), getid3_id3v2\getid3_id3v2(), getid3_lpac\getid3_lpac(), getid3_midi\getid3_midi(), getid3_mpeg\getid3_mpeg(), getid3_png\getid3_png(), getid3_quicktime\getid3_quicktime(), getid3_real\getid3_real(), getid3_riff\getid3_riff(), getid3_swf\getid3_swf(), getid3_szip\getid3_szip(), getid3_vqf\getid3_vqf(), 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().

234  {
235  $intvalue = 0;
236  $bytewordlen = strlen($byteword);
237  for ($i = 0; $i < $bytewordlen; $i++) {
238  if ($synchsafe) { // disregard MSB, effectively 7-bit bytes
239  $intvalue = $intvalue | (ord($byteword{$i}) & 0x7F) << (($bytewordlen - 1 - $i) * 7);
240  } else {
241  $intvalue += ord($byteword{$i}) * pow(256, ($bytewordlen - 1 - $i));
242  }
243  }
244  if ($signed && !$synchsafe) {
245  // synchsafe ints are not allowed to be signed
246  switch ($bytewordlen) {
247  case 1:
248  case 2:
249  case 3:
250  case 4:
251  $signmaskbit = 0x80 << (8 * ($bytewordlen - 1));
252  if ($intvalue & $signmaskbit) {
253  $intvalue = 0 - ($intvalue & ($signmaskbit - 1));
254  }
255  break;
256 
257  default:
258  die('ERROR: Cannot have signed integers larger than 32-bits in getid3_lib::BigEndian2Int()');
259  break;
260  }
261  }
262  return getid3_lib::CastAsInt($intvalue);
263  }
CastAsInt($floatnum)
Definition: getid3.lib.php:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BigEndian2Int() [2/2]

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  }

◆ BigEndian2String() [1/2]

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

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

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

281  {
282  if ($number < 0) {
283  return false;
284  }
285  $maskbyte = (($synchsafe || $signed) ? 0x7F : 0xFF);
286  $intstring = '';
287  if ($signed) {
288  if ($minbytes > 4) {
289  die('ERROR: Cannot have signed integers larger than 32-bits in getid3_lib::BigEndian2String()');
290  }
291  $number = $number & (0x80 << (8 * ($minbytes - 1)));
292  }
293  while ($number != 0) {
294  $quotient = ($number / ($maskbyte + 1));
295  $intstring = chr(ceil(($quotient - floor($quotient)) * $maskbyte)).$intstring;
296  $number = floor($quotient);
297  }
298  return str_pad($intstring, $minbytes, "\x00", STR_PAD_LEFT);
299  }
+ Here is the caller graph for this function:

◆ BigEndian2String() [2/2]

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  }

◆ Bin2Dec() [1/2]

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

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

References CastAsInt().

Referenced by getid3_swf\Analyze(), getid3_riff\Analyze(), BigEndian2Float(), Bin2String(), DecimalBinary2Float(), FixedPoint2_30(), getid3_flac\FLACparseSTREAMINFO(), Float2String(), getid3_aac\getAACADIFheaderFilepointer(), getid3_aac\getAACADTSheaderFilepointer(), getid3_mpeg\getid3_mpeg(), getid3_riff\getid3_riff(), getid3_swf\getid3_swf(), getid3_id3v2\ParseID3v2Frame(), and getid3_flac\parseSTREAMINFO().

316  {
317  $signmult = 1;
318  if ($signed) {
319  if ($binstring{0} == '1') {
320  $signmult = -1;
321  }
322  $binstring = substr($binstring, 1);
323  }
324  $decvalue = 0;
325  for ($i = 0; $i < strlen($binstring); $i++) {
326  $decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
327  }
328  return getid3_lib::CastAsInt($decvalue * $signmult);
329  }
CastAsInt($floatnum)
Definition: getid3.lib.php:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Bin2Dec() [2/2]

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  }

◆ Bin2String() [1/2]

getid3_lib::Bin2String (   $binstring)

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

References Bin2Dec().

Referenced by getid3_aac\getAACADIFheaderFilepointer().

332  {
333  // return 'hi' for input of '0110100001101001'
334  $string = '';
335  $binstringreversed = strrev($binstring);
336  for ($i = 0; $i < strlen($binstringreversed); $i += 8) {
337  $string = chr(getid3_lib::Bin2Dec(strrev(substr($binstringreversed, $i, 8)))).$string;
338  }
339  return $string;
340  }
Bin2Dec($binstring, $signed=false)
Definition: getid3.lib.php:316
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Bin2String() [2/2]

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  }

◆ CastAsInt() [1/2]

getid3_lib::CastAsInt (   $floatnum)

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

References trunc().

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

60  {
61  // convert to float if not already
62  $floatnum = (float) $floatnum;
63 
64  // convert a float to type int, only if possible
65  if (getid3_lib::trunc($floatnum) == $floatnum) {
66  // it's not floating point
67  if ($floatnum <= 1073741824) { // 2^30
68  // it's within int range
69  $floatnum = (int) $floatnum;
70  }
71  }
72  return $floatnum;
73  }
trunc($floatnumber)
Definition: getid3.lib.php:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CastAsInt() [2/2]

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  }

◆ CopyFileParts()

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

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

References getID3\FREAD_BUFFER_SIZE.

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:113

◆ CopyTagsToComments() [1/2]

getid3_lib::CopyTagsToComments ( $ThisFileInfo)

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

References MultiByteCharString2HTML().

1204  {
1205 
1206  // Copy all entries from ['tags'] into common ['comments']
1207  if (!empty($ThisFileInfo['tags'])) {
1208  foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
1209  foreach ($tagarray as $tagname => $tagdata) {
1210  foreach ($tagdata as $key => $value) {
1211  if (!empty($value)) {
1212  if (empty($ThisFileInfo['comments'][$tagname])) {
1213 
1214  // fall through and append value
1215 
1216  } elseif ($tagtype == 'id3v1') {
1217 
1218  $newvaluelength = strlen(trim($value));
1219  foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
1220  $oldvaluelength = strlen(trim($existingvalue));
1221  if (($newvaluelength <= $oldvaluelength) && (substr($existingvalue, 0, $newvaluelength) == trim($value))) {
1222  // new value is identical but shorter-than (or equal-length to) one already in comments - skip
1223  break 2;
1224  }
1225  }
1226 
1227  } else {
1228 
1229  $newvaluelength = strlen(trim($value));
1230  foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
1231  $oldvaluelength = strlen(trim($existingvalue));
1232  if (($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {
1233  $ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
1234  break 2;
1235  }
1236  }
1237 
1238  }
1239  if (empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
1240  $ThisFileInfo['comments'][$tagname][] = trim($value);
1241  }
1242  }
1243  }
1244  }
1245  }
1246 
1247  // Copy to ['comments_html']
1248  foreach ($ThisFileInfo['comments'] as $field => $values) {
1249  foreach ($values as $index => $value) {
1250  $ThisFileInfo['comments_html'][$field][$index] = str_replace('&#0;', '', getid3_lib::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
1251  }
1252  }
1253  }
1254  }
MultiByteCharString2HTML($string, $charset='ISO-8859-1')
+ Here is the call graph for this function:

◆ CopyTagsToComments() [2/2]

static getid3_lib::CopyTagsToComments ( $ThisFileInfo)
static

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

1219  {
1220 
1221  // Copy all entries from ['tags'] into common ['comments']
1222  if (!empty($ThisFileInfo['tags'])) {
1223  foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
1224  foreach ($tagarray as $tagname => $tagdata) {
1225  foreach ($tagdata as $key => $value) {
1226  if (!empty($value)) {
1227  if (empty($ThisFileInfo['comments'][$tagname])) {
1228 
1229  // fall through and append value
1230 
1231  } elseif ($tagtype == 'id3v1') {
1232 
1233  $newvaluelength = strlen(trim($value));
1234  foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
1235  $oldvaluelength = strlen(trim($existingvalue));
1236  if (($newvaluelength <= $oldvaluelength) && (substr($existingvalue, 0, $newvaluelength) == trim($value))) {
1237  // new value is identical but shorter-than (or equal-length to) one already in comments - skip
1238  break 2;
1239  }
1240  }
1241 
1242  } elseif (!is_array($value)) {
1243 
1244  $newvaluelength = strlen(trim($value));
1245  foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
1246  $oldvaluelength = strlen(trim($existingvalue));
1247  if ((strlen($existingvalue) > 10) && ($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {
1248  $ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
1249  //break 2;
1250  break;
1251  }
1252  }
1253 
1254  }
1255  if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
1256  $value = (is_string($value) ? trim($value) : $value);
1257  if (!is_numeric($key)) {
1258  $ThisFileInfo['comments'][$tagname][$key] = $value;
1259  } else {
1260  $ThisFileInfo['comments'][$tagname][] = $value;
1261  }
1262  }
1263  }
1264  }
1265  }
1266  }
1267 
1268  // Copy to ['comments_html']
1269  if (!empty($ThisFileInfo['comments'])) {
1270  foreach ($ThisFileInfo['comments'] as $field => $values) {
1271  if ($field == 'picture') {
1272  // pictures can take up a lot of space, and we don't need multiple copies of them
1273  // let there be a single copy in [comments][picture], and not elsewhere
1274  continue;
1275  }
1276  foreach ($values as $index => $value) {
1277  if (is_array($value)) {
1278  $ThisFileInfo['comments_html'][$field][$index] = $value;
1279  } else {
1280  $ThisFileInfo['comments_html'][$field][$index] = str_replace('&#0;', '', self::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
1281  }
1282  }
1283  }
1284  }
1285 
1286  }
1287  return true;
1288  }

◆ CreateDeepArray() [1/2]

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

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

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

465  {
466  // assigns $Value to a nested array path:
467  // $foo = getid3_lib::CreateDeepArray('/path/to/my', '/', 'file.txt')
468  // is the same as:
469  // $foo = array('path'=>array('to'=>'array('my'=>array('file.txt'))));
470  // or
471  // $foo['path']['to']['my'] = 'file.txt';
472  while ($ArrayPath && ($ArrayPath{0} == $Separator)) {
473  $ArrayPath = substr($ArrayPath, 1);
474  }
475  if (($pos = strpos($ArrayPath, $Separator)) !== false) {
476  $ReturnedArray[substr($ArrayPath, 0, $pos)] = getid3_lib::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
477  } else {
478  $ReturnedArray[$ArrayPath] = $Value;
479  }
480  return $ReturnedArray;
481  }
CreateDeepArray($ArrayPath, $Separator, $Value)
Definition: getid3.lib.php:465
+ Here is the caller graph for this function:

◆ CreateDeepArray() [2/2]

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  }

◆ DateMac2Unix() [1/2]

getid3_lib::DateMac2Unix (   $macdate)

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

References CastAsInt().

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

442  {
443  // Macintosh timestamp: seconds since 00:00h January 1, 1904
444  // UNIX timestamp: seconds since 00:00h January 1, 1970
445  return getid3_lib::CastAsInt($macdate - 2082844800);
446  }
CastAsInt($floatnum)
Definition: getid3.lib.php:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DateMac2Unix() [2/2]

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  }

◆ Dec2Bin() [1/2]

getid3_lib::Dec2Bin (   $number)

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

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

302  {
303  while ($number >= 256) {
304  $bytes[] = (($number / 256) - (floor($number / 256))) * 256;
305  $number = floor($number / 256);
306  }
307  $bytes[] = $number;
308  $binstring = '';
309  for ($i = 0; $i < count($bytes); $i++) {
310  $binstring = (($i == count($bytes) - 1) ? decbin($bytes[$i]) : str_pad(decbin($bytes[$i]), 8, '0', STR_PAD_LEFT)).$binstring;
311  }
312  return $binstring;
313  }
+ Here is the caller graph for this function:

◆ Dec2Bin() [2/2]

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  }

◆ DecimalBinary2Float() [1/2]

getid3_lib::DecimalBinary2Float (   $binarynumerator)

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

References Bin2Dec().

Referenced by BigEndian2Float().

76  {
77  $numerator = getid3_lib::Bin2Dec($binarynumerator);
78  $denominator = getid3_lib::Bin2Dec('1'.str_repeat('0', strlen($binarynumerator)));
79  return ($numerator / $denominator);
80  }
Bin2Dec($binstring, $signed=false)
Definition: getid3.lib.php:316
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DecimalBinary2Float() [2/2]

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  }

◆ DecimalizeFraction()

static getid3_lib::DecimalizeFraction (   $fraction)
static

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

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

96  {
97  list($numerator, $denominator) = explode('/', $fraction);
98  return $numerator / ($denominator ? $denominator : 1);
99  }
+ Here is the caller graph for this function:

◆ EmbeddedLookup() [1/2]

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

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

References $file.

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\RIFFfourccLookup(), getid3_riff\RIFFwFormatTagLookup(), getid3_riff\waveSNDMtagLookup(), and getid3_riff\wFormatTagLookup().

1257  {
1258 
1259  // Cached
1260  static $cache;
1261  if (isset($cache[$file][$name])) {
1262  return @$cache[$file][$name][$key];
1263  }
1264 
1265  // Init
1266  $keylength = strlen($key);
1267  $line_count = $end - $begin - 7;
1268 
1269  // Open php file
1270  $fp = fopen($file, 'r');
1271 
1272  // Discard $begin lines
1273  for ($i = 0; $i < ($begin + 3); $i++) {
1274  fgets($fp, 1024);
1275  }
1276 
1277  // Loop thru line
1278  while (0 < $line_count--) {
1279 
1280  // Read line
1281  $line = ltrim(fgets($fp, 1024), "\t ");
1282 
1283  // METHOD A: only cache the matching key - less memory but slower on next lookup of not-previously-looked-up key
1284  //$keycheck = substr($line, 0, $keylength);
1285  //if ($key == $keycheck) {
1286  // $cache[$file][$name][$keycheck] = substr($line, $keylength + 1);
1287  // break;
1288  //}
1289 
1290  // METHOD B: cache all keys in this lookup - more memory but faster on next lookup of not-previously-looked-up key
1291  //$cache[$file][$name][substr($line, 0, $keylength)] = trim(substr($line, $keylength + 1));
1292  @list($ThisKey, $ThisValue) = explode("\t", $line, 2);
1293  $cache[$file][$name][$ThisKey] = trim($ThisValue);
1294  }
1295 
1296  // Close and return
1297  fclose($fp);
1298  return @$cache[$file][$name][$key];
1299  }
print $file
+ Here is the caller graph for this function:

◆ EmbeddedLookup() [2/2]

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

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

References $file.

1291  {
1292 
1293  // Cached
1294  static $cache;
1295  if (isset($cache[$file][$name])) {
1296  return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
1297  }
1298 
1299  // Init
1300  $keylength = strlen($key);
1301  $line_count = $end - $begin - 7;
1302 
1303  // Open php file
1304  $fp = fopen($file, 'r');
1305 
1306  // Discard $begin lines
1307  for ($i = 0; $i < ($begin + 3); $i++) {
1308  fgets($fp, 1024);
1309  }
1310 
1311  // Loop thru line
1312  while (0 < $line_count--) {
1313 
1314  // Read line
1315  $line = ltrim(fgets($fp, 1024), "\t ");
1316 
1317  // METHOD A: only cache the matching key - less memory but slower on next lookup of not-previously-looked-up key
1318  //$keycheck = substr($line, 0, $keylength);
1319  //if ($key == $keycheck) {
1320  // $cache[$file][$name][$keycheck] = substr($line, $keylength + 1);
1321  // break;
1322  //}
1323 
1324  // METHOD B: cache all keys in this lookup - more memory but faster on next lookup of not-previously-looked-up key
1325  //$cache[$file][$name][substr($line, 0, $keylength)] = trim(substr($line, $keylength + 1));
1326  $explodedLine = explode("\t", $line, 2);
1327  $ThisKey = (isset($explodedLine[0]) ? $explodedLine[0] : '');
1328  $ThisValue = (isset($explodedLine[1]) ? $explodedLine[1] : '');
1329  $cache[$file][$name][$ThisKey] = trim($ThisValue);
1330  }
1331 
1332  // Close and return
1333  fclose($fp);
1334  return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
1335  }
print $file

◆ fileextension() [1/2]

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

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

References $filename.

Referenced by getid3_optimfrog\ParseOptimFROGheader45().

392  {
393  if (strstr($filename, '.')) {
394  $reversedfilename = strrev($filename);
395  $offset = 0;
396  for ($i = 0; $i < $numextensions; $i++) {
397  $offset = strpos($reversedfilename, '.', $offset + 1);
398  if ($offset === false) {
399  return '';
400  }
401  }
402  return strrev(substr($reversedfilename, 0, $offset));
403  }
404  return '';
405  }
$filename
Definition: buildRTE.php:89
+ Here is the caller graph for this function:

◆ fileextension() [2/2]

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

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

References $filename.

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

◆ FixedPoint16_16() [1/2]

getid3_lib::FixedPoint16_16 (   $rawdata)

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

References BigEndian2Int().

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

454  {
455  return getid3_lib::BigEndian2Int(substr($rawdata, 0, 2)) + (float) (getid3_lib::BigEndian2Int(substr($rawdata, 2, 2)) / pow(2, 16));
456  }
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FixedPoint16_16() [2/2]

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  }

◆ FixedPoint2_30() [1/2]

getid3_lib::FixedPoint2_30 (   $rawdata)

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

References BigEndian2Bin(), and Bin2Dec().

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

459  {
460  $binarystring = getid3_lib::BigEndian2Bin($rawdata);
461  return getid3_lib::Bin2Dec(substr($binarystring, 0, 2)) + (float) (getid3_lib::Bin2Dec(substr($binarystring, 2, 30)) / 1073741824);
462  }
Bin2Dec($binstring, $signed=false)
Definition: getid3.lib.php:316
BigEndian2Bin($byteword)
Definition: getid3.lib.php:271
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FixedPoint2_30() [2/2]

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  }

◆ FixedPoint8_8() [1/2]

getid3_lib::FixedPoint8_8 (   $rawdata)

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

References BigEndian2Int().

Referenced by getid3_quicktime\QuicktimeParseAtom().

449  {
450  return getid3_lib::BigEndian2Int(substr($rawdata, 0, 1)) + (float) (getid3_lib::BigEndian2Int(substr($rawdata, 1, 1)) / pow(2, 8));
451  }
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FixedPoint8_8() [2/2]

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  }

◆ 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  }

◆ Float2BinaryDecimal() [1/2]

getid3_lib::Float2BinaryDecimal (   $floatvalue)

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

References trunc().

Referenced by Float2String().

107  {
108  // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
109  $maxbits = 128; // to how many bits of precision should the calculations be taken?
110  $intpart = getid3_lib::trunc($floatvalue);
111  $floatpart = abs($floatvalue - $intpart);
112  $pointbitstring = '';
113  while (($floatpart != 0) && (strlen($pointbitstring) < $maxbits)) {
114  $floatpart *= 2;
115  $pointbitstring .= (string) getid3_lib::trunc($floatpart);
116  $floatpart -= getid3_lib::trunc($floatpart);
117  }
118  $binarypointnumber = decbin($intpart).'.'.$pointbitstring;
119  return $binarypointnumber;
120  }
trunc($floatnumber)
Definition: getid3.lib.php:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Float2BinaryDecimal() [2/2]

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  }

◆ Float2String() [1/2]

getid3_lib::Float2String (   $floatvalue,
  $bits 
)

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

References BigEndian2String(), Bin2Dec(), Float2BinaryDecimal(), and NormalizeBinaryPoint().

Referenced by getid3_write_id3v2\GenerateID3v2FrameData().

123  {
124  // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee-expl.html
125  switch ($bits) {
126  case 32:
127  $exponentbits = 8;
128  $fractionbits = 23;
129  break;
130 
131  case 64:
132  $exponentbits = 11;
133  $fractionbits = 52;
134  break;
135 
136  default:
137  return false;
138  break;
139  }
140  if ($floatvalue >= 0) {
141  $signbit = '0';
142  } else {
143  $signbit = '1';
144  }
145  $normalizedbinary = getid3_lib::NormalizeBinaryPoint(getid3_lib::Float2BinaryDecimal($floatvalue), $fractionbits);
146  $biasedexponent = pow(2, $exponentbits - 1) - 1 + $normalizedbinary['exponent']; // (127 or 1023) +/- exponent
147  $exponentbitstring = str_pad(decbin($biasedexponent), $exponentbits, '0', STR_PAD_LEFT);
148  $fractionbitstring = str_pad(substr($normalizedbinary['normalized'], 2), $fractionbits, '0', STR_PAD_RIGHT);
149 
150  return getid3_lib::BigEndian2String(getid3_lib::Bin2Dec($signbit.$exponentbitstring.$fractionbitstring), $bits % 8, false);
151  }
NormalizeBinaryPoint($binarypointnumber, $maxbits=52)
Definition: getid3.lib.php:83
Bin2Dec($binstring, $signed=false)
Definition: getid3.lib.php:316
BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:281
Float2BinaryDecimal($floatvalue)
Definition: getid3.lib.php:107
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Float2String() [2/2]

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  }

◆ GetDataImageSize() [1/2]

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

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

1167  {
1168  static $tempdir = '';
1169  if (empty($tempdir)) {
1170  // yes this is ugly, feel free to suggest a better way
1171  require_once(dirname(__FILE__).'/getid3.php');
1172  $getid3_temp = new getID3();
1173  $tempdir = $getid3_temp->tempdir;
1174  unset($getid3_temp);
1175  }
1176  $GetDataImageSize = false;
1177  if ($tempfilename = tempnam($tempdir, 'gI3')) {
1178  if (is_writable($tempfilename) && is_file($tempfilename) && ($tmp = fopen($tempfilename, 'wb'))) {
1179  fwrite($tmp, $imgData);
1180  fclose($tmp);
1181  $GetDataImageSize = @getimagesize($tempfilename, $imageinfo);
1182  if (($GetDataImageSize === false) || !isset($GetDataImageSize[0]) || !isset($GetDataImageSize[1])) {
1183  return false;
1184  }
1185  $GetDataImageSize['height'] = $GetDataImageSize[0];
1186  $GetDataImageSize['width'] = $GetDataImageSize[1];
1187  }
1188  unlink($tempfilename);
1189  }
1190  return $GetDataImageSize;
1191  }

◆ GetDataImageSize() [2/2]

getid3_lib::GetDataImageSize (   $imgData)

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

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

1170  {
1171  $GetDataImageSize = false;
1172  if ($tempfilename = tempnam('*', 'getID3')) {
1173  if ($tmp = @fopen($tempfilename, 'wb')) {
1174  fwrite($tmp, $imgData);
1175  fclose($tmp);
1176  $GetDataImageSize = @GetImageSize($tempfilename);
1177  }
1178  unlink($tempfilename);
1179  }
1180  return $GetDataImageSize;
1181  }
+ Here is the caller graph for this function:

◆ getFileSizeSyscall()

static getid3_lib::getFileSizeSyscall (   $path)
static

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

References $file, and $path.

Referenced by getID3\openfile().

1361  {
1362  $filesize = false;
1363 
1364  if (GETID3_OS_ISWINDOWS) {
1365  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:
1366  $filesystem = new COM('Scripting.FileSystemObject');
1367  $file = $filesystem->GetFile($path);
1368  $filesize = $file->Size();
1369  unset($filesystem, $file);
1370  } else {
1371  $commandline = 'for %I in ('.escapeshellarg($path).') do @echo %~zI';
1372  }
1373  } else {
1374  $commandline = 'ls -l '.escapeshellarg($path).' | awk \'{print $5}\'';
1375  }
1376  if (isset($commandline)) {
1377  $output = trim(`$commandline`);
1378  if (ctype_digit($output)) {
1379  $filesize = (float) $output;
1380  }
1381  }
1382  return $filesize;
1383  }
print $file
$path
Definition: index.php:22
+ Here is the caller graph for this function:

◆ hash_data() [1/2]

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

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

References $file, $result, and $size.

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  }
print $file
$size
Definition: RandomTest.php:79
$result

◆ hash_data() [2/2]

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

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

References $file, $result, $size, and GETID3_FREAD_BUFFER_SIZE.

Referenced by getID3\getHashdata().

582  {
583 
584  switch ($algorithm) {
585  case 'md5':
586  $hash_function = 'md5_file';
587  $unix_call = 'md5sum';
588  $windows_call = 'md5sum.exe';
589  $hash_length = 32;
590  break;
591 
592  case 'sha1':
593  $hash_function = 'sha1_file';
594  $unix_call = 'sha1sum';
595  $windows_call = 'sha1sum.exe';
596  $hash_length = 40;
597  break;
598 
599  default:
600  die('Invalid algorithm ('.$algorithm.') in getid3_lib::hash_data()');
601  break;
602  }
603  $size = $end - $offset;
604  while (true) {
605  if (GETID3_OS_ISWINDOWS) {
606 
607  // It seems that sha1sum.exe for Windows only works on physical files, does not accept piped data
608  // Fall back to create-temp-file method:
609  if ($algorithm == 'sha1') {
610  break;
611  }
612 
613  $RequiredFiles = array('cygwin1.dll', 'head.exe', 'tail.exe', $windows_call);
614  foreach ($RequiredFiles as $required_file) {
615  if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
616  // helper apps not available - fall back to old method
617  break;
618  }
619  }
620  $commandline = GETID3_HELPERAPPSDIR.'head.exe -c '.$end.' "'.escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $file)).'" | ';
621  $commandline .= GETID3_HELPERAPPSDIR.'tail.exe -c '.$size.' | ';
622  $commandline .= GETID3_HELPERAPPSDIR.$windows_call;
623 
624  } else {
625 
626  $commandline = 'head -c'.$end.' '.escapeshellarg($file).' | ';
627  $commandline .= 'tail -c'.$size.' | ';
628  $commandline .= $unix_call;
629 
630  }
631  if ((bool) ini_get('safe_mode')) {
632  $ThisFileInfo['warning'][] = 'PHP running in Safe Mode - backtick operator not available, using slower non-system-call '.$algorithm.' algorithm';
633  break;
634  }
635  return substr(`$commandline`, 0, $hash_length);
636  }
637 
638  // try to create a temporary file in the system temp directory - invalid dirname should force to system temp dir
639  if (($data_filename = tempnam('*', 'getID3')) === false) {
640  // can't find anywhere to create a temp file, just die
641  return false;
642  }
643 
644  // Init
645  $result = false;
646 
647  // copy parts of file
648  if ($fp = @fopen($file, 'rb')) {
649 
650  if ($fp_data = @fopen($data_filename, 'wb')) {
651 
652  fseek($fp, $offset, SEEK_SET);
653  $byteslefttowrite = $end - $offset;
654  while (($byteslefttowrite > 0) && ($buffer = fread($fp, GETID3_FREAD_BUFFER_SIZE))) {
655  $byteswritten = fwrite($fp_data, $buffer, $byteslefttowrite);
656  $byteslefttowrite -= $byteswritten;
657  }
658  fclose($fp_data);
659  $result = getid3_lib::$hash_function($data_filename);
660 
661  }
662  fclose($fp);
663  }
664  unlink($data_filename);
665  return $result;
666  }
const GETID3_FREAD_BUFFER_SIZE
Definition: getid3.php:14
print $file
$size
Definition: RandomTest.php:79
$result
+ Here is the caller graph for this function:

◆ iconv_fallback() [1/2]

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

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

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().

951  {
952 
953  if ($in_charset == $out_charset) {
954  return $string;
955  }
956 
957  static $iconv_broken_or_unavailable = array();
958  if (is_null(@$iconv_broken_or_unavailable[$in_charset.'_'.$out_charset])) {
959  $GETID3_ICONV_TEST_STRING = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ';
960 
961  // Check iconv()
962  if (function_exists('iconv')) {
963  if (@iconv($in_charset, 'ISO-8859-1', @iconv('ISO-8859-1', $in_charset, $GETID3_ICONV_TEST_STRING)) == $GETID3_ICONV_TEST_STRING) {
964  if (@iconv($out_charset, 'ISO-8859-1', @iconv('ISO-8859-1', $out_charset, $GETID3_ICONV_TEST_STRING)) == $GETID3_ICONV_TEST_STRING) {
965  // everything works, use iconv()
966  $iconv_broken_or_unavailable[$in_charset.'_'.$out_charset] = false;
967  } else {
968  // iconv() available, but broken. Use getID3()'s iconv_fallback() conversions instead
969  // known issue in PHP v4.1.x
970  $iconv_broken_or_unavailable[$in_charset.'_'.$out_charset] = true;
971  }
972  } else {
973  // iconv() available, but broken. Use getID3()'s iconv_fallback() conversions instead
974  // known issue in PHP v4.1.x
975  $iconv_broken_or_unavailable[$in_charset.'_'.$out_charset] = true;
976  }
977  } else {
978  // iconv() unavailable, use getID3()'s iconv_fallback() conversions
979  $iconv_broken_or_unavailable[$in_charset.'_'.$out_charset] = true;
980  }
981  }
982 
983  if ($iconv_broken_or_unavailable[$in_charset.'_'.$out_charset]) {
984  static $ConversionFunctionList = array();
985  if (empty($ConversionFunctionList)) {
986  $ConversionFunctionList['ISO-8859-1']['UTF-8'] = 'iconv_fallback_iso88591_utf8';
987  $ConversionFunctionList['ISO-8859-1']['UTF-16'] = 'iconv_fallback_iso88591_utf16';
988  $ConversionFunctionList['ISO-8859-1']['UTF-16BE'] = 'iconv_fallback_iso88591_utf16be';
989  $ConversionFunctionList['ISO-8859-1']['UTF-16LE'] = 'iconv_fallback_iso88591_utf16le';
990  $ConversionFunctionList['UTF-8']['ISO-8859-1'] = 'iconv_fallback_utf8_iso88591';
991  $ConversionFunctionList['UTF-8']['UTF-16'] = 'iconv_fallback_utf8_utf16';
992  $ConversionFunctionList['UTF-8']['UTF-16BE'] = 'iconv_fallback_utf8_utf16be';
993  $ConversionFunctionList['UTF-8']['UTF-16LE'] = 'iconv_fallback_utf8_utf16le';
994  $ConversionFunctionList['UTF-16']['ISO-8859-1'] = 'iconv_fallback_utf16_iso88591';
995  $ConversionFunctionList['UTF-16']['UTF-8'] = 'iconv_fallback_utf16_utf8';
996  $ConversionFunctionList['UTF-16LE']['ISO-8859-1'] = 'iconv_fallback_utf16le_iso88591';
997  $ConversionFunctionList['UTF-16LE']['UTF-8'] = 'iconv_fallback_utf16le_utf8';
998  $ConversionFunctionList['UTF-16BE']['ISO-8859-1'] = 'iconv_fallback_utf16be_iso88591';
999  $ConversionFunctionList['UTF-16BE']['UTF-8'] = 'iconv_fallback_utf16be_utf8';
1000  }
1001  if (isset($ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)])) {
1002  $ConversionFunction = $ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)];
1003  return getid3_lib::$ConversionFunction($string);
1004  }
1005  die('PHP does not have iconv() support - cannot convert from '.$in_charset.' to '.$out_charset);
1006  }
1007 
1008  if ($converted_string = @iconv($in_charset, $out_charset.'//TRANSLIT', $string)) {
1009  switch ($out_charset) {
1010  case 'ISO-8859-1':
1011  $converted_string = rtrim($converted_string, "\x00");
1012  break;
1013  }
1014  return $converted_string;
1015  }
1016 
1017  // iconv() may sometimes fail with "illegal character in input string" error message
1018  // and return an empty string, but returning the unconverted string is more useful
1019  return $string;
1020  }
+ Here is the caller graph for this function:

◆ iconv_fallback() [2/2]

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  // iconv() availble
964  if (function_exists('iconv')) {
965  if ($converted_string = @iconv($in_charset, $out_charset.'//TRANSLIT', $string)) {
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 
974  // iconv() may sometimes fail with "illegal character in input string" error message
975  // and return an empty string, but returning the unconverted string is more useful
976  return $string;
977  }
978 
979 
980  // iconv() not available
981  static $ConversionFunctionList = array();
982  if (empty($ConversionFunctionList)) {
983  $ConversionFunctionList['ISO-8859-1']['UTF-8'] = 'iconv_fallback_iso88591_utf8';
984  $ConversionFunctionList['ISO-8859-1']['UTF-16'] = 'iconv_fallback_iso88591_utf16';
985  $ConversionFunctionList['ISO-8859-1']['UTF-16BE'] = 'iconv_fallback_iso88591_utf16be';
986  $ConversionFunctionList['ISO-8859-1']['UTF-16LE'] = 'iconv_fallback_iso88591_utf16le';
987  $ConversionFunctionList['UTF-8']['ISO-8859-1'] = 'iconv_fallback_utf8_iso88591';
988  $ConversionFunctionList['UTF-8']['UTF-16'] = 'iconv_fallback_utf8_utf16';
989  $ConversionFunctionList['UTF-8']['UTF-16BE'] = 'iconv_fallback_utf8_utf16be';
990  $ConversionFunctionList['UTF-8']['UTF-16LE'] = 'iconv_fallback_utf8_utf16le';
991  $ConversionFunctionList['UTF-16']['ISO-8859-1'] = 'iconv_fallback_utf16_iso88591';
992  $ConversionFunctionList['UTF-16']['UTF-8'] = 'iconv_fallback_utf16_utf8';
993  $ConversionFunctionList['UTF-16LE']['ISO-8859-1'] = 'iconv_fallback_utf16le_iso88591';
994  $ConversionFunctionList['UTF-16LE']['UTF-8'] = 'iconv_fallback_utf16le_utf8';
995  $ConversionFunctionList['UTF-16BE']['ISO-8859-1'] = 'iconv_fallback_utf16be_iso88591';
996  $ConversionFunctionList['UTF-16BE']['UTF-8'] = 'iconv_fallback_utf16be_utf8';
997  }
998  if (isset($ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)])) {
999  $ConversionFunction = $ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)];
1000  return self::$ConversionFunction($string);
1001  }
1002  throw new Exception('PHP does not have iconv() support - cannot convert from '.$in_charset.' to '.$out_charset);
1003  }

◆ iconv_fallback_int_utf8() [1/2]

getid3_lib::iconv_fallback_int_utf8 (   $charval)

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

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

669  {
670  if ($charval < 128) {
671  // 0bbbbbbb
672  $newcharstring = chr($charval);
673  } elseif ($charval < 2048) {
674  // 110bbbbb 10bbbbbb
675  $newcharstring = chr(($charval >> 6) | 0xC0);
676  $newcharstring .= chr(($charval & 0x3F) | 0x80);
677  } elseif ($charval < 65536) {
678  // 1110bbbb 10bbbbbb 10bbbbbb
679  $newcharstring = chr(($charval >> 12) | 0xE0);
680  $newcharstring .= chr(($charval >> 6) | 0xC0);
681  $newcharstring .= chr(($charval & 0x3F) | 0x80);
682  } else {
683  // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
684  $newcharstring = chr(($charval >> 18) | 0xF0);
685  $newcharstring .= chr(($charval >> 12) | 0xC0);
686  $newcharstring .= chr(($charval >> 6) | 0xC0);
687  $newcharstring .= chr(($charval & 0x3F) | 0x80);
688  }
689  return $newcharstring;
690  }
+ Here is the caller graph for this function:

◆ iconv_fallback_int_utf8() [2/2]

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  }

◆ iconv_fallback_iso88591_utf16() [1/2]

getid3_lib::iconv_fallback_iso88591_utf16 (   $string)

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

References iconv_fallback_iso88591_utf16le().

734  {
735  return getid3_lib::iconv_fallback_iso88591_utf16le($string, true);
736  }
iconv_fallback_iso88591_utf16le($string, $bom=false)
Definition: getid3.lib.php:722
+ Here is the call graph for this function:

◆ iconv_fallback_iso88591_utf16() [2/2]

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  }

◆ iconv_fallback_iso88591_utf16be() [1/2]

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

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

710  {
711  $newcharstring = '';
712  if ($bom) {
713  $newcharstring .= "\xFE\xFF";
714  }
715  for ($i = 0; $i < strlen($string); $i++) {
716  $newcharstring .= "\x00".$string{$i};
717  }
718  return $newcharstring;
719  }

◆ iconv_fallback_iso88591_utf16be() [2/2]

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  }

◆ iconv_fallback_iso88591_utf16le() [1/2]

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

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

Referenced by iconv_fallback_iso88591_utf16().

722  {
723  $newcharstring = '';
724  if ($bom) {
725  $newcharstring .= "\xFF\xFE";
726  }
727  for ($i = 0; $i < strlen($string); $i++) {
728  $newcharstring .= $string{$i}."\x00";
729  }
730  return $newcharstring;
731  }
+ Here is the caller graph for this function:

◆ iconv_fallback_iso88591_utf16le() [2/2]

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  }

◆ iconv_fallback_iso88591_utf8() [1/2]

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

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

References iconv_fallback_int_utf8().

Referenced by getid3_id3v2\ParseID3v2Frame().

693  {
694  if (function_exists('utf8_encode')) {
695  return utf8_encode($string);
696  }
697  // utf8_encode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
698  $newcharstring = '';
699  if ($bom) {
700  $newcharstring .= "\xEF\xBB\xBF";
701  }
702  for ($i = 0; $i < strlen($string); $i++) {
703  $charval = ord($string{$i});
704  $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
705  }
706  return $newcharstring;
707  }
iconv_fallback_int_utf8($charval)
Definition: getid3.lib.php:669
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iconv_fallback_iso88591_utf8() [2/2]

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  }

◆ iconv_fallback_utf16_iso88591() [1/2]

getid3_lib::iconv_fallback_utf16_iso88591 (   $string)

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

References iconv_fallback_utf16be_iso88591(), and iconv_fallback_utf16le_iso88591().

930  {
931  $bom = substr($string, 0, 2);
932  if ($bom == "\xFE\xFF") {
933  return getid3_lib::iconv_fallback_utf16be_iso88591(substr($string, 2));
934  } elseif ($bom == "\xFF\xFE") {
935  return getid3_lib::iconv_fallback_utf16le_iso88591(substr($string, 2));
936  }
937  return $string;
938  }
iconv_fallback_utf16le_iso88591($string)
Definition: getid3.lib.php:916
iconv_fallback_utf16be_iso88591($string)
Definition: getid3.lib.php:902
+ Here is the call graph for this function:

◆ iconv_fallback_utf16_iso88591() [2/2]

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  }

◆ iconv_fallback_utf16_utf8() [1/2]

getid3_lib::iconv_fallback_utf16_utf8 (   $string)

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

References iconv_fallback_utf16be_utf8(), and iconv_fallback_utf16le_utf8().

941  {
942  $bom = substr($string, 0, 2);
943  if ($bom == "\xFE\xFF") {
944  return getid3_lib::iconv_fallback_utf16be_utf8(substr($string, 2));
945  } elseif ($bom == "\xFF\xFE") {
946  return getid3_lib::iconv_fallback_utf16le_utf8(substr($string, 2));
947  }
948  return $string;
949  }
iconv_fallback_utf16le_utf8($string)
Definition: getid3.lib.php:888
iconv_fallback_utf16be_utf8($string)
Definition: getid3.lib.php:874
+ Here is the call graph for this function:

◆ iconv_fallback_utf16_utf8() [2/2]

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  }

◆ iconv_fallback_utf16be_iso88591() [1/2]

getid3_lib::iconv_fallback_utf16be_iso88591 (   $string)

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

References BigEndian2Int().

Referenced by iconv_fallback_utf16_iso88591().

902  {
903  if (substr($string, 0, 2) == "\xFE\xFF") {
904  // strip BOM
905  $string = substr($string, 2);
906  }
907  $newcharstring = '';
908  for ($i = 0; $i < strlen($string); $i += 2) {
909  $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
910  $newcharstring .= (($charval < 256) ? chr($charval) : '?');
911  }
912  return $newcharstring;
913  }
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iconv_fallback_utf16be_iso88591() [2/2]

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  }

◆ iconv_fallback_utf16be_utf8() [1/2]

getid3_lib::iconv_fallback_utf16be_utf8 (   $string)

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

References BigEndian2Int(), and iconv_fallback_int_utf8().

Referenced by iconv_fallback_utf16_utf8().

874  {
875  if (substr($string, 0, 2) == "\xFE\xFF") {
876  // strip BOM
877  $string = substr($string, 2);
878  }
879  $newcharstring = '';
880  for ($i = 0; $i < strlen($string); $i += 2) {
881  $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
882  $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
883  }
884  return $newcharstring;
885  }
iconv_fallback_int_utf8($charval)
Definition: getid3.lib.php:669
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iconv_fallback_utf16be_utf8() [2/2]

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  }

◆ iconv_fallback_utf16le_iso88591() [1/2]

getid3_lib::iconv_fallback_utf16le_iso88591 (   $string)

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

References LittleEndian2Int().

Referenced by iconv_fallback_utf16_iso88591().

916  {
917  if (substr($string, 0, 2) == "\xFF\xFE") {
918  // strip BOM
919  $string = substr($string, 2);
920  }
921  $newcharstring = '';
922  for ($i = 0; $i < strlen($string); $i += 2) {
923  $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
924  $newcharstring .= (($charval < 256) ? chr($charval) : '?');
925  }
926  return $newcharstring;
927  }
LittleEndian2Int($byteword, $signed=false)
Definition: getid3.lib.php:266
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iconv_fallback_utf16le_iso88591() [2/2]

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  }

◆ iconv_fallback_utf16le_utf8() [1/2]

getid3_lib::iconv_fallback_utf16le_utf8 (   $string)

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

References iconv_fallback_int_utf8(), and LittleEndian2Int().

Referenced by iconv_fallback_utf16_utf8().

888  {
889  if (substr($string, 0, 2) == "\xFF\xFE") {
890  // strip BOM
891  $string = substr($string, 2);
892  }
893  $newcharstring = '';
894  for ($i = 0; $i < strlen($string); $i += 2) {
895  $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
896  $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
897  }
898  return $newcharstring;
899  }
LittleEndian2Int($byteword, $signed=false)
Definition: getid3.lib.php:266
iconv_fallback_int_utf8($charval)
Definition: getid3.lib.php:669
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iconv_fallback_utf16le_utf8() [2/2]

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  }

◆ iconv_fallback_utf8_iso88591() [1/2]

getid3_lib::iconv_fallback_utf8_iso88591 (   $string)

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

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

◆ iconv_fallback_utf8_iso88591() [2/2]

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() [1/2]

getid3_lib::iconv_fallback_utf8_utf16 (   $string)

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

References iconv_fallback_utf8_utf16le().

869  {
870  return getid3_lib::iconv_fallback_utf8_utf16le($string, true);
871  }
iconv_fallback_utf8_utf16le($string, $bom=false)
Definition: getid3.lib.php:826
+ Here is the call graph for this function:

◆ iconv_fallback_utf8_utf16() [2/2]

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  }

◆ iconv_fallback_utf8_utf16be() [1/2]

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

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

References BigEndian2String().

783  {
784  $newcharstring = '';
785  if ($bom) {
786  $newcharstring .= "\xFE\xFF";
787  }
788  $offset = 0;
789  $stringlength = strlen($string);
790  while ($offset < $stringlength) {
791  if ((ord($string{$offset}) | 0x07) == 0xF7) {
792  // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
793  $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
794  ((ord($string{($offset + 1)}) & 0x3F) << 12) &
795  ((ord($string{($offset + 2)}) & 0x3F) << 6) &
796  (ord($string{($offset + 3)}) & 0x3F);
797  $offset += 4;
798  } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
799  // 1110bbbb 10bbbbbb 10bbbbbb
800  $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
801  ((ord($string{($offset + 1)}) & 0x3F) << 6) &
802  (ord($string{($offset + 2)}) & 0x3F);
803  $offset += 3;
804  } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
805  // 110bbbbb 10bbbbbb
806  $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
807  (ord($string{($offset + 1)}) & 0x3F);
808  $offset += 2;
809  } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
810  // 0bbbbbbb
811  $charval = ord($string{$offset});
812  $offset += 1;
813  } else {
814  // error? throw some kind of warning here?
815  $charval = false;
816  $offset += 1;
817  }
818  if ($charval !== false) {
819  $newcharstring .= (($charval < 65536) ? getid3_lib::BigEndian2String($charval, 2) : "\x00".'?');
820  }
821  }
822  return $newcharstring;
823  }
BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:281
+ Here is the call graph for this function:

◆ iconv_fallback_utf8_utf16be() [2/2]

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() [1/2]

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

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

References LittleEndian2String().

Referenced by iconv_fallback_utf8_utf16().

826  {
827  $newcharstring = '';
828  if ($bom) {
829  $newcharstring .= "\xFF\xFE";
830  }
831  $offset = 0;
832  $stringlength = strlen($string);
833  while ($offset < $stringlength) {
834  if ((ord($string{$offset}) | 0x07) == 0xF7) {
835  // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
836  $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
837  ((ord($string{($offset + 1)}) & 0x3F) << 12) &
838  ((ord($string{($offset + 2)}) & 0x3F) << 6) &
839  (ord($string{($offset + 3)}) & 0x3F);
840  $offset += 4;
841  } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
842  // 1110bbbb 10bbbbbb 10bbbbbb
843  $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
844  ((ord($string{($offset + 1)}) & 0x3F) << 6) &
845  (ord($string{($offset + 2)}) & 0x3F);
846  $offset += 3;
847  } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
848  // 110bbbbb 10bbbbbb
849  $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
850  (ord($string{($offset + 1)}) & 0x3F);
851  $offset += 2;
852  } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
853  // 0bbbbbbb
854  $charval = ord($string{$offset});
855  $offset += 1;
856  } else {
857  // error? maybe throw some warning here?
858  $charval = false;
859  $offset += 1;
860  }
861  if ($charval !== false) {
862  $newcharstring .= (($charval < 65536) ? getid3_lib::LittleEndian2String($charval, 2) : '?'."\x00");
863  }
864  }
865  return $newcharstring;
866  }
LittleEndian2String($number, $minbytes=1, $synchsafe=false)
Definition: getid3.lib.php:343
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iconv_fallback_utf8_utf16le() [2/2]

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  }

◆ image_type_to_mime_type()

getid3_lib::image_type_to_mime_type (   $imagetypeid)

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

Referenced by getid3_ogg\ParseVorbisCommentsFilepointer().

419  {
420  // only available in PHP v4.3.0+
421  static $image_type_to_mime_type = array();
422  if (empty($image_type_to_mime_type)) {
423  $image_type_to_mime_type[1] = 'image/gif'; // GIF
424  $image_type_to_mime_type[2] = 'image/jpeg'; // JPEG
425  $image_type_to_mime_type[3] = 'image/png'; // PNG
426  $image_type_to_mime_type[4] = 'application/x-shockwave-flash'; // Flash
427  $image_type_to_mime_type[5] = 'image/psd'; // PSD
428  $image_type_to_mime_type[6] = 'image/bmp'; // BMP
429  $image_type_to_mime_type[7] = 'image/tiff'; // TIFF: little-endian (Intel)
430  $image_type_to_mime_type[8] = 'image/tiff'; // TIFF: big-endian (Motorola)
431  //$image_type_to_mime_type[9] = 'image/jpc'; // JPC
432  //$image_type_to_mime_type[10] = 'image/jp2'; // JPC
433  //$image_type_to_mime_type[11] = 'image/jpx'; // JPC
434  //$image_type_to_mime_type[12] = 'image/jb2'; // JPC
435  $image_type_to_mime_type[13] = 'application/x-shockwave-flash'; // Shockwave
436  $image_type_to_mime_type[14] = 'image/iff'; // IFF
437  }
438  return (isset($image_type_to_mime_type[$imagetypeid]) ? $image_type_to_mime_type[$imagetypeid] : 'application/octet-stream');
439  }
+ Here is the caller graph for this function:

◆ ImageExtFromMime()

static getid3_lib::ImageExtFromMime (   $mime_type)
static

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

1193  {
1194  // temporary way, works OK for now, but should be reworked in the future
1195  return str_replace(array('image/', 'x-', 'jpeg'), array('', '', 'jpg'), $mime_type);
1196  }

◆ ImageTypesLookup() [1/2]

getid3_lib::ImageTypesLookup (   $imagetypeid)

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

1183  {
1184  static $ImageTypesLookup = array();
1185  if (empty($ImageTypesLookup)) {
1186  $ImageTypesLookup[1] = 'gif';
1187  $ImageTypesLookup[2] = 'jpeg';
1188  $ImageTypesLookup[3] = 'png';
1189  $ImageTypesLookup[4] = 'swf';
1190  $ImageTypesLookup[5] = 'psd';
1191  $ImageTypesLookup[6] = 'bmp';
1192  $ImageTypesLookup[7] = 'tiff (little-endian)';
1193  $ImageTypesLookup[8] = 'tiff (big-endian)';
1194  $ImageTypesLookup[9] = 'jpc';
1195  $ImageTypesLookup[10] = 'jp2';
1196  $ImageTypesLookup[11] = 'jpx';
1197  $ImageTypesLookup[12] = 'jb2';
1198  $ImageTypesLookup[13] = 'swc';
1199  $ImageTypesLookup[14] = 'iff';
1200  }
1201  return (isset($ImageTypesLookup[$imagetypeid]) ? $ImageTypesLookup[$imagetypeid] : '');
1202  }

◆ ImageTypesLookup() [2/2]

static getid3_lib::ImageTypesLookup (   $imagetypeid)
static

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

1198  {
1199  static $ImageTypesLookup = array();
1200  if (empty($ImageTypesLookup)) {
1201  $ImageTypesLookup[1] = 'gif';
1202  $ImageTypesLookup[2] = 'jpeg';
1203  $ImageTypesLookup[3] = 'png';
1204  $ImageTypesLookup[4] = 'swf';
1205  $ImageTypesLookup[5] = 'psd';
1206  $ImageTypesLookup[6] = 'bmp';
1207  $ImageTypesLookup[7] = 'tiff (little-endian)';
1208  $ImageTypesLookup[8] = 'tiff (big-endian)';
1209  $ImageTypesLookup[9] = 'jpc';
1210  $ImageTypesLookup[10] = 'jp2';
1211  $ImageTypesLookup[11] = 'jpx';
1212  $ImageTypesLookup[12] = 'jb2';
1213  $ImageTypesLookup[13] = 'swc';
1214  $ImageTypesLookup[14] = 'iff';
1215  }
1216  return (isset($ImageTypesLookup[$imagetypeid]) ? $ImageTypesLookup[$imagetypeid] : '');
1217  }

◆ IncludeDependency() [1/2]

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

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

References $filename.

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

1301  {
1302  global $GETID3_ERRORARRAY;
1303 
1304  if (file_exists($filename)) {
1305  if (@include_once($filename)) {
1306  return true;
1307  } else {
1308  $diemessage = basename($sourcefile).' depends on '.$filename.', which has errors';
1309  }
1310  } else {
1311  $diemessage = basename($sourcefile).' depends on '.$filename.', which is missing';
1312  }
1313  if ($DieOnFailure) {
1314  die($diemessage);
1315  } else {
1316  $GETID3_ERRORARRAY[] = $diemessage;
1317  }
1318  return false;
1319  }
$filename
Definition: buildRTE.php:89
+ Here is the caller graph for this function:

◆ IncludeDependency() [2/2]

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

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

References $filename.

1337  {
1338  global $GETID3_ERRORARRAY;
1339 
1340  if (file_exists($filename)) {
1341  if (include_once($filename)) {
1342  return true;
1343  } else {
1344  $diemessage = basename($sourcefile).' depends on '.$filename.', which has errors';
1345  }
1346  } else {
1347  $diemessage = basename($sourcefile).' depends on '.$filename.', which is missing';
1348  }
1349  if ($DieOnFailure) {
1350  throw new Exception($diemessage);
1351  } else {
1352  $GETID3_ERRORARRAY[] = $diemessage;
1353  }
1354  return false;
1355  }
$filename
Definition: buildRTE.php:89

◆ intValueSupported()

static getid3_lib::intValueSupported (   $num)
static

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

Referenced by getid3_bonk\Analyze(), getid3_id3v1\Analyze(), getid3_lyrics3\Analyze(), getid3_zip\Analyze(), getid3_apetag\Analyze(), getid3_ogg\Analyze(), getid3_quicktime\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().

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  }
+ 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  }

◆ LittleEndian2Float() [1/2]

getid3_lib::LittleEndian2Float (   $byteword)

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

References BigEndian2Float().

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

154  {
155  return getid3_lib::BigEndian2Float(strrev($byteword));
156  }
BigEndian2Float($byteword)
Definition: getid3.lib.php:159
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LittleEndian2Float() [2/2]

static getid3_lib::LittleEndian2Float (   $byteword)
static

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

180  {
181  return self::BigEndian2Float(strrev($byteword));
182  }

◆ LittleEndian2Int() [1/2]

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

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

References BigEndian2Int().

Referenced by getid3_bonk\Analyze(), getid3_monkey\Analyze(), getid3_exe\Analyze(), getid3_dss\Analyze(), getid3_efax\Analyze(), getid3_rkau\Analyze(), getid3_shorten\Analyze(), getid3_tta\Analyze(), getid3_voc\Analyze(), getid3_wavpack\Analyze(), getid3_gif\Analyze(), getid3_la\Analyze(), getid3_apetag\Analyze(), getid3_ogg\Analyze(), getid3_swf\Analyze(), getid3_bmp\Analyze(), getid3_ac3\Analyze(), getid3_gzip\Analyze(), getid3_asf\Analyze(), getid3_riff\Analyze(), getid3_flv\Analyze(), getid3_asf\ASF_WMpicture(), getid3_riff\EitherEndian2Int(), getid3_ac3\getid3_ac3(), getid3_apetag\getid3_apetag(), getid3_asf\getid3_asf(), getid3_bmp\getid3_bmp(), getid3_bonk\getid3_bonk(), getid3_exe\getid3_exe(), getid3_gif\getid3_gif(), getid3_gzip\getid3_gzip(), getid3_la\getid3_la(), getid3_monkey\getid3_monkey(), getid3_mpc\getid3_mpc(), getid3_ogg\getid3_ogg(), getid3_riff\getid3_riff(), getid3_rkau\getid3_rkau(), getid3_shorten\getid3_shorten(), getid3_svg\getid3_svg(), getid3_swf\getid3_swf(), getid3_tta\getid3_tta(), getid3_voc\getid3_voc(), getid3_wavpack\getid3_wavpack(), 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\ParseVorbisCommentsFilepointer(), getid3_ogg\ParseVorbisPageHeader(), getid3_riff\parseWavPackHeader(), getid3_riff\RIFFparseWAVEFORMATex(), getid3_riff\RIFFparseWavPackHeader(), getid3_tiff\TIFFendian2Int(), getid3_zip\ZIPparseCentralDirectory(), getid3_zip\ZIPparseEndOfCentralDirectory(), and getid3_zip\ZIPparseLocalFileHeader().

266  {
267  return getid3_lib::BigEndian2Int(strrev($byteword), false, $signed);
268  }
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LittleEndian2Int() [2/2]

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  }

◆ LittleEndian2String() [1/2]

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

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

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

343  {
344  $intstring = '';
345  while ($number > 0) {
346  if ($synchsafe) {
347  $intstring = $intstring.chr($number & 127);
348  $number >>= 7;
349  } else {
350  $intstring = $intstring.chr($number & 255);
351  $number >>= 8;
352  }
353  }
354  return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
355  }
+ Here is the caller graph for this function:

◆ LittleEndian2String() [2/2]

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  }

◆ 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 1392 of file getid3.lib.php.

References $path.

Referenced by getID3\openfile().

1392  {
1393  $splited = preg_split('#/#', rtrim($path, '/ '));
1394  return substr(basename('X'.$splited[count($splited) - 1], $suffix), 1);
1395  }
$path
Definition: index.php:22
+ Here is the caller graph for this function:

◆ md5_file()

getid3_lib::md5_file (   $file)

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

References $file, and $r.

Referenced by getID3\getHashdata().

512  {
513 
514  // md5_file() exists in PHP 4.2.0+.
515  if (function_exists('md5_file')) {
516  return md5_file($file);
517  }
518 
519  if (GETID3_OS_ISWINDOWS) {
520 
521  $RequiredFiles = array('cygwin1.dll', 'md5sum.exe');
522  foreach ($RequiredFiles as $required_file) {
523  if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
524  die(implode(' and ', $RequiredFiles).' are required in '.GETID3_HELPERAPPSDIR.' for getid3_lib::md5_file() to function under Windows in PHP < v4.2.0');
525  }
526  }
527  $commandline = GETID3_HELPERAPPSDIR.'md5sum.exe "'.str_replace('/', DIRECTORY_SEPARATOR, $file).'"';
528  if (ereg("^[\\]?([0-9a-f]{32})", strtolower(`$commandline`), $r)) {
529  return $r[1];
530  }
531 
532  } else {
533 
534  // The following works under UNIX only
535  $file = str_replace('`', '\\`', $file);
536  if (ereg("^([0-9a-f]{32})[ \t\n\r]", `md5sum "$file"`, $r)) {
537  return $r[1];
538  }
539 
540  }
541  return false;
542  }
print $file
$r
Definition: example_031.php:79
md5_file($file)
Definition: getid3.lib.php:512
+ Here is the caller graph for this function:

◆ MultiByteCharString2HTML() [1/2]

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

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

1019  {
1020  $string = (string) $string; // in case trying to pass a numeric (float, int) string, would otherwise return an empty string
1021  $HTMLstring = '';
1022 
1023  switch ($charset) {
1024  case '1251':
1025  case '1252':
1026  case '866':
1027  case '932':
1028  case '936':
1029  case '950':
1030  case 'BIG5':
1031  case 'BIG5-HKSCS':
1032  case 'cp1251':
1033  case 'cp1252':
1034  case 'cp866':
1035  case 'EUC-JP':
1036  case 'EUCJP':
1037  case 'GB2312':
1038  case 'ibm866':
1039  case 'ISO-8859-1':
1040  case 'ISO-8859-15':
1041  case 'ISO8859-1':
1042  case 'ISO8859-15':
1043  case 'KOI8-R':
1044  case 'koi8-ru':
1045  case 'koi8r':
1046  case 'Shift_JIS':
1047  case 'SJIS':
1048  case 'win-1251':
1049  case 'Windows-1251':
1050  case 'Windows-1252':
1051  $HTMLstring = htmlentities($string, ENT_COMPAT, $charset);
1052  break;
1053 
1054  case 'UTF-8':
1055  $strlen = strlen($string);
1056  for ($i = 0; $i < $strlen; $i++) {
1057  $char_ord_val = ord($string{$i});
1058  $charval = 0;
1059  if ($char_ord_val < 0x80) {
1060  $charval = $char_ord_val;
1061  } elseif ((($char_ord_val & 0xF0) >> 4) == 0x0F && $i+3 < $strlen) {
1062  $charval = (($char_ord_val & 0x07) << 18);
1063  $charval += ((ord($string{++$i}) & 0x3F) << 12);
1064  $charval += ((ord($string{++$i}) & 0x3F) << 6);
1065  $charval += (ord($string{++$i}) & 0x3F);
1066  } elseif ((($char_ord_val & 0xE0) >> 5) == 0x07 && $i+2 < $strlen) {
1067  $charval = (($char_ord_val & 0x0F) << 12);
1068  $charval += ((ord($string{++$i}) & 0x3F) << 6);
1069  $charval += (ord($string{++$i}) & 0x3F);
1070  } elseif ((($char_ord_val & 0xC0) >> 6) == 0x03 && $i+1 < $strlen) {
1071  $charval = (($char_ord_val & 0x1F) << 6);
1072  $charval += (ord($string{++$i}) & 0x3F);
1073  }
1074  if (($charval >= 32) && ($charval <= 127)) {
1075  $HTMLstring .= htmlentities(chr($charval));
1076  } else {
1077  $HTMLstring .= '&#'.$charval.';';
1078  }
1079  }
1080  break;
1081 
1082  case 'UTF-16LE':
1083  for ($i = 0; $i < strlen($string); $i += 2) {
1084  $charval = self::LittleEndian2Int(substr($string, $i, 2));
1085  if (($charval >= 32) && ($charval <= 127)) {
1086  $HTMLstring .= chr($charval);
1087  } else {
1088  $HTMLstring .= '&#'.$charval.';';
1089  }
1090  }
1091  break;
1092 
1093  case 'UTF-16BE':
1094  for ($i = 0; $i < strlen($string); $i += 2) {
1095  $charval = self::BigEndian2Int(substr($string, $i, 2));
1096  if (($charval >= 32) && ($charval <= 127)) {
1097  $HTMLstring .= chr($charval);
1098  } else {
1099  $HTMLstring .= '&#'.$charval.';';
1100  }
1101  }
1102  break;
1103 
1104  default:
1105  $HTMLstring = 'ERROR: Character set "'.$charset.'" not supported in MultiByteCharString2HTML()';
1106  break;
1107  }
1108  return $HTMLstring;
1109  }

◆ MultiByteCharString2HTML() [2/2]

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

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

References BigEndian2Int(), and LittleEndian2Int().

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

1023  {
1024  $HTMLstring = '';
1025 
1026  switch ($charset) {
1027  case 'ISO-8859-1':
1028  case 'ISO8859-1':
1029  case 'ISO-8859-15':
1030  case 'ISO8859-15':
1031  case 'cp866':
1032  case 'ibm866':
1033  case '866':
1034  case 'cp1251':
1035  case 'Windows-1251':
1036  case 'win-1251':
1037  case '1251':
1038  case 'cp1252':
1039  case 'Windows-1252':
1040  case '1252':
1041  case 'KOI8-R':
1042  case 'koi8-ru':
1043  case 'koi8r':
1044  case 'BIG5':
1045  case '950':
1046  case 'GB2312':
1047  case '936':
1048  case 'BIG5-HKSCS':
1049  case 'Shift_JIS':
1050  case 'SJIS':
1051  case '932':
1052  case 'EUC-JP':
1053  case 'EUCJP':
1054  $HTMLstring = htmlentities($string, ENT_COMPAT, $charset);
1055  break;
1056 
1057  case 'UTF-8':
1058  $strlen = strlen($string);
1059  for ($i = 0; $i < $strlen; $i++) {
1060  $char_ord_val = ord($string{$i});
1061  $charval = 0;
1062  if ($char_ord_val < 0x80) {
1063  $charval = $char_ord_val;
1064  } elseif ((($char_ord_val & 0xF0) >> 4) == 0x0F) {
1065  $charval = (($char_ord_val & 0x07) << 18);
1066  $charval += ((ord($string{++$i}) & 0x3F) << 12);
1067  $charval += ((ord($string{++$i}) & 0x3F) << 6);
1068  $charval += (ord($string{++$i}) & 0x3F);
1069  } elseif ((($char_ord_val & 0xE0) >> 5) == 0x07) {
1070  $charval = (($char_ord_val & 0x0F) << 12);
1071  $charval += ((ord($string{++$i}) & 0x3F) << 6);
1072  $charval += (ord($string{++$i}) & 0x3F);
1073  } elseif ((($char_ord_val & 0xC0) >> 6) == 0x03) {
1074  $charval = (($char_ord_val & 0x1F) << 6);
1075  $charval += (ord($string{++$i}) & 0x3F);
1076  }
1077  if (($charval >= 32) && ($charval <= 127)) {
1078  $HTMLstring .= chr($charval);
1079  } else {
1080  $HTMLstring .= '&#'.$charval.';';
1081  }
1082  }
1083  break;
1084 
1085  case 'UTF-16LE':
1086  for ($i = 0; $i < strlen($string); $i += 2) {
1087  $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
1088  if (($charval >= 32) && ($charval <= 127)) {
1089  $HTMLstring .= chr($charval);
1090  } else {
1091  $HTMLstring .= '&#'.$charval.';';
1092  }
1093  }
1094  break;
1095 
1096  case 'UTF-16BE':
1097  for ($i = 0; $i < strlen($string); $i += 2) {
1098  $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
1099  if (($charval >= 32) && ($charval <= 127)) {
1100  $HTMLstring .= chr($charval);
1101  } else {
1102  $HTMLstring .= '&#'.$charval.';';
1103  }
1104  }
1105  break;
1106 
1107  default:
1108  $HTMLstring = 'ERROR: Character set "'.$charset.'" not supported in MultiByteCharString2HTML()';
1109  break;
1110  }
1111  return $HTMLstring;
1112  }
LittleEndian2Int($byteword, $signed=false)
Definition: getid3.lib.php:266
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ NormalizeBinaryPoint() [1/2]

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

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

Referenced by Float2String().

83  {
84  // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
85  if (strpos($binarypointnumber, '.') === false) {
86  $binarypointnumber = '0.'.$binarypointnumber;
87  } elseif ($binarypointnumber{0} == '.') {
88  $binarypointnumber = '0'.$binarypointnumber;
89  }
90  $exponent = 0;
91  while (($binarypointnumber{0} != '1') || (substr($binarypointnumber, 1, 1) != '.')) {
92  if (substr($binarypointnumber, 1, 1) == '.') {
93  $exponent--;
94  $binarypointnumber = substr($binarypointnumber, 2, 1).'.'.substr($binarypointnumber, 3);
95  } else {
96  $pointpos = strpos($binarypointnumber, '.');
97  $exponent += ($pointpos - 1);
98  $binarypointnumber = str_replace('.', '', $binarypointnumber);
99  $binarypointnumber = $binarypointnumber{0}.'.'.substr($binarypointnumber, 1);
100  }
101  }
102  $binarypointnumber = str_pad(substr($binarypointnumber, 0, $maxbits + 2), $maxbits + 2, '0', STR_PAD_RIGHT);
103  return array('normalized'=>$binarypointnumber, 'exponent'=>(int) $exponent);
104  }
+ Here is the caller graph for this function:

◆ NormalizeBinaryPoint() [2/2]

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  }

◆ PlaytimeString() [1/2]

getid3_lib::PlaytimeString (   $playtimeseconds)

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

Referenced by getID3\ChannelsBitratePlaytimeCalculations().

408  {
409  $contentseconds = round((($playtimeseconds / 60) - floor($playtimeseconds / 60)) * 60);
410  $contentminutes = floor($playtimeseconds / 60);
411  if ($contentseconds >= 60) {
412  $contentseconds -= 60;
413  $contentminutes++;
414  }
415  return intval($contentminutes).':'.str_pad($contentseconds, 2, 0, STR_PAD_LEFT);
416  }
+ Here is the caller graph for this function:

◆ PlaytimeString() [2/2]

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  }

◆ PrintHexBytes() [1/2]

getid3_lib::PrintHexBytes (   $string,
  $hex = true,
  $spaces = true,
  $htmlsafe = true 
)

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

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

17  {
18  $returnstring = '';
19  for ($i = 0; $i < strlen($string); $i++) {
20  if ($hex) {
21  $returnstring .= str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT);
22  } else {
23  $returnstring .= ' '.(ereg("[\x20-\x7E]", $string{$i}) ? $string{$i} : '¤');
24  }
25  if ($spaces) {
26  $returnstring .= ' ';
27  }
28  }
29  if ($htmlsafe) {
30  $returnstring = htmlentities($returnstring);
31  }
32  return $returnstring;
33  }
+ Here is the caller graph for this function:

◆ PrintHexBytes() [2/2]

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  }

◆ recursiveMultiByteCharString2HTML()

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

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

References $data.

Referenced by getID3\HandleAllTags().

1005  {
1006  if (is_string($data)) {
1007  return self::MultiByteCharString2HTML($data, $charset);
1008  } elseif (is_array($data)) {
1009  $return_data = array();
1010  foreach ($data as $key => $value) {
1011  $return_data[$key] = self::recursiveMultiByteCharString2HTML($value, $charset);
1012  }
1013  return $return_data;
1014  }
1015  // integer, float, objects, resources, etc
1016  return $data;
1017  }
$data
+ Here is the caller graph for this function:

◆ RGADadjustmentLookup() [1/2]

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

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

1138  {
1139  $adjustment = $rawadjustment / 10;
1140  if ($signbit == 1) {
1141  $adjustment *= -1;
1142  }
1143  return (float) $adjustment;
1144  }

◆ RGADadjustmentLookup() [2/2]

getid3_lib::RGADadjustmentLookup (   $rawadjustment,
  $signbit 
)

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

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

1141  {
1142  $adjustment = $rawadjustment / 10;
1143  if ($signbit == 1) {
1144  $adjustment *= -1;
1145  }
1146  return (float) $adjustment;
1147  }
+ Here is the caller graph for this function:

◆ RGADamplitude2dB() [1/2]

static getid3_lib::RGADamplitude2dB (   $amplitude)
static

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

1162  {
1163  return 20 * log10($amplitude);
1164  }

◆ RGADamplitude2dB() [2/2]

getid3_lib::RGADamplitude2dB (   $amplitude)

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

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

1165  {
1166  return 20 * log10($amplitude);
1167  }
+ Here is the caller graph for this function:

◆ RGADgainString() [1/2]

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

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

1147  {
1148  if ($replaygain < 0) {
1149  $signbit = '1';
1150  } else {
1151  $signbit = '0';
1152  }
1153  $storedreplaygain = intval(round($replaygain * 10));
1154  $gainstring = str_pad(decbin($namecode), 3, '0', STR_PAD_LEFT);
1155  $gainstring .= str_pad(decbin($originatorcode), 3, '0', STR_PAD_LEFT);
1156  $gainstring .= $signbit;
1157  $gainstring .= str_pad(decbin($storedreplaygain), 9, '0', STR_PAD_LEFT);
1158 
1159  return $gainstring;
1160  }

◆ RGADgainString() [2/2]

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

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

Referenced by getid3_write_id3v2\GenerateID3v2FrameData().

1150  {
1151  if ($replaygain < 0) {
1152  $signbit = '1';
1153  } else {
1154  $signbit = '0';
1155  }
1156  $storedreplaygain = intval(round($replaygain * 10));
1157  $gainstring = str_pad(decbin($namecode), 3, '0', STR_PAD_LEFT);
1158  $gainstring .= str_pad(decbin($originatorcode), 3, '0', STR_PAD_LEFT);
1159  $gainstring .= $signbit;
1160  $gainstring .= str_pad(decbin($storedreplaygain), 9, '0', STR_PAD_LEFT);
1161 
1162  return $gainstring;
1163  }
+ Here is the caller graph for this function:

◆ RGADnameLookup() [1/2]

static getid3_lib::RGADnameLookup (   $namecode)
static

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

1113  {
1114  static $RGADname = array();
1115  if (empty($RGADname)) {
1116  $RGADname[0] = 'not set';
1117  $RGADname[1] = 'Track Gain Adjustment';
1118  $RGADname[2] = 'Album Gain Adjustment';
1119  }
1120 
1121  return (isset($RGADname[$namecode]) ? $RGADname[$namecode] : '');
1122  }

◆ RGADnameLookup() [2/2]

getid3_lib::RGADnameLookup (   $namecode)

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

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

1116  {
1117  static $RGADname = array();
1118  if (empty($RGADname)) {
1119  $RGADname[0] = 'not set';
1120  $RGADname[1] = 'Track Gain Adjustment';
1121  $RGADname[2] = 'Album Gain Adjustment';
1122  }
1123 
1124  return (isset($RGADname[$namecode]) ? $RGADname[$namecode] : '');
1125  }
+ Here is the caller graph for this function:

◆ RGADoriginatorLookup() [1/2]

static getid3_lib::RGADoriginatorLookup (   $originatorcode)
static

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

1125  {
1126  static $RGADoriginator = array();
1127  if (empty($RGADoriginator)) {
1128  $RGADoriginator[0] = 'unspecified';
1129  $RGADoriginator[1] = 'pre-set by artist/producer/mastering engineer';
1130  $RGADoriginator[2] = 'set by user';
1131  $RGADoriginator[3] = 'determined automatically';
1132  }
1133 
1134  return (isset($RGADoriginator[$originatorcode]) ? $RGADoriginator[$originatorcode] : '');
1135  }

◆ RGADoriginatorLookup() [2/2]

getid3_lib::RGADoriginatorLookup (   $originatorcode)

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

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

1128  {
1129  static $RGADoriginator = array();
1130  if (empty($RGADoriginator)) {
1131  $RGADoriginator[0] = 'unspecified';
1132  $RGADoriginator[1] = 'pre-set by artist/producer/mastering engineer';
1133  $RGADoriginator[2] = 'set by user';
1134  $RGADoriginator[3] = 'determined automatically';
1135  }
1136 
1137  return (isset($RGADoriginator[$originatorcode]) ? $RGADoriginator[$originatorcode] : '');
1138  }
+ 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.

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

56  {
57  if (isset($variable)) {
58  $variable += $increment;
59  } else {
60  $variable = $increment;
61  }
62  return true;
63  }
+ Here is the caller graph for this function:

◆ SafeStripSlashes()

getid3_lib::SafeStripSlashes (   $text)

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

References $text.

35  {
36  if (get_magic_quotes_gpc()) {
37  return stripslashes($text);
38  }
39  return $text;
40  }
$text

◆ sha1_file()

getid3_lib::sha1_file (   $file)

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

References $file, and $r.

Referenced by getID3\getHashdata().

545  {
546 
547  // sha1_file() exists in PHP 4.3.0+.
548  if (function_exists('sha1_file')) {
549  return sha1_file($file);
550  }
551 
552  $file = str_replace('`', '\\`', $file);
553 
554  if (GETID3_OS_ISWINDOWS) {
555 
556  $RequiredFiles = array('cygwin1.dll', 'sha1sum.exe');
557  foreach ($RequiredFiles as $required_file) {
558  if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
559  die(implode(' and ', $RequiredFiles).' are required in '.GETID3_HELPERAPPSDIR.' for getid3_lib::sha1_file() to function under Windows in PHP < v4.3.0');
560  }
561  }
562  $commandline = GETID3_HELPERAPPSDIR.'sha1sum.exe "'.str_replace('/', DIRECTORY_SEPARATOR, $file).'"';
563  if (ereg("^sha1=([0-9a-f]{40})", strtolower(`$commandline`), $r)) {
564  return $r[1];
565  }
566 
567  } else {
568 
569  $commandline = 'sha1sum '.escapeshellarg($file).'';
570  if (ereg("^([0-9a-f]{40})[ \t\n\r]", strtolower(`$commandline`), $r)) {
571  return $r[1];
572  }
573 
574  }
575 
576  return false;
577  }
print $file
$r
Definition: example_031.php:79
sha1_file($file)
Definition: getid3.lib.php:545
+ 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  }

◆ trimNullByte()

static getid3_lib::trimNullByte (   $string)
static

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

Referenced by getid3_matroska\parseEBML().

1357  {
1358  return trim($string, "\x00");
1359  }
+ Here is the caller graph for this function:

◆ trunc() [1/2]

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  }

◆ trunc() [2/2]

getid3_lib::trunc (   $floatnumber)

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

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

43  {
44  // truncates a floating-point number at the decimal point
45  // returns int (if possible, otherwise float)
46  if ($floatnumber >= 1) {
47  $truncatednumber = floor($floatnumber);
48  } elseif ($floatnumber <= -1) {
49  $truncatednumber = ceil($floatnumber);
50  } else {
51  $truncatednumber = 0;
52  }
53  if ($truncatednumber <= 1073741824) { // 2^30
54  $truncatednumber = (int) $truncatednumber;
55  }
56  return $truncatednumber;
57  }
+ Here is the caller graph for this function:

◆ XML2array()

static getid3_lib::XML2array (   $XMLstring)
static

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

References $loader.

Referenced by getid3_riff\Analyze().

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  }
$loader
+ Here is the caller graph for this function:

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