ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 1618 of file getid3.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 1633 of file getid3.php.

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

References $getid3.

Member Function Documentation

◆ Analyze()

◆ AnalyzeString()

getid3_handler::AnalyzeString (   $string)

Definition at line 1647 of file getid3.php.

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

References $data_string_length, Analyze(), and setStringMode().

+ Here is the call graph for this function:

◆ error()

getid3_handler::error (   $text)
protected

Definition at line 1738 of file getid3.php.

1738 {
1739 $this->getid3->info['error'][] = $text;
1740
1741 return false;
1742 }
$text

References $text.

Referenced by getid3_asf\Analyze(), getid3_riff\Analyze(), getid3_ac3\Analyze(), getid3_dts\Analyze(), getid3_flac\Analyze(), getid3_matroska\EnsureBufferHasEnoughData(), getid3_flac\parseMETAdata(), getid3_riff\ParseRIFF(), and getid3_flac\parseSTREAMINFO().

+ Here is the caller graph for this function:

◆ feof()

getid3_handler::feof ( )
protected

Definition at line 1727 of file getid3.php.

1727 {
1728 if ($this->data_string_flag) {
1729 return $this->data_string_position >= $this->data_string_length;
1730 }
1731 return feof($this->getid3->fp);
1732 }

References $data_string_length, and feof().

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

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

◆ fread()

getid3_handler::fread (   $bytes)
protected

Definition at line 1685 of file getid3.php.

1685 {
1686 if ($this->data_string_flag) {
1687 $this->data_string_position += $bytes;
1688 return substr($this->data_string, $this->data_string_position - $bytes, $bytes);
1689 }
1690 $pos = $this->ftell() + $bytes;
1691 if (!getid3_lib::intValueSupported($pos)) {
1692 throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10);
1693 }
1694 return fread($this->getid3->fp, $bytes);
1695 }
fread($bytes)
Definition: getid3.php:1685
static intValueSupported($num)
Definition: getid3.lib.php:80

References fread(), ftell(), and getid3_lib\intValueSupported().

