ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
getid3_handler Class Reference
+ Inheritance diagram for getid3_handler:
+ Collaboration diagram for getid3_handler:

Public Member Functions

 __construct (getID3 $getid3, $call_module=null)
 
 Analyze ()
 
 AnalyzeString ($string)
 
 setStringMode ($string)
 
 saveAttachment ($name, $offset, $length, $image_mime=null)
 

Protected Member Functions

 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
 notice ($text)
 

Protected Attributes

 $getid3
 
 $data_string_flag = false
 
 $data_string = ''
 
 $data_string_position = 0
 
 $data_string_length = 0
 

Private Attributes

 $dependency_to = null
 

Detailed Description

Definition at line 1616 of file getid3.php.

Constructor & Destructor Documentation

◆ __construct()

getid3_handler::__construct ( getID3  $getid3,
  $call_module = null 
)

Definition at line 1631 of file getid3.php.

1631  {
1632  $this->getid3 = $getid3;
1633 
1634  if ($call_module) {
1635  $this->dependency_to = str_replace('getid3_', '', $call_module);
1636  }
1637  }

Member Function Documentation

◆ Analyze()

getid3_handler::Analyze ( )
abstract

◆ AnalyzeString()

getid3_handler::AnalyzeString (   $string)

Definition at line 1645 of file getid3.php.

1645  {
1646  // Enter string mode
1647  $this->setStringMode($string);
1648 
1649  // Save info
1650  $saved_avdataoffset = $this->getid3->info['avdataoffset'];
1651  $saved_avdataend = $this->getid3->info['avdataend'];
1652  $saved_filesize = (isset($this->getid3->info['filesize']) ? $this->getid3->info['filesize'] : null); // may be not set if called as dependency without openfile() call
1653 
1654  // Reset some info
1655  $this->getid3->info['avdataoffset'] = 0;
1656  $this->getid3->info['avdataend'] = $this->getid3->info['filesize'] = $this->data_string_length;
1657 
1658  // Analyze
1659  $this->Analyze();
1660 
1661  // Restore some info
1662  $this->getid3->info['avdataoffset'] = $saved_avdataoffset;
1663  $this->getid3->info['avdataend'] = $saved_avdataend;
1664  $this->getid3->info['filesize'] = $saved_filesize;
1665 
1666  // Exit string mode
1667  $this->data_string_flag = false;
1668  }
setStringMode($string)
Definition: getid3.php:1670

◆ error()

getid3_handler::error (   $text)
protected

Definition at line 1752 of file getid3.php.

References $text.

