ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
GetId3\Handler\BaseHandler Class Reference

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

+ Inheritance diagram for GetId3\Handler\BaseHandler:
+ Collaboration diagram for GetId3\Handler\BaseHandler:

Public Member Functions

 __construct (GetId3Core $getid3, $call_module=null)
 
 analyze ()
 Analyze from file pointer. More...
 
 AnalyzeString (&$string)
 Analyze from string instead. More...
 
 saveAttachment (&$ThisFileInfoIndex, $filename, $offset, $length)
 

Protected Member Functions

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

Protected Attributes

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

Private Attributes

 $dependency_to
 

Detailed Description

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

Author
James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g http://www.getid3.org

Definition at line 25 of file BaseHandler.php.

Constructor & Destructor Documentation

◆ __construct()

GetId3\Handler\BaseHandler::__construct ( GetId3Core  $getid3,
  $call_module = null 
)
Parameters
GetId3\GetId3$getid3
type$call_module

Definition at line 69 of file BaseHandler.php.

References GetId3\Handler\BaseHandler\$getid3, and GetId3\Handler\BaseHandler\analyze().

70  {
71  $this->getid3 = $getid3;
72 
73  if (null !== $call_module) {
74  $this->dependency_to = $call_module;
75  }
76  }
+ Here is the call graph for this function:

Member Function Documentation

◆ analyze()

GetId3\Handler\BaseHandler::analyze ( )
abstract

Analyze from file pointer.

Referenced by GetId3\Handler\BaseHandler\__construct(), and GetId3\Handler\BaseHandler\AnalyzeString().

+ Here is the caller graph for this function:

◆ AnalyzeString()

GetId3\Handler\BaseHandler::AnalyzeString ( $string)

Analyze from string instead.

Definition at line 86 of file BaseHandler.php.

References GetId3\Handler\BaseHandler\analyze().

87  {
88  // Enter string mode
89  $this->data_string_flag = true;
90  $this->data_string = $string;
91 
92  // Save info
93  $saved_avdataoffset = $this->getid3->info['avdataoffset'];
94  $saved_avdataend = $this->getid3->info['avdataend'];
95  $saved_filesize = (isset($this->getid3->info['filesize']) ? $this->getid3->info['filesize'] : null); // may be not set if called as dependency without openfile() call
96  // Reset some info
97  $this->getid3->info['avdataoffset'] = 0;
98  $this->getid3->info['avdataend'] = $this->getid3->info['filesize'] = $this->data_string_length = strlen($string);
99 
100  // Analyze
101  $this->analyze();
102 
103  // Restore some info
104  $this->getid3->info['avdataoffset'] = $saved_avdataoffset;
105  $this->getid3->info['avdataend'] = $saved_avdataend;
106  $this->getid3->info['filesize'] = $saved_filesize;
107 
108  // Exit string mode
109  $this->data_string_flag = false;
110  }
analyze()
Analyze from file pointer.
+ Here is the call graph for this function:

◆ error()

GetId3\Handler\BaseHandler::error (   $text)
protected
Parameters
type$text
Returns
boolean

Definition at line 199 of file BaseHandler.php.

References $text.

Referenced by GetId3\Module\Audio\Dts\analyze(), GetId3\Module\Audio\Flac\analyze(), GetId3\Module\Audio\Ac3\analyze(), GetId3\Module\Audio\Flac\parseMETAdata(), and GetId3\Module\Audio\Flac\parseSTREAMINFO().

200  {
201  $this->getid3->info['error'][] = $text;
202 
203  return false;
204  }
$text
+ Here is the caller graph for this function:

◆ feof()

◆ fread()

GetId3\Handler\BaseHandler::fread (   $bytes)
protected
Parameters
type$bytes
Returns
type

Definition at line 130 of file BaseHandler.php.