Referenced by getid3_gzip\Analyze(), getid3_szip\Analyze(), getid3_tar\Analyze(), getid3_zip\Analyze(), getid3_asf\Analyze(), getid3_bink\Analyze(), getid3_flv\Analyze(), getid3_mpeg\Analyze(), getid3_nsv\Analyze(), getid3_quicktime\Analyze(), getid3_real\Analyze(), getid3_riff\Analyze(), getid3_swf\Analyze(), getid3_ts\Analyze(), getid3_aa\Analyze(), getid3_aac\Analyze(), getid3_ac3\Analyze(), getid3_amr\Analyze(), getid3_au\Analyze(), getid3_avr\Analyze(), getid3_bonk\Analyze(), getid3_dss\Analyze(), getid3_dts\Analyze(), getid3_flac\Analyze(), getid3_la\Analyze(), getid3_lpac\Analyze(), getid3_midi\Analyze(), getid3_mod\Analyze(), getid3_monkey\Analyze(), getid3_mp3\Analyze(), getid3_mpc\Analyze(), getid3_ogg\Analyze(), getid3_optimfrog\Analyze(), getid3_rkau\Analyze(), getid3_shorten\Analyze(), getid3_tta\Analyze(), getid3_voc\Analyze(), getid3_vqf\Analyze(), getid3_wavpack\Analyze(), getid3_bmp\Analyze(), getid3_efax\Analyze(), getid3_gif\Analyze(), getid3_pcd\Analyze(), getid3_png\Analyze(), getid3_svg\Analyze(), getid3_tiff\Analyze(), getid3_exe\Analyze(), getid3_iso\Analyze(), getid3_msoffice\Analyze(), getid3_apetag\Analyze(), getid3_id3v1\Analyze(), getid3_id3v2\Analyze(), getid3_lyrics3\Analyze(), getid3_mp3\decodeMPEGaudioHeader(), getid3_matroska\EnsureBufferHasEnoughData(), getid3_flac\FLACparseMETAdata(), fread(), getid3_mp3\FreeFormatFrameLength(), getid3_aac\getAACADIFheaderFilepointer(), getid3_aac\getAACADTSheaderFilepointer(), getid3_ac3\getid3_ac3(), getid3_apetag\getid3_apetag(), getid3_asf\getid3_asf(), getid3_au\getid3_au(), getid3_avr\getid3_avr(), getid3_bink\getid3_bink(), getid3_bmp\getid3_bmp(), getid3_bonk\getid3_bonk(), getid3_exe\getid3_exe(), getid3_flac\getid3_flac(), getid3_flv\getid3_flv(), getid3_gif\getid3_gif(), getid3_gzip\getid3_gzip(), getid3_id3v1\getid3_id3v1(), getid3_id3v2\getid3_id3v2(), getid3_iso\getid3_iso(), getid3_jpg\getid3_jpg(), getid3_la\getid3_la(), getid3_lpac\getid3_lpac(), getid3_lyrics3\getid3_lyrics3(), getid3_midi\getid3_midi(), getid3_monkey\getid3_monkey(), getid3_mp3\getid3_mp3(), getid3_mpc\getid3_mpc(), getid3_mpeg\getid3_mpeg(), getid3_nsv\getid3_nsv(), getid3_ogg\getid3_ogg(), getid3_optimfrog\getid3_optimfrog(), getid3_pcd\getid3_pcd(), getid3_png\getid3_png(), getid3_quicktime\getid3_quicktime(), getid3_real\getid3_real(), getid3_riff\getid3_riff(), getid3_rkau\getid3_rkau(), getid3_shorten\getid3_shorten(), getid3_svg\getid3_svg(), getid3_swf\getid3_swf(), getid3_szip\getid3_szip(), getid3_tar\getid3_tar(), getid3_tiff\getid3_tiff(), getid3_tta\getid3_tta(), getid3_voc\getid3_voc(), getid3_vqf\getid3_vqf(), getid3_wavpack\getid3_wavpack(), getid3_zip\getid3_zip(), 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_ogg\ParseVorbisCommentsFilepointer(), saveAttachment(), getid3_zip\ZIPparseCentralDirectory(), getid3_zip\ZIPparseEndOfCentralDirectory(), and getid3_zip\ZIPparseLocalFileHeader().

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

◆ fseek()

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

Definition at line 1697 of file getid3.php.

1697 {
1698 if ($this->data_string_flag) {
1699 switch ($whence) {
1700 case SEEK_SET:
1701 $this->data_string_position = $bytes;
1702 break;
1703
1704 case SEEK_CUR:
1705 $this->data_string_position += $bytes;
1706 break;
1707
1708 case SEEK_END:
1709 $this->data_string_position = $this->data_string_length + $bytes;
1710 break;
1711 }
1712 return 0;
1713 } else {
1714 $pos = $bytes;
1715 if ($whence == SEEK_CUR) {
1716 $pos = $this->ftell() + $bytes;
1717 } elseif ($whence == SEEK_END) {
1718 $pos = $this->getid3->info['filesize'] + $bytes;
1719 }
1720 if (!getid3_lib::intValueSupported($pos)) {
1721 throw new getid3_exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10);
1722 }
1723 }
1724 return fseek($this->getid3->fp, $bytes, $whence);
1725 }
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697

References fseek(), ftell(), and getid3_lib\intValueSupported().