Referenced by getid3_bonk\Analyze(), getid3_vqf\Analyze(), getid3_zip\Analyze(), getid3_bink\Analyze(), getid3_dss\Analyze(), getid3_wavpack\Analyze(), getid3_efax\Analyze(), getid3_gif\Analyze(), getid3_tiff\Analyze(), getid3_exe\Analyze(), getid3_msoffice\Analyze(), getid3_par2\Analyze(), getid3_pdf\Analyze(), getid3_ts\Analyze(), getid3_mod\Analyze(), getid3_aa\Analyze(), getid3_monkey\Analyze(), getid3_amr\Analyze(), getid3_mpc\Analyze(), getid3_voc\Analyze(), getid3_szip\Analyze(), getid3_tta\Analyze(), getid3_avr\Analyze(), getid3_rkau\Analyze(), getid3_nsv\Analyze(), getid3_shorten\Analyze(), getid3_au\Analyze(), getid3_svg\Analyze(), getid3_apetag\Analyze(), getid3_lpac\Analyze(), getid3_png\Analyze(), getid3_pcd\Analyze(), getid3_real\Analyze(), getid3_la\Analyze(), getid3_swf\Analyze(), getid3_ogg\Analyze(), getid3_dsf\Analyze(), getid3_optimfrog\Analyze(), getid3_bmp\Analyze(), getid3_id3v2\Analyze(), getid3_rar\Analyze(), getid3_midi\Analyze(), getid3_ac3\Analyze(), getid3_quicktime\Analyze(), getid3_flac\Analyze(), getid3_gzip\Analyze(), getid3_mp3\Analyze(), getid3_asf\Analyze(), getid3_riff\Analyze(), getid3_dts\Analyze(), getid3_flv\Analyze(), getid3_matroska\Analyze(), getid3_mp3\decodeMPEGaudioHeader(), getid3_matroska\EnsureBufferHasEnoughData(), getid3_mp3\FreeFormatFrameLength(), getid3_aac\getAACADIFheaderFilepointer(), getid3_aac\getAACADTSheaderFilepointer(), getid3_mod\getITheaderFilepointer(), getid3_lyrics3\getLyrics3Data(), getid3_mod\getMODheaderFilepointer(), getid3_nsv\getNSVfHeaderFilepointer(), getid3_nsv\getNSVsHeaderFilepointer(), getid3_mp3\getOnlyMPEGaudioInfo(), getid3_mp3\getOnlyMPEGaudioInfoBruteForce(), getid3_mod\getS3MheaderFilepointer(), getid3_mod\getXMheaderFilepointer(), getid3_zip\getZIPentriesFilepointer(), getid3_zip\getZIPHeaderFilepointerTopDown(), getid3_bink\ParseBink(), getid3_flac\parseMETAdata(), getid3_mpc\ParseMPCsv7(), getid3_mpc\ParseMPCsv8(), getid3_ogg\ParseOpusPageHeader(), getid3_iso\ParsePathTable(), getid3_iso\ParsePrimaryVolumeDescriptor(), getid3_riff\ParseRIFF(), getid3_flac\parseSTREAMINFO(), getid3_iso\ParseSupplementaryVolumeDescriptor(), getid3_ogg\ParseVorbisPageHeader(), getid3_quicktime\QuicktimeParseAtom(), and getid3_mp3\RecursiveFrameScanning().

1752  {
1753  $this->getid3->info['error'][] = $text;
1754 
1755  return false;
1756  }
$text
Definition: errorreport.php:18
+ Here is the caller graph for this function:

◆ feof()

getid3_handler::feof ( )
protected

Definition at line 1741 of file getid3.php.

Referenced by getid3_szip\Analyze(), getid3_amr\Analyze(), getid3_voc\Analyze(), getid3_wavpack\Analyze(), getid3_tar\Analyze(), getid3_matroska\EnsureBufferHasEnoughData(), getid3_mp3\getOnlyMPEGaudioInfo(), getid3_bonk\HandleBonkTags(), getid3_ogg\ParseOggPageHeader(), and getid3_optimfrog\ParseOptimFROGheader45().

1741  {
1742  if ($this->data_string_flag) {
1743  return $this->data_string_position >= $this->data_string_length;
1744  }
1745  return feof($this->getid3->fp);
1746  }
+ Here is the caller graph for this function:

◆ fread()

getid3_handler::fread (   $bytes)
protected

Definition at line 1683 of file getid3.php.

References $contents, and getid3_lib\intValueSupported().