Referenced by GetId3\Module\Audio\Avr\analyze(), GetId3\Module\Graphic\Svg\analyze(), GetId3\Module\Archive\Zip\analyze(), GetId3\Module\Audio\Dss\analyze(), GetId3\Module\Audio\Aac\analyze(), GetId3\Module\Audio\Dts\analyze(), GetId3\Module\Tag\Id3v1\analyze(), GetId3\Module\Archive\Szip\analyze(), GetId3\Module\Audio\Mod\analyze(), GetId3\Module\Audio\Vqf\analyze(), GetId3\Module\AudioVideo\Ts\analyze(), GetId3\Module\Graphic\Efax\analyze(), GetId3\Module\Graphic\Gif\analyze(), GetId3\Module\Audio\Mpc\analyze(), GetId3\Module\Graphic\Png\analyze(), GetId3\Module\Audio\Aa\analyze(), GetId3\Module\Graphic\Tiff\analyze(), GetId3\Module\Misc\Exe\analyze(), GetId3\Module\Misc\Iso\analyze(), GetId3\Module\Audio\Rkau\analyze(), GetId3\Module\Misc\Msoffice\analyze(), GetId3\Module\Audio\Voc\analyze(), GetId3\Module\Audio\Tta\analyze(), GetId3\Module\AudioVideo\Bink\analyze(), GetId3\Module\Audio\Au\analyze(), GetId3\Module\AudioVideo\Nsv\analyze(), GetId3\Module\Audio\Monkey\analyze(), GetId3\Module\Audio\Flac\analyze(), GetId3\Module\Audio\Bonk\analyze(), GetId3\Module\AudioVideo\Real\analyze(), GetId3\Module\Audio\La\analyze(), GetId3\Module\Tag\Lyrics3\analyze(), GetId3\Module\Audio\Lpac\analyze(), GetId3\Module\Audio\Wavpack\analyze(), GetId3\Module\Graphic\Pcd\analyze(), GetId3\Module\Audio\Optimfrog\analyze(), GetId3\Module\Audio\Shorten\analyze(), GetId3\Module\AudioVideo\Swf\analyze(), GetId3\Module\Graphic\Jpg\analyze(), GetId3\Module\Audio\Ogg\analyze(), GetId3\Module\Archive\Tar\analyze(), GetId3\Module\Audio\Midi\analyze(), GetId3\Module\Tag\Apetag\analyze(), GetId3\Module\Graphic\Bmp\analyze(), GetId3\Module\Tag\Id3v2\analyze(), GetId3\Module\AudioVideo\Mpeg\analyze(), GetId3\Module\Audio\Ac3\analyze(), GetId3\Module\AudioVideo\Riff\analyze(), GetId3\Module\AudioVideo\Quicktime\analyze(), GetId3\Module\Audio\Mp3\analyze(), GetId3\Module\AudioVideo\Flv\analyze(), GetId3\Module\AudioVideo\Asf\analyze(), GetId3\Module\Audio\Mp3\decodeMPEGaudioHeader(), GetId3\Write\Apetag\DeleteAPEtag(), GetId3\Write\Lyrics3\DeleteLyrics3(), GetId3\Module\AudioVideo\Matroska\EnsureBufferHasEnoughData(), GetId3\Module\Audio\Mp3\FreeFormatFrameLength(), GetId3\Module\Audio\Aac\getAACADIFheaderFilepointer(), GetId3\Module\Audio\Aac\getAACADTSheaderFilepointer(), GetId3\Module\Audio\Mod\getITheaderFilepointer(), GetId3\Module\Graphic\Gif\GetLSBits(), GetId3\Module\Tag\Lyrics3\getLyrics3Data(), GetId3\Module\Audio\Mod\getMODheaderFilepointer(), GetId3\Module\AudioVideo\Nsv\getNSVfHeaderFilepointer(), GetId3\Module\AudioVideo\Nsv\getNSVsHeaderFilepointer(), GetId3\Module\Audio\Mp3\getOnlyMPEGaudioInfo(), GetId3\Module\Audio\Mp3\getOnlyMPEGaudioInfoBruteForce(), GetId3\Module\Audio\Mod\getS3MheaderFilepointer(), GetId3\Module\Audio\Mod\getXMheaderFilepointer(), GetId3\Module\Audio\Bonk\HandleBonkTags(), GetId3\Module\AudioVideo\Bink\ParseBink(), GetId3\Module\Misc\Iso\ParseDirectoryRecord(), GetId3\Module\Audio\Flac\parseMETAdata(), GetId3\Module\Audio\Mpc\ParseMPCsv6(), GetId3\Module\Audio\Mpc\ParseMPCsv7(), GetId3\Module\Audio\Mpc\ParseMPCsv8(), GetId3\Module\Audio\Ogg\ParseOggPageHeader(), GetId3\Module\Audio\Optimfrog\ParseOptimFROGheader42(), GetId3\Module\Audio\Optimfrog\ParseOptimFROGheader45(), GetId3\Module\Misc\Iso\ParsePathTable(), GetId3\Module\Audio\Flac\parsePICTURE(), GetId3\Module\AudioVideo\Riff\ParseRIFF(), GetId3\Module\Audio\Ogg\ParseVorbisComments(), GetId3\Write\Id3v1\RemoveID3v1(), GetId3\Write\Id3v2\RemoveID3v2(), GetId3\Handler\BaseHandler\saveAttachment(), GetId3\Write\Apetag\WriteAPEtag(), GetId3\Write\Id3v1\WriteID3v1(), GetId3\Write\Id3v2\WriteID3v2(), GetId3\Module\Archive\Zip\ZIPparseCentralDirectory(), GetId3\Module\Archive\Zip\ZIPparseEndOfCentralDirectory(), and GetId3\Module\Archive\Zip\ZIPparseLocalFileHeader().