Referenced by getid3_gzip\Analyze(), getid3_szip\Analyze(), getid3_tar\Analyze(), getid3_zip\Analyze(), getid3_asf\Analyze(), getid3_bink\Analyze(), getid3_flv\Analyze(), getid3_mpeg\Analyze(), getid3_nsv\Analyze(), getid3_quicktime\Analyze(), getid3_real\Analyze(), getid3_riff\Analyze(), getid3_swf\Analyze(), getid3_ts\Analyze(), getid3_aa\Analyze(), getid3_aac\Analyze(), getid3_ac3\Analyze(), getid3_amr\Analyze(), getid3_au\Analyze(), getid3_avr\Analyze(), getid3_bonk\Analyze(), getid3_dss\Analyze(), getid3_dts\Analyze(), getid3_flac\Analyze(), getid3_la\Analyze(), getid3_lpac\Analyze(), getid3_midi\Analyze(), getid3_mod\Analyze(), getid3_monkey\Analyze(), getid3_mp3\Analyze(), getid3_mpc\Analyze(), getid3_ogg\Analyze(), getid3_optimfrog\Analyze(), getid3_rkau\Analyze(), getid3_shorten\Analyze(), getid3_tta\Analyze(), getid3_voc\Analyze(), getid3_vqf\Analyze(), getid3_wavpack\Analyze(), getid3_bmp\Analyze(), getid3_efax\Analyze(), getid3_gif\Analyze(), getid3_jpg\Analyze(), getid3_pcd\Analyze(), getid3_png\Analyze(), getid3_svg\Analyze(), getid3_tiff\Analyze(), getid3_exe\Analyze(), getid3_iso\Analyze(), getid3_msoffice\Analyze(), getid3_apetag\Analyze(), getid3_id3v1\Analyze(), getid3_id3v2\Analyze(), getid3_lyrics3\Analyze(), getid3_mp3\decodeMPEGaudioHeader(), getid3_matroska\EnsureBufferHasEnoughData(), getid3_flac\FLACparseMETAdata(), getid3_mp3\FreeFormatFrameLength(), fseek(), getid3_aac\getAACADIFheaderFilepointer(), getid3_aac\getAACADTSheaderFilepointer(), getid3_ac3\getid3_ac3(), getid3_apetag\getid3_apetag(), getid3_asf\getid3_asf(), getid3_au\getid3_au(), getid3_avr\getid3_avr(), getid3_bink\getid3_bink(), getid3_bmp\getid3_bmp(), getid3_bonk\getid3_bonk(), getid3_exe\getid3_exe(), getid3_flac\getid3_flac(), getid3_flv\getid3_flv(), getid3_gif\getid3_gif(), getid3_gzip\getid3_gzip(), getid3_id3v1\getid3_id3v1(), getid3_id3v2\getid3_id3v2(), getid3_iso\getid3_iso(), getid3_jpg\getid3_jpg(), getid3_la\getid3_la(), getid3_lpac\getid3_lpac(), getid3_lyrics3\getid3_lyrics3(), getid3_matroska\getid3_matroska(), getid3_midi\getid3_midi(), getid3_monkey\getid3_monkey(), getid3_mp3\getid3_mp3(), getid3_mpc\getid3_mpc(), getid3_mpeg\getid3_mpeg(), getid3_nsv\getid3_nsv(), getid3_ogg\getid3_ogg(), getid3_optimfrog\getid3_optimfrog(), getid3_pcd\getid3_pcd(), getid3_png\getid3_png(), getid3_quicktime\getid3_quicktime(), getid3_real\getid3_real(), getid3_riff\getid3_riff(), getid3_rkau\getid3_rkau(), getid3_shorten\getid3_shorten(), getid3_svg\getid3_svg(), getid3_swf\getid3_swf(), getid3_szip\getid3_szip(), getid3_tar\getid3_tar(), getid3_tiff\getid3_tiff(), getid3_tta\getid3_tta(), getid3_voc\getid3_voc(), getid3_vqf\getid3_vqf(), getid3_wavpack\getid3_wavpack(), getid3_zip\getid3_zip(), 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_ogg\ParseVorbisCommentsFilepointer(), saveAttachment(), getid3_zip\ZIPparseCentralDirectory(), getid3_zip\ZIPparseEndOfCentralDirectory(), and getid3_zip\ZIPparseLocalFileHeader().

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

◆ ftell()

◆ isDependencyFor()

getid3_handler::isDependencyFor (   $module)
finalprotected

Definition at line 1734 of file getid3.php.

1734 {
1735 return $this->dependency_to == $module;
1736 }

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

+ Here is the caller graph for this function:

◆ notice()

getid3_handler::notice (   $text)
protected