Referenced by getid3_aac\Analyze(), getid3_vqf\Analyze(), getid3_bonk\Analyze(), getid3_zip\Analyze(), getid3_bink\Analyze(), getid3_dss\Analyze(), getid3_tta\Analyze(), getid3_shorten\Analyze(), getid3_voc\Analyze(), getid3_wavpack\Analyze(), getid3_efax\Analyze(), getid3_gif\Analyze(), getid3_tiff\Analyze(), getid3_exe\Analyze(), getid3_iso\Analyze(), getid3_ts\Analyze(), getid3_mod\Analyze(), getid3_msoffice\Analyze(), getid3_id3v1\Analyze(), getid3_lyrics3\Analyze(), getid3_aa\Analyze(), getid3_monkey\Analyze(), getid3_nsv\Analyze(), getid3_mpc\Analyze(), getid3_rkau\Analyze(), getid3_szip\Analyze(), getid3_au\Analyze(), getid3_amr\Analyze(), getid3_avr\Analyze(), getid3_dsf\Analyze(), getid3_apetag\Analyze(), getid3_real\Analyze(), getid3_svg\Analyze(), getid3_pcd\Analyze(), getid3_png\Analyze(), getid3_la\Analyze(), getid3_lpac\Analyze(), getid3_swf\Analyze(), getid3_ogg\Analyze(), getid3_optimfrog\Analyze(), getid3_bmp\Analyze(), getid3_id3v2\Analyze(), getid3_midi\Analyze(), getid3_ac3\Analyze(), getid3_tar\Analyze(), getid3_flac\Analyze(), getid3_quicktime\Analyze(), getid3_gzip\Analyze(), getid3_mp3\Analyze(), getid3_mpeg\Analyze(), getid3_asf\Analyze(), getid3_riff\Analyze(), getid3_dts\Analyze(), getid3_flv\Analyze(), getid3_mp3\decodeMPEGaudioHeader(), getid3_matroska\EnsureBufferHasEnoughData(), getid3_mp3\FreeFormatFrameLength(), getid3_aac\getAACADIFheaderFilepointer(), getid3_aac\getAACADTSheaderFilepointer(), getid3_mod\getITheaderFilepointer(), getid3_gif\GetLSBits(), getid3_lyrics3\getLyrics3Data(), getid3_mod\getMODheaderFilepointer(), getid3_nsv\getNSVfHeaderFilepointer(), getid3_nsv\getNSVsHeaderFilepointer(), getid3_mp3\getOnlyMPEGaudioInfo(), getid3_mp3\getOnlyMPEGaudioInfoBruteForce(), getid3_mod\getS3MheaderFilepointer(), getid3_mod\getXMheaderFilepointer(), getid3_bonk\HandleBonkTags(), getid3_iso\ParseDirectoryRecord(), getid3_flac\parseMETAdata(), getid3_mpc\ParseMPCsv6(), getid3_mpc\ParseMPCsv7(), getid3_mpc\ParseMPCsv8(), getid3_ogg\ParseOggPageHeader(), getid3_optimfrog\ParseOptimFROGheader42(), getid3_optimfrog\ParseOptimFROGheader45(), getid3_iso\ParsePathTable(), getid3_flac\parsePICTURE(), getid3_riff\ParseRIFF(), getid3_riff\ParseRIFFAMV(), getid3_ogg\ParseVorbisComments(), getid3_zip\ZIPparseCentralDirectory(), getid3_zip\ZIPparseEndOfCentralDirectory(), and getid3_zip\ZIPparseLocalFileHeader().

1683  {
1684  if ($this->data_string_flag) {
1685  $this->data_string_position += $bytes;
1686  return substr($this->data_string, $this->data_string_position - $bytes, $bytes);
1687  }
1688  $pos = $this->ftell() + $bytes;
1689  if (!getid3_lib::intValueSupported($pos)) {
1690  throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10);
1691  }
1692 
1693  //return fread($this->getid3->fp, $bytes);
1694  /*
1695  * http://www.getid3.org/phpBB3/viewtopic.php?t=1930
1696  * "I found out that the root cause for the problem was how getID3 uses the PHP system function fread().
1697  * It seems to assume that fread() would always return as many bytes as were requested.
1698  * However, according the PHP manual (http://php.net/manual/en/function.fread.php), this is the case only with regular local files, but not e.g. with Linux pipes.
1699  * The call may return only part of the requested data and a new call is needed to get more."
1700  */
1701  $contents = '';
1702  do {
1703  $part = fread($this->getid3->fp, $bytes);
1704  $partLength = strlen($part);
1705  $bytes -= $partLength;
1706  $contents .= $part;
1707  } while (($bytes > 0) && ($partLength > 0));
1708  return $contents;
1709  }
static intValueSupported($num)
Definition: getid3.lib.php:80
fread($bytes)
Definition: getid3.php:1683
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fseek()

getid3_handler::fseek (   $bytes,
  $whence = SEEK_SET 
)
protected

Definition at line 1711 of file getid3.php.