131  {
132  if ($this->data_string_flag) {
133  $this->data_string_position += $bytes;
134 
135  return substr($this->data_string,
136  $this->data_string_position - $bytes, $bytes);
137  }
138 
139  return fread($this->getid3->fp, $bytes);
140  }
+ Here is the caller graph for this function:

◆ fseek()

GetId3\Handler\BaseHandler::fseek (   $bytes,
  $whence = SEEK_SET 
)
protected
Parameters
type$bytes
type$whence
Returns
int

Definition at line 148 of file BaseHandler.php.

Referenced by GetId3\Module\Audio\Avr\analyze(), GetId3\Module\Graphic\Svg\analyze(), GetId3\Module\Archive\Zip\analyze(), GetId3\Module\Audio\Aac\analyze(), GetId3\Module\Audio\Dss\analyze(), GetId3\Module\Audio\Dts\analyze(), GetId3\Module\Tag\Id3v1\analyze(), GetId3\Module\Audio\Mod\analyze(), GetId3\Module\Audio\Vqf\analyze(), GetId3\Module\Archive\Szip\analyze(), GetId3\Module\Graphic\Efax\analyze(), GetId3\Module\Graphic\Gif\analyze(), GetId3\Module\Audio\Mpc\analyze(), GetId3\Module\Graphic\Png\analyze(), GetId3\Module\Graphic\Tiff\analyze(), GetId3\Module\Misc\Exe\analyze(), GetId3\Module\Audio\Aa\analyze(), GetId3\Module\Misc\Iso\analyze(), GetId3\Module\Misc\Msoffice\analyze(), GetId3\Module\Audio\Rkau\analyze(), GetId3\Module\Audio\Tta\analyze(), GetId3\Module\Audio\Voc\analyze(), GetId3\Module\AudioVideo\Bink\analyze(), GetId3\Module\AudioVideo\Nsv\analyze(), GetId3\Module\Audio\Au\analyze(), GetId3\Module\Audio\Monkey\analyze(), GetId3\Module\AudioVideo\Ts\analyze(), GetId3\Module\Audio\Flac\analyze(), GetId3\Module\AudioVideo\Real\analyze(), GetId3\Module\Audio\Bonk\analyze(), GetId3\Module\Audio\Lpac\analyze(), GetId3\Module\Tag\Lyrics3\analyze(), GetId3\Module\Audio\La\analyze(), GetId3\Module\Audio\Wavpack\analyze(), GetId3\Module\Graphic\Pcd\analyze(), GetId3\Module\Audio\Optimfrog\analyze(), GetId3\Module\Audio\Shorten\analyze(), GetId3\Module\Graphic\Jpg\analyze(), GetId3\Module\AudioVideo\Swf\analyze(), GetId3\Module\Audio\Ogg\analyze(), GetId3\Module\Archive\Tar\analyze(), GetId3\Module\Audio\Midi\analyze(), GetId3\Module\Tag\Apetag\analyze(), GetId3\Module\Tag\Id3v2\analyze(), GetId3\Module\AudioVideo\Mpeg\analyze(), GetId3\Module\Graphic\Bmp\analyze(), GetId3\Module\Audio\Ac3\analyze(), GetId3\Module\AudioVideo\Riff\analyze(), GetId3\Module\AudioVideo\Quicktime\analyze(), GetId3\Module\Audio\Mp3\analyze(), GetId3\Module\AudioVideo\Flv\analyze(), GetId3\Module\AudioVideo\Asf\analyze(), GetId3\Module\Audio\Mp3\decodeMPEGaudioHeader(), GetId3\Write\Apetag\DeleteAPEtag(), GetId3\Write\Lyrics3\DeleteLyrics3(), GetId3\Module\AudioVideo\Matroska\EnsureBufferHasEnoughData(), GetId3\Module\Audio\Mp3\FreeFormatFrameLength(), GetId3\Module\Audio\Aac\getAACADIFheaderFilepointer(), GetId3\Module\Audio\Aac\getAACADTSheaderFilepointer(), GetId3\Module\Audio\Mod\getITheaderFilepointer(), GetId3\Module\Tag\Lyrics3\getLyrics3Data(), GetId3\Module\Audio\Mod\getMODheaderFilepointer(), GetId3\Module\AudioVideo\Nsv\getNSVfHeaderFilepointer(), GetId3\Module\AudioVideo\Nsv\getNSVsHeaderFilepointer(), GetId3\Module\Audio\Mp3\getOnlyMPEGaudioInfo(), GetId3\Module\Audio\Mp3\getOnlyMPEGaudioInfoBruteForce(), GetId3\Module\Audio\Mod\getS3MheaderFilepointer(), GetId3\Module\Audio\Mod\getXMheaderFilepointer(), GetId3\Module\Audio\Bonk\HandleBonkTags(), GetId3\Module\Misc\Iso\ParseDirectoryRecord(), GetId3\Module\Audio\Mpc\ParseMPCsv6(), GetId3\Module\Audio\Mpc\ParseMPCsv8(), GetId3\Module\Audio\Ogg\ParseOggPageHeader(), GetId3\Module\Audio\Optimfrog\ParseOptimFROGheader42(), GetId3\Module\Audio\Optimfrog\ParseOptimFROGheader45(), GetId3\Module\Misc\Iso\ParsePathTable(), GetId3\Module\AudioVideo\Riff\ParseRIFF(), GetId3\Module\Audio\Ogg\ParseVorbisComments(), GetId3\Write\Id3v1\RemoveID3v1(), GetId3\Write\Id3v2\RemoveID3v2(), GetId3\Handler\BaseHandler\saveAttachment(), GetId3\Write\Apetag\WriteAPEtag(), GetId3\Write\Id3v1\WriteID3v1(), GetId3\Write\Id3v2\WriteID3v2(), GetId3\Module\Archive\Zip\ZIPparseCentralDirectory(), GetId3\Module\Archive\Zip\ZIPparseEndOfCentralDirectory(), and GetId3\Module\Archive\Zip\ZIPparseLocalFileHeader().