Definition at line 1748 of file getid3.php.

1748 {
1749 // does nothing for now
1750 }

Referenced by getid3_ogg\ParseVorbisComments().

+ Here is the caller graph for this function:

◆ saveAttachment()

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

Definition at line 1752 of file getid3.php.

1752 {
1753 try {
1754
1755 // do not extract at all
1756 if ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_NONE) {
1757
1758 $attachment = null; // do not set any
1759
1760 // extract to return array
1761 } elseif ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_INLINE) {
1762
1763 $this->fseek($offset);
1764 $attachment = $this->fread($length); // get whole data in one pass, till it is anyway stored in memory
1765 if ($attachment === false || strlen($attachment) != $length) {
1766 throw new Exception('failed to read attachment data');
1767 }
1768
1769 // assume directory path is given
1770 } else {
1771
1772 // set up destination path
1773 $dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->getid3->option_save_attachments), DIRECTORY_SEPARATOR);
1774 if (!is_dir($dir) || !is_writable($dir)) { // check supplied directory
1775 throw new Exception('supplied path ('.$dir.') does not exist, or is not writable');
1776 }
1777 $dest = $dir.DIRECTORY_SEPARATOR.$name.($image_mime ? '.'.getid3_lib::ImageExtFromMime($image_mime) : '');
1778
1779 // create dest file
1780 if (($fp_dest = fopen($dest, 'wb')) == false) {
1781 throw new Exception('failed to create file '.$dest);
1782 }
1783
1784 // copy data
1785 $this->fseek($offset);
1786 $buffersize = ($this->data_string_flag ? $length : $this->getid3->fread_buffer_size());
1787 $bytesleft = $length;
1788 while ($bytesleft > 0) {
1789 if (($buffer = $this->fread(min($buffersize, $bytesleft))) === false || ($byteswritten = fwrite($fp_dest, $buffer)) === false || ($byteswritten === 0)) {
1790 throw new Exception($buffer === false ? 'not enough data to read' : 'failed to write to destination file, may be not enough disk space');
1791 }
1792 $bytesleft -= $byteswritten;
1793 }
1794
1795 fclose($fp_dest);
1796 $attachment = $dest;
1797
1798 }
1799
1800 } catch (Exception $e) {
1801
1802 // close and remove dest file if created
1803 if (isset($fp_dest) && is_resource($fp_dest)) {
1804 fclose($fp_dest);
1805 unlink($dest);
1806 }
1807
1808 // do not set any is case of error
1809 $attachment = null;
1810 $this->warning('Failed to extract attachment '.$name.': '.$e->getMessage());
1811
1812 }
1813
1814 // seek to the end of attachment
1815 $this->fseek($offset + $length);
1816
1817 return $attachment;
1818 }
const ATTACHMENTS_INLINE
Definition: getid3.php:116
const ATTACHMENTS_NONE
Definition: getid3.php:115
warning($text)
Definition: getid3.php:1744

References getID3\ATTACHMENTS_INLINE, getID3\ATTACHMENTS_NONE, fread(), fseek(), and warning().

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

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

◆ setStringMode()

getid3_handler::setStringMode (   $string)

Definition at line 1672 of file getid3.php.

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

Referenced by AnalyzeString().

+ Here is the caller graph for this function:

◆ warning()

Field Documentation

◆ $data_string

getid3_handler::$data_string = ''
protected

Definition at line 1626 of file getid3.php.

◆ $data_string_flag

getid3_handler::$data_string_flag = false
protected

Definition at line 1625 of file getid3.php.

◆ $data_string_length

getid3_handler::$data_string_length = 0
protected

Definition at line 1628 of file getid3.php.

Referenced by AnalyzeString(), and feof().

◆ $data_string_position

getid3_handler::$data_string_position = 0
protected

Definition at line 1627 of file getid3.php.

Referenced by ftell().

◆ $dependency_to

getid3_handler::$dependency_to = null
private

Definition at line 1630 of file getid3.php.

◆ $getid3

getid3_handler::$getid3
protected

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