References getid3_lib\intValueSupported().

Referenced by getid3_aac\Analyze(), getid3_vqf\Analyze(), getid3_bonk\Analyze(), getid3_zip\Analyze(), getid3_bink\Analyze(), getid3_dss\Analyze(), getid3_wavpack\Analyze(), getid3_efax\Analyze(), getid3_gif\Analyze(), getid3_tiff\Analyze(), getid3_exe\Analyze(), getid3_iso\Analyze(), getid3_msoffice\Analyze(), getid3_ts\Analyze(), getid3_mod\Analyze(), getid3_id3v1\Analyze(), getid3_lyrics3\Analyze(), getid3_aa\Analyze(), getid3_monkey\Analyze(), getid3_nsv\Analyze(), getid3_mpc\Analyze(), getid3_voc\Analyze(), getid3_tta\Analyze(), getid3_shorten\Analyze(), getid3_szip\Analyze(), getid3_au\Analyze(), getid3_amr\Analyze(), getid3_rkau\Analyze(), getid3_avr\Analyze(), getid3_dsf\Analyze(), getid3_apetag\Analyze(), getid3_real\Analyze(), getid3_pcd\Analyze(), getid3_svg\Analyze(), getid3_la\Analyze(), getid3_lpac\Analyze(), getid3_png\Analyze(), getid3_swf\Analyze(), getid3_ogg\Analyze(), getid3_optimfrog\Analyze(), getid3_bmp\Analyze(), getid3_jpg\Analyze(), getid3_id3v2\Analyze(), getid3_midi\Analyze(), getid3_ac3\Analyze(), getid3_tar\Analyze(), getid3_flac\Analyze(), getid3_quicktime\Analyze(), getid3_gzip\Analyze(), getid3_mp3\Analyze(), getid3_mpeg\Analyze(), getid3_asf\Analyze(), getid3_riff\Analyze(), getid3_dts\Analyze(), getid3_flv\Analyze(), getid3_mp3\decodeMPEGaudioHeader(), getid3_matroska\EnsureBufferHasEnoughData(), getid3_mp3\FreeFormatFrameLength(), getid3_aac\getAACADIFheaderFilepointer(), getid3_aac\getAACADTSheaderFilepointer(), getid3_mod\getITheaderFilepointer(), getid3_lyrics3\getLyrics3Data(), getid3_mod\getMODheaderFilepointer(), getid3_nsv\getNSVfHeaderFilepointer(), getid3_nsv\getNSVsHeaderFilepointer(), getid3_mp3\getOnlyMPEGaudioInfo(), getid3_mp3\getOnlyMPEGaudioInfoBruteForce(), getid3_mod\getS3MheaderFilepointer(), getid3_mod\getXMheaderFilepointer(), getid3_bonk\HandleBonkTags(), getid3_iso\ParseDirectoryRecord(), getid3_mpc\ParseMPCsv6(), getid3_mpc\ParseMPCsv8(), getid3_ogg\ParseOggPageHeader(), getid3_optimfrog\ParseOptimFROGheader42(), getid3_optimfrog\ParseOptimFROGheader45(), getid3_iso\ParsePathTable(), getid3_riff\ParseRIFF(), getid3_riff\ParseRIFFAMV(), getid3_ogg\ParseVorbisComments(), getid3_zip\ZIPparseCentralDirectory(), getid3_zip\ZIPparseEndOfCentralDirectory(), and getid3_zip\ZIPparseLocalFileHeader().

1711  {
1712  if ($this->data_string_flag) {
1713  switch ($whence) {
1714  case SEEK_SET:
1715  $this->data_string_position = $bytes;
1716  break;
1717 
1718  case SEEK_CUR:
1719  $this->data_string_position += $bytes;
1720  break;
1721 
1722  case SEEK_END:
1723  $this->data_string_position = $this->data_string_length + $bytes;
1724  break;
1725  }
1726  return 0;
1727  } else {
1728  $pos = $bytes;
1729  if ($whence == SEEK_CUR) {
1730  $pos = $this->ftell() + $bytes;
1731  } elseif ($whence == SEEK_END) {
1732  $pos = $this->getid3->info['filesize'] + $bytes;
1733  }
1734  if (!getid3_lib::intValueSupported($pos)) {
1735  throw new getid3_exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10);
1736  }
1737  }
1738  return fseek($this->getid3->fp, $bytes, $whence);
1739  }
static intValueSupported($num)
Definition: getid3.lib.php:80
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1711
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ftell()