149  {
150  if ($this->data_string_flag) {
151  switch ($whence) {
152  case SEEK_SET:
153  $this->data_string_position = $bytes;
154  break;
155 
156  case SEEK_CUR:
157  $this->data_string_position += $bytes;
158  break;
159 
160  case SEEK_END:
161  $this->data_string_position = $this->data_string_length + $bytes;
162  break;
163  }
164 
165  return 0;
166  }
167 
168  return fseek($this->getid3->fp, $bytes, $whence);
169  }
fseek($bytes, $whence=SEEK_SET)
+ Here is the caller graph for this function:

◆ ftell()

GetId3\Handler\BaseHandler::ftell ( )
protected
Returns
type

Definition at line 116 of file BaseHandler.php.

References GetId3\Handler\BaseHandler\$data_string_position.

Referenced by GetId3\Module\Audio\Vqf\analyze(), GetId3\Module\Graphic\Png\analyze(), GetId3\Module\Audio\Voc\analyze(), GetId3\Module\AudioVideo\Real\analyze(), GetId3\Module\Audio\Bonk\analyze(), GetId3\Module\Audio\Wavpack\analyze(), GetId3\Module\Audio\Ogg\analyze(), GetId3\Module\Tag\Apetag\analyze(), GetId3\Module\AudioVideo\Mpeg\analyze(), GetId3\Module\AudioVideo\Flv\analyze(), GetId3\Module\AudioVideo\Asf\analyze(), GetId3\Module\Audio\Mp3\getOnlyMPEGaudioInfo(), GetId3\Module\Audio\Mp3\getOnlyMPEGaudioInfoBruteForce(), GetId3\Module\Audio\Flac\parseMETAdata(), GetId3\Module\Audio\Mpc\ParseMPCsv8(), GetId3\Module\Audio\Ogg\ParseOggPageHeader(), GetId3\Module\Audio\Optimfrog\ParseOptimFROGheader45(), GetId3\Module\Audio\Flac\parsePICTURE(), GetId3\Module\AudioVideo\Riff\ParseRIFF(), GetId3\Module\Audio\Ogg\ParseVorbisComments(), GetId3\Write\Apetag\WriteAPEtag(), GetId3\Module\Archive\Zip\ZIPparseCentralDirectory(), GetId3\Module\Archive\Zip\ZIPparseEndOfCentralDirectory(), and GetId3\Module\Archive\Zip\ZIPparseLocalFileHeader().

117  {
118  if ($this->data_string_flag) {
120  }
121 
122  return ftell($this->getid3->fp);
123  }
+ Here is the caller graph for this function:

◆ isDependencyFor()

GetId3\Handler\BaseHandler::isDependencyFor (   $module)
finalprotected
Parameters
type$module
Returns
type

Definition at line 189 of file BaseHandler.php.

Referenced by GetId3\Module\Audio\Dts\analyze(), GetId3\Module\Audio\Ac3\analyze(), GetId3\Module\Audio\Flac\parseMETAdata(), GetId3\Module\Audio\Flac\parseSTREAMINFO(), and GetId3\Module\Audio\Flac\parseVORBIS_COMMENT().

190  {
191  return $this->dependency_to == $module;
192  }
+ Here is the caller graph for this function:

◆ saveAttachment()

GetId3\Handler\BaseHandler::saveAttachment ( $ThisFileInfoIndex,
  $filename,
  $offset,
  $length 
)
Parameters
type$ThisFileInfoIndex
type$filename
type$offset
type$length
Returns
boolean
Exceptions
Exception

Definition at line 225 of file BaseHandler.php.

References $filename, array, GetId3\Handler\BaseHandler\fread(), GetId3\Handler\BaseHandler\fseek(), GetId3\Lib\Helper\intValueSupported(), and GetId3\Handler\BaseHandler\warning().

Referenced by GetId3\Module\AudioVideo\Matroska\parseEBML(), and GetId3\Module\Audio\Flac\parsePICTURE().