◆ isDependencyFor()

getid3_handler::isDependencyFor (   $module)
finalprotected

Definition at line 1748 of file getid3.php.

References $module.

Referenced by getid3_ac3\Analyze(), getid3_dts\Analyze(), getid3_mp3\decodeMPEGaudioHeader(), getid3_flac\parseMETAdata(), getid3_flac\parseSTREAMINFO(), and getid3_flac\parseVORBIS_COMMENT().

1748  {
1749  return $this->dependency_to == $module;
1750  }
if($modEnd===false) $module
Definition: module.php:59
+ Here is the caller graph for this function:

◆ notice()

getid3_handler::notice (   $text)
protected

Definition at line 1762 of file getid3.php.

Referenced by getid3_ogg\ParseVorbisComments().

1762  {
1763  // does nothing for now
1764  }
+ Here is the caller graph for this function:

◆ saveAttachment()

getid3_handler::saveAttachment (   $name,
  $offset,
  $length,
  $image_mime = null 
)

Definition at line 1766 of file getid3.php.

References $name, array, getID3\ATTACHMENTS_INLINE, getID3\ATTACHMENTS_NONE, and getID3\warning().

Referenced by getid3_matroska\parseEBML(), and getid3_flac\parsePICTURE().

1766  {
1767  try {
1768 
1769  // do not extract at all
1770  if ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_NONE) {
1771 
1772  $attachment = null; // do not set any
1773 
1774  // extract to return array
1775  } elseif ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_INLINE) {
1776 
1777  $this->fseek($offset);
1778  $attachment = $this->fread($length); // get whole data in one pass, till it is anyway stored in memory
1779  if ($attachment === false || strlen($attachment) != $length) {
1780  throw new Exception('failed to read attachment data');
1781  }
1782 
1783  // assume directory path is given
1784  } else {
1785 
1786  // set up destination path
1787  $dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->getid3->option_save_attachments), DIRECTORY_SEPARATOR);
1788  if (!is_dir($dir) || !is_writable($dir)) { // check supplied directory
1789  throw new Exception('supplied path ('.$dir.') does not exist, or is not writable');
1790  }
1791  $dest = $dir.DIRECTORY_SEPARATOR.$name.($image_mime ? '.'.getid3_lib::ImageExtFromMime($image_mime) : '');
1792 
1793  // create dest file
1794  if (($fp_dest = fopen($dest, 'wb')) == false) {
1795  throw new Exception('failed to create file '.$dest);
1796  }
1797 
1798  // copy data
1799  $this->fseek($offset);
1800  $buffersize = ($this->data_string_flag ? $length : $this->getid3->fread_buffer_size());
1801  $bytesleft = $length;
1802  while ($bytesleft > 0) {
1803  if (($buffer = $this->fread(min($buffersize, $bytesleft))) === false || ($byteswritten = fwrite($fp_dest, $buffer)) === false || ($byteswritten === 0)) {
1804  throw new Exception($buffer === false ? 'not enough data to read' : 'failed to write to destination file, may be not enough disk space');
1805  }
1806  $bytesleft -= $byteswritten;
1807  }
1808 
1809  fclose($fp_dest);
1810  $attachment = $dest;
1811 
1812  }
1813 
1814  } catch (Exception $e) {
1815 
1816  // close and remove dest file if created
1817  if (isset($fp_dest) && is_resource($fp_dest)) {
1818  fclose($fp_dest);
1819  unlink($dest);
1820  }
1821 
1822  // do not set any is case of error
1823  $attachment = null;
1824  $this->warning('Failed to extract attachment '.$name.': '.$e->getMessage());
1825 
1826  }
1827 
1828  // seek to the end of attachment
1829  $this->fseek($offset + $length);
1830 
1831  return $attachment;
1832  }
const ATTACHMENTS_NONE
Definition: getid3.php:118
warning($text)
Definition: getid3.php:1758
if($format !==null) $name
Definition: metadata.php:146
fread($bytes)
Definition: getid3.php:1683
Create styles array
The data for the language used.
const ATTACHMENTS_INLINE
Definition: getid3.php:119
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1711
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setStringMode()