227  {
228  try {
229  if (!Helper::intValueSupported($offset + $length)) {
230  throw new DefaultException('it extends beyond the ' . round(PHP_INT_MAX / 1073741824) . 'GB limit');
231  }
232 
233  // do not extract at all
234  if ($this->getid3->option_save_attachments === self::ATTACHMENTS_NONE) {
235  unset($ThisFileInfoIndex); // do not set any
236  }
237 
238  // extract to return array
239  else if ($this->getid3->option_save_attachments === self::ATTACHMENTS_INLINE) {
240 
241  // get whole data in one pass, till it is anyway stored in memory
242  $this->fseek($offset);
243  $ThisFileInfoIndex = $this->fread($length);
244  if ($ThisFileInfoIndex === false || strlen($ThisFileInfoIndex) != $length) { // verify
245  throw new DefaultException('failed to read attachment data');
246  }
247  }
248 
249  // assume directory path is given
250  else {
251 
252  // set up destination path
253  $dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR,
254  $this->getid3->option_save_attachments),
255  DIRECTORY_SEPARATOR);
256  if (!is_dir($dir) || !is_writable($dir)) { // check supplied directory
257  throw new DefaultException('supplied path (' . $dir . ') does not exist, or is not writable');
258  }
259  $dest = $dir . DIRECTORY_SEPARATOR . $filename;
260 
261  // create dest file
262  if (($fp_dest = fopen($dest, 'wb')) == false) {
263  throw new DefaultException('failed to create file ' . $dest);
264  }
265 
266  // copy data
267  $this->fseek($offset);
268  $buffersize = ($this->data_string_flag ? $length : $this->getid3->fread_buffer_size());
269  $bytesleft = $length;
270  while ($bytesleft > 0) {
271  if (($buffer = $this->fread(min($buffersize, $bytesleft))) === false || ($byteswritten = fwrite($fp_dest,
272  $buffer)) === false) {
273  fclose($fp_dest);
274  unlink($dest);
275  throw new DefaultException($buffer === false ? 'not enough data to read' : 'failed to write to destination file, may be not enough disk space');
276  }
277  $bytesleft -= $byteswritten;
278  }
279 
280  fclose($fp_dest);
281  $ThisFileInfoIndex = $dest;
282  }
283  } catch (DefaultException $e) {
284 
285  unset($ThisFileInfoIndex); // do not set any is case of error
286  $this->warning('Failed to extract attachment ' . $filename . ': ' . $e->getMessage());
287 
288  return false;
289  }
290 
291  return true;
292  }
fseek($bytes, $whence=SEEK_SET)
Create styles array
The data for the language used.
static intValueSupported($num)
null $hasINT64
Definition: Helper.php:130
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ warning()

GetId3\Handler\BaseHandler::warning (   $text)
protected
Parameters
type$text
Returns
type

Definition at line 211 of file BaseHandler.php.

References $text.

Referenced by GetId3\Module\Audio\Flac\parseMETAdata(), GetId3\Module\Audio\Flac\parseSTREAMINFO(), and GetId3\Handler\BaseHandler\saveAttachment().

212  {
213  return $this->getid3->warning($text);
214  }
$text
+ Here is the caller graph for this function:

Field Documentation

◆ $data_string

GetId3\Handler\BaseHandler::$data_string = ''
protected

Definition at line 46 of file BaseHandler.php.

Referenced by GetId3\Module\Audio\Flac\parseVORBIS_COMMENT().

◆ $data_string_flag

GetId3\Handler\BaseHandler::$data_string_flag = false
protected

Definition at line 39 of file BaseHandler.php.

◆ $data_string_length

GetId3\Handler\BaseHandler::$data_string_length = 0
protected

Definition at line 60 of file BaseHandler.php.

Referenced by GetId3\Handler\BaseHandler\feof().

◆ $data_string_position

GetId3\Handler\BaseHandler::$data_string_position = 0
protected

Definition at line 53 of file BaseHandler.php.

Referenced by GetId3\Handler\BaseHandler\ftell().

◆ $dependency_to

GetId3\Handler\BaseHandler::$dependency_to
private

Definition at line 62 of file BaseHandler.php.

◆ $getid3

GetId3\Handler\BaseHandler::$getid3
protected

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