getid3_handler::setStringMode (   $string)

Definition at line 1670 of file getid3.php.

1670  {
1671  $this->data_string_flag = true;
1672  $this->data_string = $string;
1673  $this->data_string_length = strlen($string);
1674  }

◆ warning()

getid3_handler::warning (   $text)
protected

Definition at line 1758 of file getid3.php.

References $text.

Referenced by getid3_bonk\Analyze(), getid3_vqf\Analyze(), getid3_aa\Analyze(), getid3_zip\Analyze(), getid3_nsv\Analyze(), getid3_id3v1\Analyze(), getid3_voc\Analyze(), getid3_wavpack\Analyze(), getid3_au\Analyze(), getid3_avr\Analyze(), getid3_lyrics3\Analyze(), getid3_ogg\Analyze(), getid3_png\Analyze(), getid3_apetag\Analyze(), getid3_real\Analyze(), getid3_la\Analyze(), getid3_lpac\Analyze(), getid3_id3v2\Analyze(), getid3_jpg\Analyze(), getid3_midi\Analyze(), getid3_ac3\Analyze(), getid3_quicktime\Analyze(), getid3_mp3\Analyze(), getid3_mpeg\Analyze(), getid3_asf\Analyze(), getid3_riff\Analyze(), getid3_matroska\Analyze(), getid3_mp3\decodeMPEGaudioHeader(), getid3_matroska\EnsureBufferHasEnoughData(), getid3_mp3\FreeFormatFrameLength(), getid3_aac\getAACADTSheaderFilepointer(), getid3_lyrics3\getLyrics3Data(), getid3_nsv\getNSVfHeaderFilepointer(), getid3_mp3\getOnlyMPEGaudioInfo(), getid3_mp3\getOnlyMPEGaudioInfoBruteForce(), getid3_bonk\HandleBonkTags(), getid3_asf\HeaderExtensionObjectDataParse(), getid3_matroska\parseEBML(), getid3_id3v2\ParseID3v2Frame(), getid3_flac\parseMETAdata(), getid3_mpc\ParseMPCsv6(), getid3_optimfrog\ParseOptimFROGheader45(), getid3_riff\ParseRIFF(), getid3_riff\ParseRIFFAMV(), getid3_flac\parseSTREAMINFO(), getid3_ogg\ParseVorbisComments(), getid3_quicktime\QuicktimeParseAtom(), getid3_mp3\RecursiveFrameScanning(), getid3_matroska\unhandledElement(), and getid3_zip\ZIPparseLocalFileHeader().

1758  {
1759  return $this->getid3->warning($text);
1760  }
$text
Definition: errorreport.php:18
+ Here is the caller graph for this function:

Field Documentation

◆ $data_string

getid3_handler::$data_string = ''
protected

Definition at line 1624 of file getid3.php.

◆ $data_string_flag

getid3_handler::$data_string_flag = false
protected

Definition at line 1623 of file getid3.php.

◆ $data_string_length

getid3_handler::$data_string_length = 0
protected

Definition at line 1626 of file getid3.php.

◆ $data_string_position

getid3_handler::$data_string_position = 0
protected

Definition at line 1625 of file getid3.php.

◆ $dependency_to

getid3_handler::$dependency_to = null
private

Definition at line 1628 of file getid3.php.

◆ $getid3

getid3_handler::$getid3
protected

Definition at line 1621 of file getid3.php.

Referenced by getid3_ogg\ParseVorbisComments().


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