ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
getID3 Class Reference
+ Inheritance diagram for getID3:
+ Collaboration diagram for getID3:

Public Member Functions

 getID3 ()
 
 setOption ($optArray)
 
 analyze ($filename)
 
 error ($message)
 
 warning ($message)
 
 CleanUp ()
 
 GetFileFormatArray ()
 
 GetFileFormat (&$filedata, $filename='')
 
 CharConvert (&$array, $encoding)
 
 HandleAllTags ()
 
 getHashdata ($algorithm)
 
 ChannelsBitratePlaytimeCalculations ()
 
 CalculateCompressionRatioVideo ()
 
 CalculateCompressionRatioAudio ()
 
 CalculateReplayGain ()
 
 ProcessAudioStreams ()
 
 getid3_tempnam ()
 
 __construct ()
 
 version ()
 
 fread_buffer_size ()
 
 setOption ($optArray)
 
 openfile ($filename, $filesize=null)
 
 analyze ($filename, $filesize=null, $original_filename='')
 
 error ($message)
 
 warning ($message)
 
 GetFileFormatArray ()
 
 GetFileFormat (&$filedata, $filename='')
 
 CharConvert (&$array, $encoding)
 
 HandleAllTags ()
 
 getHashdata ($algorithm)
 
 ChannelsBitratePlaytimeCalculations ()
 
 CalculateCompressionRatioVideo ()
 
 CalculateCompressionRatioAudio ()
 
 CalculateReplayGain ()
 
 ProcessAudioStreams ()
 
 getid3_tempnam ()
 
 include_module ($name)
 

Data Fields

 $encoding = 'ISO-8859-1'
 
 $encoding_id3v1 = 'ISO-8859-1'
 
 $tempdir = '*'
 
 $option_tag_id3v1 = true
 
 $option_tag_id3v2 = true
 
 $option_tag_lyrics3 = true
 
 $option_tag_apetag = true
 
 $option_tags_process = true
 
 $option_tags_html = true
 
 $option_extra_info = true
 
 $option_md5_data = false
 
 $option_md5_data_source = false
 
 $option_sha1_data = false
 
 $option_max_2gb_check = true
 
 $filename
 
 $option_save_attachments = true
 
 $option_fread_buffer_size = 32768
 
 $fp
 
 $info
 
 $memory_limit = 0
 
const VERSION = '1.9.10-20150914'
 
const FREAD_BUFFER_SIZE = 32768
 
const ATTACHMENTS_NONE = false
 
const ATTACHMENTS_INLINE = true
 

Protected Attributes

 $startup_error = ''
 
 $startup_warning = ''
 

Private Member Functions

 CleanUp ()
 

Detailed Description

Definition at line 18 of file getid3.php.

Constructor & Destructor Documentation

◆ __construct()

getID3::__construct ( )

Definition at line 119 of file getid3.php.

References $filename, and warning().

119  {
120 
121  // Check for PHP version
122  $required_php_version = '5.3.0';
123  if (version_compare(PHP_VERSION, $required_php_version, '<')) {
124  $this->startup_error .= 'getID3() requires PHP v'.$required_php_version.' or higher - you are running v'.PHP_VERSION;
125  return false;
126  }
127 
128  // Check memory
129  $this->memory_limit = ini_get('memory_limit');
130  if (preg_match('#([0-9]+)M#i', $this->memory_limit, $matches)) {
131  // could be stored as "16M" rather than 16777216 for example
132  $this->memory_limit = $matches[1] * 1048576;
133  } elseif (preg_match('#([0-9]+)G#i', $this->memory_limit, $matches)) { // The 'G' modifier is available since PHP 5.1.0
134  // could be stored as "2G" rather than 2147483648 for example
135  $this->memory_limit = $matches[1] * 1073741824;
136  }
137  if ($this->memory_limit <= 0) {
138  // memory limits probably disabled
139  } elseif ($this->memory_limit <= 4194304) {
140  $this->startup_error .= 'PHP has less than 4MB available memory and will very likely run out. Increase memory_limit in php.ini';
141  } elseif ($this->memory_limit <= 12582912) {
142  $this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini';
143  }
144 
145  // Check safe_mode off
146  if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
147  $this->warning('WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.');
148  }
149 
150  if (intval(ini_get('mbstring.func_overload')) > 0) {
151  $this->warning('WARNING: php.ini contains "mbstring.func_overload = '.ini_get('mbstring.func_overload').'", this may break things.');
152  }
153 
154  // Check for magic_quotes_runtime
155  if (function_exists('get_magic_quotes_runtime')) {
156  if (get_magic_quotes_runtime()) {
157  return $this->startup_error('magic_quotes_runtime must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_runtime(0) and set_magic_quotes_runtime(1).');
158  }
159  }
160 
161  // Check for magic_quotes_gpc
162  if (function_exists('magic_quotes_gpc')) {
163  if (get_magic_quotes_gpc()) {
164  return $this->startup_error('magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).');
165  }
166  }
167 
168  // Load support library
169  if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
170  $this->startup_error .= 'getid3.lib.php is missing or corrupt';
171  }
172 
173  if ($this->option_max_2gb_check === null) {
174  $this->option_max_2gb_check = (PHP_INT_MAX <= 2147483647);
175  }
176 
177 
178  // Needed for Windows only:
179  // Define locations of helper applications for Shorten, VorbisComment, MetaFLAC
180  // as well as other helper functions such as head, tail, md5sum, etc
181  // This path cannot contain spaces, but the below code will attempt to get the
182  // 8.3-equivalent path automatically
183  // IMPORTANT: This path must include the trailing slash
184  if (GETID3_OS_ISWINDOWS && !defined('GETID3_HELPERAPPSDIR')) {
185 
186  $helperappsdir = GETID3_INCLUDEPATH.'..'.DIRECTORY_SEPARATOR.'helperapps'; // must not have any space in this path
187 
188  if (!is_dir($helperappsdir)) {
189  $this->startup_warning .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist';
190  } elseif (strpos(realpath($helperappsdir), ' ') !== false) {
191  $DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir));
192  $path_so_far = array();
193  foreach ($DirPieces as $key => $value) {
194  if (strpos($value, ' ') !== false) {
195  if (!empty($path_so_far)) {
196  $commandline = 'dir /x '.escapeshellarg(implode(DIRECTORY_SEPARATOR, $path_so_far));
197  $dir_listing = `$commandline`;
198  $lines = explode("\n", $dir_listing);
199  foreach ($lines as $line) {
200  $line = trim($line);
201  if (preg_match('#^([0-9/]{10}) +([0-9:]{4,5}( [AP]M)?) +(<DIR>|[0-9,]+) +([^ ]{0,11}) +(.+)$#', $line, $matches)) {
202  list($dummy, $date, $time, $ampm, $filesize, $shortname, $filename) = $matches;
203  if ((strtoupper($filesize) == '<DIR>') && (strtolower($filename) == strtolower($value))) {
204  $value = $shortname;
205  }
206  }
207  }
208  } else {
209  $this->startup_warning .= 'GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary. You can run "dir /x" from the commandline to see the correct 8.3-style names.';
210  }
211  }
212  $path_so_far[] = $value;
213  }
214  $helperappsdir = implode(DIRECTORY_SEPARATOR, $path_so_far);
215  }
216  define('GETID3_HELPERAPPSDIR', $helperappsdir.DIRECTORY_SEPARATOR);
217  }
218 
219  return true;
220  }
warning($message)
Definition: getid3.php:411
$filename
Definition: getid3.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ analyze() [1/2]

getID3::analyze (   $filename)

Definition at line 168 of file getid3.php.

References $encoding, $fp, $header, $info, getid3_lib\BigEndian2Int(), CalculateCompressionRatioAudio(), CalculateCompressionRatioVideo(), CalculateReplayGain(), ChannelsBitratePlaytimeCalculations(), CleanUp(), error(), GetFileFormat(), getHashdata(), GETID3_VERSION, HandleAllTags(), getid3_lib\IncludeDependency(), ProcessAudioStreams(), and warning().

Referenced by getid3_write_apetag\DeleteAPEtag(), getid3_write_lyrics3\DeleteLyrics3(), getid3_write_id3v1\FixID3v1Padding(), getid3_write_id3v2\RemoveID3v2(), getid3_write_real\RemoveReal(), getid3_write_id3v1\setRealFileSize(), getid3_write_apetag\WriteAPEtag(), getid3_write_id3v2\WriteID3v2(), and getid3_write_real\WriteReal().

168  {
169 
170  if (!empty($this->startup_error)) {
171  return $this->error($this->startup_error);
172  }
173  if (!empty($this->startup_warning)) {
174  $this->warning($this->startup_warning);
175  }
176 
177  // init result array and set parameters
178  $this->info = array();
179  $this->info['GETID3_VERSION'] = GETID3_VERSION;
180 
181  // Check encoding/iconv support
182  if (!function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
183  $errormessage = 'iconv() support is needed for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
184  if (GETID3_OS_ISWINDOWS) {
185  $errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
186  } else {
187  $errormessage .= 'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
188  }
189  return $this->error($errormessage);
190  }
191 
192  // Disable magic_quotes_runtime, if neccesary
193  $old_magic_quotes_runtime = get_magic_quotes_runtime(); // store current setting of magic_quotes_runtime
194  if ($old_magic_quotes_runtime) {
195  set_magic_quotes_runtime(0); // turn off magic_quotes_runtime
196  if (get_magic_quotes_runtime()) {
197  return $this->error('Could not disable magic_quotes_runtime - getID3() cannot work properly with this setting enabled');
198  }
199  }
200 
201  // remote files not supported
202  if (preg_match('/^(ht|f)tp:\/\//', $filename)) {
203  return $this->error('Remote files are not supported in this version of getID3() - please copy the file locally first');
204  }
205 
206  // open local file
207  if (!$fp = @fopen($filename, 'rb')) {
208  return $this->error('Could not open file "'.$filename.'"');
209  }
210 
211  // set parameters
212  $this->info['filesize'] = filesize($filename);
213 
214  // option_max_2gb_check
215  if ($this->option_max_2gb_check) {
216  // PHP doesn't support integers larger than 31-bit (~2GB)
217  // filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
218  // ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
219  fseek($fp, 0, SEEK_END);
220  if ((($this->info['filesize'] != 0) && (ftell($fp) == 0)) ||
221  ($this->info['filesize'] < 0) ||
222  (ftell($fp) < 0)) {
223  unset($this->info['filesize']);
224  fclose($fp);
225  return $this->error('File is most likely larger than 2GB and is not supported by PHP');
226  }
227  }
228 
229  // set more parameters
230  $this->info['avdataoffset'] = 0;
231  $this->info['avdataend'] = $this->info['filesize'];
232  $this->info['fileformat'] = ''; // filled in later
233  $this->info['audio']['dataformat'] = ''; // filled in later, unset if not used
234  $this->info['video']['dataformat'] = ''; // filled in later, unset if not used
235  $this->info['tags'] = array(); // filled in later, unset if not used
236  $this->info['error'] = array(); // filled in later, unset if not used
237  $this->info['warning'] = array(); // filled in later, unset if not used
238  $this->info['comments'] = array(); // filled in later, unset if not used
239  $this->info['encoding'] = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired
240 
241  // set redundant parameters - might be needed in some include file
242  $this->info['filename'] = basename($filename);
243  $this->info['filepath'] = str_replace('\\', '/', realpath(dirname($filename)));
244  $this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename'];
245 
246 
247  // handle ID3v2 tag - done first - already at beginning of file
248  // ID3v2 detection (even if not parsing) is always done otherwise fileformat is much harder to detect
249  if ($this->option_tag_id3v2) {
250 
251  $GETID3_ERRORARRAY = &$this->info['warning'];
252  if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, false)) {
253  $tag = new getid3_id3v2($fp, $this->info);
254  }
255 
256  } else {
257 
258  fseek($fp, 0, SEEK_SET);
259  $header = fread($fp, 10);
260  if (substr($header, 0, 3) == 'ID3') {
261  $this->info['id3v2']['header'] = true;
262  $this->info['id3v2']['majorversion'] = ord($header{3});
263  $this->info['id3v2']['minorversion'] = ord($header{4});
264  $this->info['id3v2']['headerlength'] = getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length
265 
266  $this->info['id3v2']['tag_offset_start'] = 0;
267  $this->info['id3v2']['tag_offset_end'] = $this->info['id3v2']['tag_offset_start'] + $this->info['id3v2']['headerlength'];
268  $this->info['avdataoffset'] = $this->info['id3v2']['tag_offset_end'];
269  }
270 
271  }
272 
273 
274  // handle ID3v1 tag
275  if ($this->option_tag_id3v1) {
276  if (!@include_once(GETID3_INCLUDEPATH.'module.tag.id3v1.php')) {
277  return $this->error('module.tag.id3v1.php is missing - you may disable option_tag_id3v1.');
278  }
279  $tag = new getid3_id3v1($fp, $this->info);
280  }
281 
282  // handle APE tag
283  if ($this->option_tag_apetag) {
284  if (!@include_once(GETID3_INCLUDEPATH.'module.tag.apetag.php')) {
285  return $this->error('module.tag.apetag.php is missing - you may disable option_tag_apetag.');
286  }
287  $tag = new getid3_apetag($fp, $this->info);
288  }
289 
290  // handle lyrics3 tag
291  if ($this->option_tag_lyrics3) {
292  if (!@include_once(GETID3_INCLUDEPATH.'module.tag.lyrics3.php')) {
293  return $this->error('module.tag.lyrics3.php is missing - you may disable option_tag_lyrics3.');
294  }
295  $tag = new getid3_lyrics3($fp, $this->info);
296  }
297 
298  // read 32 kb file data
299  fseek($fp, $this->info['avdataoffset'], SEEK_SET);
300  $formattest = fread($fp, 32774);
301 
302  // determine format
303  $determined_format = $this->GetFileFormat($formattest, $filename);
304 
305  // unable to determine file format
306  if (!$determined_format) {
307  fclose($fp);
308  return $this->error('unable to determine file format');
309  }
310 
311  // check for illegal ID3 tags
312  if (isset($determined_format['fail_id3']) && (in_array('id3v1', $this->info['tags']) || in_array('id3v2', $this->info['tags']))) {
313  if ($determined_format['fail_id3'] === 'ERROR') {
314  fclose($fp);
315  return $this->error('ID3 tags not allowed on this file type.');
316  } elseif ($determined_format['fail_id3'] === 'WARNING') {
317  $this->info['warning'][] = 'ID3 tags not allowed on this file type.';
318  }
319  }
320 
321  // check for illegal APE tags
322  if (isset($determined_format['fail_ape']) && in_array('ape', $this->info['tags'])) {
323  if ($determined_format['fail_ape'] === 'ERROR') {
324  fclose($fp);
325  return $this->error('APE tags not allowed on this file type.');
326  } elseif ($determined_format['fail_ape'] === 'WARNING') {
327  $this->info['warning'][] = 'APE tags not allowed on this file type.';
328  }
329  }
330 
331  // set mime type
332  $this->info['mime_type'] = $determined_format['mime_type'];
333 
334  // supported format signature pattern detected, but module deleted
335  if (!file_exists(GETID3_INCLUDEPATH.$determined_format['include'])) {
336  fclose($fp);
337  return $this->error('Format not supported, module, '.$determined_format['include'].', was removed.');
338  }
339 
340  // module requires iconv support
341  if (!function_exists('iconv') && @$determined_format['iconv_req']) {
342  return $this->error('iconv support is required for this module ('.$determined_format['include'].').');
343  }
344 
345  // include module
346  include_once(GETID3_INCLUDEPATH.$determined_format['include']);
347 
348  // instantiate module class
349  $class_name = 'getid3_'.$determined_format['module'];
350  if (!class_exists($class_name)) {
351  return $this->error('Format not supported, module, '.$determined_format['include'].', is corrupt.');
352  }
353  if (isset($determined_format['option'])) {
354  $class = new $class_name($fp, $this->info, $determined_format['option']);
355  } else {
356  $class = new $class_name($fp, $this->info);
357  }
358 
359  // close file
360  fclose($fp);
361 
362  // process all tags - copy to 'tags' and convert charsets
363  if ($this->option_tags_process) {
364  $this->HandleAllTags();
365  }
366 
367  // perform more calculations
368  if ($this->option_extra_info) {
372  $this->CalculateReplayGain();
373  $this->ProcessAudioStreams();
374  }
375 
376  // get the MD5 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
377  if ($this->option_md5_data) {
378  // do not cald md5_data if md5_data_source is present - set by flac only - future MPC/SV8 too
379  if (!$this->option_md5_data_source || empty($this->info['md5_data_source'])) {
380  $this->getHashdata('md5');
381  }
382  }
383 
384  // get the SHA1 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
385  if ($this->option_sha1_data) {
386  $this->getHashdata('sha1');
387  }
388 
389  // remove undesired keys
390  $this->CleanUp();
391 
392  // restore magic_quotes_runtime setting
393  set_magic_quotes_runtime($old_magic_quotes_runtime);
394 
395  // return info array
396  return $this->info;
397  }
getID3() by James Heinrich info@getid3.org //
GetFileFormat(&$filedata, $filename='')
Definition: getid3.php:918
warning($message)
Definition: getid3.php:411
HandleAllTags()
Definition: getid3.php:973
$filename
Definition: getid3.php:46
const GETID3_VERSION
getID3() by James Heinrich info@getid3.org //
Definition: getid3.php:13
CalculateCompressionRatioAudio()
Definition: getid3.php:1249
getID3() by James Heinrich info@getid3.org //
CleanUp()
Definition: getid3.php:418
$header
CalculateReplayGain()
Definition: getid3.php:1266
ProcessAudioStreams()
Definition: getid3.php:1286
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
$encoding
Definition: getid3.php:21
getID3() by James Heinrich info@getid3.org //
CalculateCompressionRatioVideo()
Definition: getid3.php:1201
ChannelsBitratePlaytimeCalculations()
Definition: getid3.php:1168
IncludeDependency($filename, $sourcefile, $DieOnFailure=false)
error($message)
Definition: getid3.php:401
getHashdata($algorithm)
Definition: getid3.php:1043
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ analyze() [2/2]

getID3::analyze (   $filename,
  $filesize = null,
  $original_filename = '' 
)

Definition at line 345 of file getid3.php.

References $filename, $header, $info, getid3_lib\BigEndian2Int(), CalculateCompressionRatioAudio(), CalculateCompressionRatioVideo(), CalculateReplayGain(), ChannelsBitratePlaytimeCalculations(), CleanUp(), error(), GetFileFormat(), getHashdata(), HandleAllTags(), include_module(), openfile(), ProcessAudioStreams(), and warning().

345  {
346  try {
347  if (!$this->openfile($filename, $filesize)) {
348  return $this->info;
349  }
350 
351  // Handle tags
352  foreach (array('id3v2'=>'id3v2', 'id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) {
353  $option_tag = 'option_tag_'.$tag_name;
354  if ($this->$option_tag) {
355  $this->include_module('tag.'.$tag_name);
356  try {
357  $tag_class = 'getid3_'.$tag_name;
358  $tag = new $tag_class($this);
359  $tag->Analyze();
360  }
361  catch (getid3_exception $e) {
362  throw $e;
363  }
364  }
365  }
366  if (isset($this->info['id3v2']['tag_offset_start'])) {
367  $this->info['avdataoffset'] = max($this->info['avdataoffset'], $this->info['id3v2']['tag_offset_end']);
368  }
369  foreach (array('id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) {
370  if (isset($this->info[$tag_key]['tag_offset_start'])) {
371  $this->info['avdataend'] = min($this->info['avdataend'], $this->info[$tag_key]['tag_offset_start']);
372  }
373  }
374 
375  // ID3v2 detection (NOT parsing), even if ($this->option_tag_id3v2 == false) done to make fileformat easier
376  if (!$this->option_tag_id3v2) {
377  fseek($this->fp, 0);
378  $header = fread($this->fp, 10);
379  if ((substr($header, 0, 3) == 'ID3') && (strlen($header) == 10)) {
380  $this->info['id3v2']['header'] = true;
381  $this->info['id3v2']['majorversion'] = ord($header{3});
382  $this->info['id3v2']['minorversion'] = ord($header{4});
383  $this->info['avdataoffset'] += getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length
384  }
385  }
386 
387  // read 32 kb file data
388  fseek($this->fp, $this->info['avdataoffset']);
389  $formattest = fread($this->fp, 32774);
390 
391  // determine format
392  $determined_format = $this->GetFileFormat($formattest, ($original_filename ? $original_filename : $filename));
393 
394  // unable to determine file format
395  if (!$determined_format) {
396  fclose($this->fp);
397  return $this->error('unable to determine file format');
398  }
399 
400  // check for illegal ID3 tags
401  if (isset($determined_format['fail_id3']) && (in_array('id3v1', $this->info['tags']) || in_array('id3v2', $this->info['tags']))) {
402  if ($determined_format['fail_id3'] === 'ERROR') {
403  fclose($this->fp);
404  return $this->error('ID3 tags not allowed on this file type.');
405  } elseif ($determined_format['fail_id3'] === 'WARNING') {
406  $this->warning('ID3 tags not allowed on this file type.');
407  }
408  }
409 
410  // check for illegal APE tags
411  if (isset($determined_format['fail_ape']) && in_array('ape', $this->info['tags'])) {
412  if ($determined_format['fail_ape'] === 'ERROR') {
413  fclose($this->fp);
414  return $this->error('APE tags not allowed on this file type.');
415  } elseif ($determined_format['fail_ape'] === 'WARNING') {
416  $this->warning('APE tags not allowed on this file type.');
417  }
418  }
419 
420  // set mime type
421  $this->info['mime_type'] = $determined_format['mime_type'];
422 
423  // supported format signature pattern detected, but module deleted
424  if (!file_exists(GETID3_INCLUDEPATH.$determined_format['include'])) {
425  fclose($this->fp);
426  return $this->error('Format not supported, module "'.$determined_format['include'].'" was removed.');
427  }
428 
429  // module requires iconv support
430  // Check encoding/iconv support
431  if (!empty($determined_format['iconv_req']) && !function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
432  $errormessage = 'iconv() support is required for this module ('.$determined_format['include'].') for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
433  if (GETID3_OS_ISWINDOWS) {
434  $errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
435  } else {
436  $errormessage .= 'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
437  }
438  return $this->error($errormessage);
439  }
440 
441  // include module
442  include_once(GETID3_INCLUDEPATH.$determined_format['include']);
443 
444  // instantiate module class
445  $class_name = 'getid3_'.$determined_format['module'];
446  if (!class_exists($class_name)) {
447  return $this->error('Format not supported, module "'.$determined_format['include'].'" is corrupt.');
448  }
449  $class = new $class_name($this);
450  $class->Analyze();
451  unset($class);
452 
453  // close file
454  fclose($this->fp);
455 
456  // process all tags - copy to 'tags' and convert charsets
457  if ($this->option_tags_process) {
458  $this->HandleAllTags();
459  }
460 
461  // perform more calculations
462  if ($this->option_extra_info) {
466  $this->CalculateReplayGain();
467  $this->ProcessAudioStreams();
468  }
469 
470  // get the MD5 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
471  if ($this->option_md5_data) {
472  // do not calc md5_data if md5_data_source is present - set by flac only - future MPC/SV8 too
473  if (!$this->option_md5_data_source || empty($this->info['md5_data_source'])) {
474  $this->getHashdata('md5');
475  }
476  }
477 
478  // get the SHA1 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
479  if ($this->option_sha1_data) {
480  $this->getHashdata('sha1');
481  }
482 
483  // remove undesired keys
484  $this->CleanUp();
485 
486  } catch (Exception $e) {
487  $this->error('Caught exception: '.$e->getMessage());
488  }
489 
490  // return info array
491  return $this->info;
492  }
GetFileFormat(&$filedata, $filename='')
Definition: getid3.php:918
warning($message)
Definition: getid3.php:411
HandleAllTags()
Definition: getid3.php:973
$filename
Definition: getid3.php:46
CalculateCompressionRatioAudio()
Definition: getid3.php:1249
include_module($name)
Definition: getid3.php:1606
CleanUp()
Definition: getid3.php:418
$header
CalculateReplayGain()
Definition: getid3.php:1266
ProcessAudioStreams()
Definition: getid3.php:1286
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
CalculateCompressionRatioVideo()
Definition: getid3.php:1201
openfile($filename, $filesize=null)
Definition: getid3.php:246
ChannelsBitratePlaytimeCalculations()
Definition: getid3.php:1168
error($message)
Definition: getid3.php:401
getHashdata($algorithm)
Definition: getid3.php:1043
+ Here is the call graph for this function:

◆ CalculateCompressionRatioAudio() [1/2]

getID3::CalculateCompressionRatioAudio ( )

Definition at line 1249 of file getid3.php.

Referenced by analyze().

1249  {
1250  if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate'])) {
1251  return false;
1252  }
1253  $this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
1254 
1255  if (!empty($this->info['audio']['streams'])) {
1256  foreach ($this->info['audio']['streams'] as $streamnumber => $streamdata) {
1257  if (!empty($streamdata['bitrate']) && !empty($streamdata['channels']) && !empty($streamdata['sample_rate'])) {
1258  $this->info['audio']['streams'][$streamnumber]['compression_ratio'] = $streamdata['bitrate'] / ($streamdata['channels'] * $streamdata['sample_rate'] * (!empty($streamdata['bits_per_sample']) ? $streamdata['bits_per_sample'] : 16));
1259  }
1260  }
1261  }
1262  return true;
1263  }
+ Here is the caller graph for this function:

◆ CalculateCompressionRatioAudio() [2/2]

getID3::CalculateCompressionRatioAudio ( )

Definition at line 1550 of file getid3.php.

1550  {
1551  if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate']) || !is_numeric($this->info['audio']['sample_rate'])) {
1552  return false;
1553  }
1554  $this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
1555 
1556  if (!empty($this->info['audio']['streams'])) {
1557  foreach ($this->info['audio']['streams'] as $streamnumber => $streamdata) {
1558  if (!empty($streamdata['bitrate']) && !empty($streamdata['channels']) && !empty($streamdata['sample_rate'])) {
1559  $this->info['audio']['streams'][$streamnumber]['compression_ratio'] = $streamdata['bitrate'] / ($streamdata['channels'] * $streamdata['sample_rate'] * (!empty($streamdata['bits_per_sample']) ? $streamdata['bits_per_sample'] : 16));
1560  }
1561  }
1562  }
1563  return true;
1564  }

◆ CalculateCompressionRatioVideo() [1/2]

getID3::CalculateCompressionRatioVideo ( )

Definition at line 1201 of file getid3.php.

Referenced by analyze().

1201  {
1202  if (empty($this->info['video'])) {
1203  return false;
1204  }
1205  if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) {
1206  return false;
1207  }
1208  if (empty($this->info['video']['bits_per_sample'])) {
1209  return false;
1210  }
1211 
1212  switch ($this->info['video']['dataformat']) {
1213  case 'bmp':
1214  case 'gif':
1215  case 'jpeg':
1216  case 'jpg':
1217  case 'png':
1218  case 'tiff':
1219  $FrameRate = 1;
1220  $PlaytimeSeconds = 1;
1221  $BitrateCompressed = $this->info['filesize'] * 8;
1222  break;
1223 
1224  default:
1225  if (!empty($this->info['video']['frame_rate'])) {
1226  $FrameRate = $this->info['video']['frame_rate'];
1227  } else {
1228  return false;
1229  }
1230  if (!empty($this->info['playtime_seconds'])) {
1231  $PlaytimeSeconds = $this->info['playtime_seconds'];
1232  } else {
1233  return false;
1234  }
1235  if (!empty($this->info['video']['bitrate'])) {
1236  $BitrateCompressed = $this->info['video']['bitrate'];
1237  } else {
1238  return false;
1239  }
1240  break;
1241  }
1242  $BitrateUncompressed = $this->info['video']['resolution_x'] * $this->info['video']['resolution_y'] * $this->info['video']['bits_per_sample'] * $FrameRate;
1243 
1244  $this->info['video']['compression_ratio'] = $BitrateCompressed / $BitrateUncompressed;
1245  return true;
1246  }
+ Here is the caller graph for this function:

◆ CalculateCompressionRatioVideo() [2/2]

getID3::CalculateCompressionRatioVideo ( )

Definition at line 1502 of file getid3.php.

1502  {
1503  if (empty($this->info['video'])) {
1504  return false;
1505  }
1506  if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) {
1507  return false;
1508  }
1509  if (empty($this->info['video']['bits_per_sample'])) {
1510  return false;
1511  }
1512 
1513  switch ($this->info['video']['dataformat']) {
1514  case 'bmp':
1515  case 'gif':
1516  case 'jpeg':
1517  case 'jpg':
1518  case 'png':
1519  case 'tiff':
1520  $FrameRate = 1;
1521  $PlaytimeSeconds = 1;
1522  $BitrateCompressed = $this->info['filesize'] * 8;
1523  break;
1524 
1525  default:
1526  if (!empty($this->info['video']['frame_rate'])) {
1527  $FrameRate = $this->info['video']['frame_rate'];
1528  } else {
1529  return false;
1530  }
1531  if (!empty($this->info['playtime_seconds'])) {
1532  $PlaytimeSeconds = $this->info['playtime_seconds'];
1533  } else {
1534  return false;
1535  }
1536  if (!empty($this->info['video']['bitrate'])) {
1537  $BitrateCompressed = $this->info['video']['bitrate'];
1538  } else {
1539  return false;
1540  }
1541  break;
1542  }
1543  $BitrateUncompressed = $this->info['video']['resolution_x'] * $this->info['video']['resolution_y'] * $this->info['video']['bits_per_sample'] * $FrameRate;
1544 
1545  $this->info['video']['compression_ratio'] = $BitrateCompressed / $BitrateUncompressed;
1546  return true;
1547  }

◆ CalculateReplayGain() [1/2]

getID3::CalculateReplayGain ( )

Definition at line 1266 of file getid3.php.

References getid3_lib\RGADamplitude2dB().

Referenced by analyze().

1266  {
1267  if (isset($this->info['replay_gain'])) {
1268  $this->info['replay_gain']['reference_volume'] = 89;
1269  if (isset($this->info['replay_gain']['track']['adjustment'])) {
1270  $this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment'];
1271  }
1272  if (isset($this->info['replay_gain']['album']['adjustment'])) {
1273  $this->info['replay_gain']['album']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['album']['adjustment'];
1274  }
1275 
1276  if (isset($this->info['replay_gain']['track']['peak'])) {
1277  $this->info['replay_gain']['track']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['track']['peak']);
1278  }
1279  if (isset($this->info['replay_gain']['album']['peak'])) {
1280  $this->info['replay_gain']['album']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['album']['peak']);
1281  }
1282  }
1283  return true;
1284  }
RGADamplitude2dB($amplitude)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalculateReplayGain() [2/2]

getID3::CalculateReplayGain ( )

Definition at line 1567 of file getid3.php.

References getid3_lib\RGADamplitude2dB().

1567  {
1568  if (isset($this->info['replay_gain'])) {
1569  if (!isset($this->info['replay_gain']['reference_volume'])) {
1570  $this->info['replay_gain']['reference_volume'] = (double) 89.0;
1571  }
1572  if (isset($this->info['replay_gain']['track']['adjustment'])) {
1573  $this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment'];
1574  }
1575  if (isset($this->info['replay_gain']['album']['adjustment'])) {
1576  $this->info['replay_gain']['album']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['album']['adjustment'];
1577  }
1578 
1579  if (isset($this->info['replay_gain']['track']['peak'])) {
1580  $this->info['replay_gain']['track']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['track']['peak']);
1581  }
1582  if (isset($this->info['replay_gain']['album']['peak'])) {
1583  $this->info['replay_gain']['album']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['album']['peak']);
1584  }
1585  }
1586  return true;
1587  }
RGADamplitude2dB($amplitude)
+ Here is the call graph for this function:

◆ ChannelsBitratePlaytimeCalculations() [1/2]

getID3::ChannelsBitratePlaytimeCalculations ( )

Definition at line 1168 of file getid3.php.

References getid3_lib\PlaytimeString().

Referenced by analyze().

1168  {
1169 
1170  // set channelmode on audio
1171  if (@$this->info['audio']['channels'] == '1') {
1172  $this->info['audio']['channelmode'] = 'mono';
1173  } elseif (@$this->info['audio']['channels'] == '2') {
1174  $this->info['audio']['channelmode'] = 'stereo';
1175  }
1176 
1177  // Calculate combined bitrate - audio + video
1178  $CombinedBitrate = 0;
1179  $CombinedBitrate += (isset($this->info['audio']['bitrate']) ? $this->info['audio']['bitrate'] : 0);
1180  $CombinedBitrate += (isset($this->info['video']['bitrate']) ? $this->info['video']['bitrate'] : 0);
1181  if (($CombinedBitrate > 0) && empty($this->info['bitrate'])) {
1182  $this->info['bitrate'] = $CombinedBitrate;
1183  }
1184  //if ((isset($this->info['video']) && !isset($this->info['video']['bitrate'])) || (isset($this->info['audio']) && !isset($this->info['audio']['bitrate']))) {
1185  // // for example, VBR MPEG video files cannot determine video bitrate:
1186  // // should not set overall bitrate and playtime from audio bitrate only
1187  // unset($this->info['bitrate']);
1188  //}
1189 
1190  if (!isset($this->info['playtime_seconds']) && !empty($this->info['bitrate'])) {
1191  $this->info['playtime_seconds'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['bitrate'];
1192  }
1193 
1194  // Set playtime string
1195  if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) {
1196  $this->info['playtime_string'] = getid3_lib::PlaytimeString($this->info['playtime_seconds']);
1197  }
1198  }
PlaytimeString($playtimeseconds)
Definition: getid3.lib.php:408
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ChannelsBitratePlaytimeCalculations() [2/2]

getID3::ChannelsBitratePlaytimeCalculations ( )

Definition at line 1437 of file getid3.php.

References getid3_lib\PlaytimeString().

1437  {
1438 
1439  // set channelmode on audio
1440  if (!empty($this->info['audio']['channelmode']) || !isset($this->info['audio']['channels'])) {
1441  // ignore
1442  } elseif ($this->info['audio']['channels'] == 1) {
1443  $this->info['audio']['channelmode'] = 'mono';
1444  } elseif ($this->info['audio']['channels'] == 2) {
1445  $this->info['audio']['channelmode'] = 'stereo';
1446  }
1447 
1448  // Calculate combined bitrate - audio + video
1449  $CombinedBitrate = 0;
1450  $CombinedBitrate += (isset($this->info['audio']['bitrate']) ? $this->info['audio']['bitrate'] : 0);
1451  $CombinedBitrate += (isset($this->info['video']['bitrate']) ? $this->info['video']['bitrate'] : 0);
1452  if (($CombinedBitrate > 0) && empty($this->info['bitrate'])) {
1453  $this->info['bitrate'] = $CombinedBitrate;
1454  }
1455  //if ((isset($this->info['video']) && !isset($this->info['video']['bitrate'])) || (isset($this->info['audio']) && !isset($this->info['audio']['bitrate']))) {
1456  // // for example, VBR MPEG video files cannot determine video bitrate:
1457  // // should not set overall bitrate and playtime from audio bitrate only
1458  // unset($this->info['bitrate']);
1459  //}
1460 
1461  // video bitrate undetermined, but calculable
1462  if (isset($this->info['video']['dataformat']) && $this->info['video']['dataformat'] && (!isset($this->info['video']['bitrate']) || ($this->info['video']['bitrate'] == 0))) {
1463  // if video bitrate not set
1464  if (isset($this->info['audio']['bitrate']) && ($this->info['audio']['bitrate'] > 0) && ($this->info['audio']['bitrate'] == $this->info['bitrate'])) {
1465  // AND if audio bitrate is set to same as overall bitrate
1466  if (isset($this->info['playtime_seconds']) && ($this->info['playtime_seconds'] > 0)) {
1467  // AND if playtime is set
1468  if (isset($this->info['avdataend']) && isset($this->info['avdataoffset'])) {
1469  // AND if AV data offset start/end is known
1470  // THEN we can calculate the video bitrate
1471  $this->info['bitrate'] = round((($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds']);
1472  $this->info['video']['bitrate'] = $this->info['bitrate'] - $this->info['audio']['bitrate'];
1473  }
1474  }
1475  }
1476  }
1477 
1478  if ((!isset($this->info['playtime_seconds']) || ($this->info['playtime_seconds'] <= 0)) && !empty($this->info['bitrate'])) {
1479  $this->info['playtime_seconds'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['bitrate'];
1480  }
1481 
1482  if (!isset($this->info['bitrate']) && !empty($this->info['playtime_seconds'])) {
1483  $this->info['bitrate'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds'];
1484  }
1485  if (isset($this->info['bitrate']) && empty($this->info['audio']['bitrate']) && empty($this->info['video']['bitrate'])) {
1486  if (isset($this->info['audio']['dataformat']) && empty($this->info['video']['resolution_x'])) {
1487  // audio only
1488  $this->info['audio']['bitrate'] = $this->info['bitrate'];
1489  } elseif (isset($this->info['video']['resolution_x']) && empty($this->info['audio']['dataformat'])) {
1490  // video only
1491  $this->info['video']['bitrate'] = $this->info['bitrate'];
1492  }
1493  }
1494 
1495  // Set playtime string
1496  if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) {
1497  $this->info['playtime_string'] = getid3_lib::PlaytimeString($this->info['playtime_seconds']);
1498  }
1499  }
PlaytimeString($playtimeseconds)
Definition: getid3.lib.php:408
+ Here is the call graph for this function:

◆ CharConvert() [1/2]

getID3::CharConvert ( $array,
  $encoding 
)

Definition at line 950 of file getid3.php.

References getid3_lib\iconv_fallback().

Referenced by CharConvert(), and HandleAllTags().

950  {
951 
952  // identical encoding - end here
953  if ($encoding == $this->encoding) {
954  return;
955  }
956 
957  // loop thru array
958  foreach ($array as $key => $value) {
959 
960  // go recursive
961  if (is_array($value)) {
962  $this->CharConvert($array[$key], $encoding);
963  }
964 
965  // convert string
966  elseif (is_string($value)) {
967  $array[$key] = trim(getid3_lib::iconv_fallback($encoding, $this->encoding, $value));
968  }
969  }
970  }
CharConvert(&$array, $encoding)
Definition: getid3.php:950
iconv_fallback($in_charset, $out_charset, $string)
Definition: getid3.lib.php:951
$encoding
Definition: getid3.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CharConvert() [2/2]

getID3::CharConvert ( $array,
  $encoding 
)

Definition at line 1146 of file getid3.php.

References $encoding, CharConvert(), and getid3_lib\iconv_fallback().

1146  {
1147 
1148  // identical encoding - end here
1149  if ($encoding == $this->encoding) {
1150  return;
1151  }
1152 
1153  // loop thru array
1154  foreach ($array as $key => $value) {
1155 
1156  // go recursive
1157  if (is_array($value)) {
1158  $this->CharConvert($array[$key], $encoding);
1159  }
1160 
1161  // convert string
1162  elseif (is_string($value)) {
1163  $array[$key] = trim(getid3_lib::iconv_fallback($encoding, $this->encoding, $value));
1164  }
1165  }
1166  }
CharConvert(&$array, $encoding)
Definition: getid3.php:950
iconv_fallback($in_charset, $out_charset, $string)
Definition: getid3.lib.php:951
$encoding
Definition: getid3.php:21
+ Here is the call graph for this function:

◆ CleanUp() [1/2]

getID3::CleanUp ( )

Definition at line 418 of file getid3.php.

Referenced by analyze(), and error().

418  {
419 
420  // remove possible empty keys
421  $AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams');
422  foreach ($AVpossibleEmptyKeys as $dummy => $key) {
423  if (empty($this->info['audio'][$key]) && isset($this->info['audio'][$key])) {
424  unset($this->info['audio'][$key]);
425  }
426  if (empty($this->info['video'][$key]) && isset($this->info['video'][$key])) {
427  unset($this->info['video'][$key]);
428  }
429  }
430 
431  // remove empty root keys
432  if (!empty($this->info)) {
433  foreach ($this->info as $key => $value) {
434  if (empty($this->info[$key]) && ($this->info[$key] !== 0) && ($this->info[$key] !== '0')) {
435  unset($this->info[$key]);
436  }
437  }
438  }
439 
440  // remove meaningless entries from unknown-format files
441  if (empty($this->info['fileformat'])) {
442  if (isset($this->info['avdataoffset'])) {
443  unset($this->info['avdataoffset']);
444  }
445  if (isset($this->info['avdataend'])) {
446  unset($this->info['avdataend']);
447  }
448  }
449  }
+ Here is the caller graph for this function:

◆ CleanUp() [2/2]

getID3::CleanUp ( )
private

Definition at line 514 of file getid3.php.

514  {
515 
516  // remove possible empty keys
517  $AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams', 'bitrate');
518  foreach ($AVpossibleEmptyKeys as $dummy => $key) {
519  if (empty($this->info['audio'][$key]) && isset($this->info['audio'][$key])) {
520  unset($this->info['audio'][$key]);
521  }
522  if (empty($this->info['video'][$key]) && isset($this->info['video'][$key])) {
523  unset($this->info['video'][$key]);
524  }
525  }
526 
527  // remove empty root keys
528  if (!empty($this->info)) {
529  foreach ($this->info as $key => $value) {
530  if (empty($this->info[$key]) && ($this->info[$key] !== 0) && ($this->info[$key] !== '0')) {
531  unset($this->info[$key]);
532  }
533  }
534  }
535 
536  // remove meaningless entries from unknown-format files
537  if (empty($this->info['fileformat'])) {
538  if (isset($this->info['avdataoffset'])) {
539  unset($this->info['avdataoffset']);
540  }
541  if (isset($this->info['avdataend'])) {
542  unset($this->info['avdataend']);
543  }
544  }
545 
546  // remove possible duplicated identical entries
547  if (!empty($this->info['error'])) {
548  $this->info['error'] = array_values(array_unique($this->info['error']));
549  }
550  if (!empty($this->info['warning'])) {
551  $this->info['warning'] = array_values(array_unique($this->info['warning']));
552  }
553 
554  // remove "global variable" type keys
555  unset($this->info['php_memory_limit']);
556 
557  return true;
558  }

◆ error() [1/2]

getID3::error (   $message)

Definition at line 401 of file getid3.php.

References $info, and CleanUp().

Referenced by analyze(), getHashdata(), and openfile().

401  {
402 
403  $this->CleanUp();
404 
405  $this->info['error'][] = $message;
406  return $this->info;
407  }
CleanUp()
Definition: getid3.php:418
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ error() [2/2]

getID3::error (   $message)

Definition at line 496 of file getid3.php.

References $info, and CleanUp().

496  {
497  $this->CleanUp();
498  if (!isset($this->info['error'])) {
499  $this->info['error'] = array();
500  }
501  $this->info['error'][] = $message;
502  return $this->info;
503  }
CleanUp()
Definition: getid3.php:418
+ Here is the call graph for this function:

◆ fread_buffer_size()

getID3::fread_buffer_size ( )

Definition at line 226 of file getid3.php.

References $option_fread_buffer_size.

226  {
228  }
$option_fread_buffer_size
Definition: getid3.php:99

◆ GetFileFormat() [1/2]

getID3::GetFileFormat ( $filedata,
  $filename = '' 
)

Definition at line 918 of file getid3.php.

References $info, and GetFileFormatArray().

Referenced by analyze().

918  {
919  // this function will determine the format of a file based on usually
920  // the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
921  // and in the case of ISO CD image, 6 bytes offset 32kb from the start
922  // of the file).
923 
924  // Identify file format - loop through $format_info and detect with reg expr
925  foreach ($this->GetFileFormatArray() as $format_name => $info) {
926  // Using preg_match() instead of ereg() - much faster
927  // The /s switch on preg_match() forces preg_match() NOT to treat
928  // newline (0x0A) characters as special chars but do a binary match
929  if (preg_match('/'.$info['pattern'].'/s', $filedata)) {
930  $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
931  return $info;
932  }
933  }
934 
935 
936  if (preg_match('/\.mp[123a]$/i', $filename)) {
937  // Too many mp3 encoders on the market put gabage in front of mpeg files
938  // use assume format on these if format detection failed
939  $GetFileFormatArray = $this->GetFileFormatArray();
940  $info = $GetFileFormatArray['mp3'];
941  $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
942  return $info;
943  }
944 
945  return false;
946  }
$filename
Definition: getid3.php:46
GetFileFormatArray()
Definition: getid3.php:453
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetFileFormat() [2/2]

getID3::GetFileFormat ( $filedata,
  $filename = '' 
)

Definition at line 1107 of file getid3.php.

References $filename, $info, and GetFileFormatArray().

1107  {
1108  // this function will determine the format of a file based on usually
1109  // the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
1110  // and in the case of ISO CD image, 6 bytes offset 32kb from the start
1111  // of the file).
1112 
1113  // Identify file format - loop through $format_info and detect with reg expr
1114  foreach ($this->GetFileFormatArray() as $format_name => $info) {
1115  // The /s switch on preg_match() forces preg_match() NOT to treat
1116  // newline (0x0A) characters as special chars but do a binary match
1117  if (!empty($info['pattern']) && preg_match('#'.$info['pattern'].'#s', $filedata)) {
1118  $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
1119  return $info;
1120  }
1121  }
1122 
1123 
1124  if (preg_match('#\.mp[123a]$#i', $filename)) {
1125  // Too many mp3 encoders on the market put gabage in front of mpeg files
1126  // use assume format on these if format detection failed
1127  $GetFileFormatArray = $this->GetFileFormatArray();
1128  $info = $GetFileFormatArray['mp3'];
1129  $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
1130  return $info;
1131  } elseif (preg_match('/\.cue$/i', $filename) && preg_match('#FILE "[^"]+" (BINARY|MOTOROLA|AIFF|WAVE|MP3)#', $filedata)) {
1132  // there's not really a useful consistent "magic" at the beginning of .cue files to identify them
1133  // so until I think of something better, just go by filename if all other format checks fail
1134  // and verify there's at least one instance of "TRACK xx AUDIO" in the file
1135  $GetFileFormatArray = $this->GetFileFormatArray();
1136  $info = $GetFileFormatArray['cue'];
1137  $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
1138  return $info;
1139  }
1140 
1141  return false;
1142  }
$filename
Definition: getid3.php:46
GetFileFormatArray()
Definition: getid3.php:453
+ Here is the call graph for this function:

◆ GetFileFormatArray() [1/2]

getID3::GetFileFormatArray ( )

Definition at line 453 of file getid3.php.

Referenced by GetFileFormat().

453  {
454  static $format_info = array();
455  if (empty($format_info)) {
456  $format_info = array(
457 
458  // Audio formats
459 
460  // AC-3 - audio - Dolby AC-3 / Dolby Digital
461  'ac3' => array(
462  'pattern' => '^\x0B\x77',
463  'group' => 'audio',
464  'module' => 'ac3',
465  'mime_type' => 'audio/ac3',
466  ),
467 
468  // AAC - audio - Advanced Audio Coding (AAC) - ADIF format
469  'adif' => array(
470  'pattern' => '^ADIF',
471  'group' => 'audio',
472  'module' => 'aac',
473  'option' => 'adif',
474  'mime_type' => 'application/octet-stream',
475  'fail_ape' => 'WARNING',
476  ),
477 
478 
479  // AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
480  'adts' => array(
481  'pattern' => '^\xFF[\xF0-\xF1\xF8-\xF9]',
482  'group' => 'audio',
483  'module' => 'aac',
484  'option' => 'adts',
485  'mime_type' => 'application/octet-stream',
486  'fail_ape' => 'WARNING',
487  ),
488 
489 
490  // AU - audio - NeXT/Sun AUdio (AU)
491  'au' => array(
492  'pattern' => '^\.snd',
493  'group' => 'audio',
494  'module' => 'au',
495  'mime_type' => 'audio/basic',
496  ),
497 
498  // AVR - audio - Audio Visual Research
499  'avr' => array(
500  'pattern' => '^2BIT',
501  'group' => 'audio',
502  'module' => 'avr',
503  'mime_type' => 'application/octet-stream',
504  ),
505 
506  // BONK - audio - Bonk v0.9+
507  'bonk' => array(
508  'pattern' => '^\x00(BONK|INFO|META| ID3)',
509  'group' => 'audio',
510  'module' => 'bonk',
511  'mime_type' => 'audio/xmms-bonk',
512  ),
513 
514  // FLAC - audio - Free Lossless Audio Codec
515  'flac' => array(
516  'pattern' => '^fLaC',
517  'group' => 'audio',
518  'module' => 'flac',
519  'mime_type' => 'audio/x-flac',
520  ),
521 
522  // LA - audio - Lossless Audio (LA)
523  'la' => array(
524  'pattern' => '^LA0[2-4]',
525  'group' => 'audio',
526  'module' => 'la',
527  'mime_type' => 'application/octet-stream',
528  ),
529 
530  // LPAC - audio - Lossless Predictive Audio Compression (LPAC)
531  'lpac' => array(
532  'pattern' => '^LPAC',
533  'group' => 'audio',
534  'module' => 'lpac',
535  'mime_type' => 'application/octet-stream',
536  ),
537 
538  // MIDI - audio - MIDI (Musical Instrument Digital Interface)
539  'midi' => array(
540  'pattern' => '^MThd',
541  'group' => 'audio',
542  'module' => 'midi',
543  'mime_type' => 'audio/midi',
544  ),
545 
546  // MAC - audio - Monkey's Audio Compressor
547  'mac' => array(
548  'pattern' => '^MAC ',
549  'group' => 'audio',
550  'module' => 'monkey',
551  'mime_type' => 'application/octet-stream',
552  ),
553 
554  // MOD - audio - MODule (assorted sub-formats)
555  'mod' => array(
556  'pattern' => '^.{1080}(M.K.|[5-9]CHN|[1-3][0-9]CH)',
557  'group' => 'audio',
558  'module' => 'mod',
559  'option' => 'mod',
560  'mime_type' => 'audio/mod',
561  ),
562 
563  // MOD - audio - MODule (Impulse Tracker)
564  'it' => array(
565  'pattern' => '^IMPM',
566  'group' => 'audio',
567  'module' => 'mod',
568  'option' => 'it',
569  'mime_type' => 'audio/it',
570  ),
571 
572  // MOD - audio - MODule (eXtended Module, various sub-formats)
573  'xm' => array(
574  'pattern' => '^Extended Module',
575  'group' => 'audio',
576  'module' => 'mod',
577  'option' => 'xm',
578  'mime_type' => 'audio/xm',
579  ),
580 
581  // MOD - audio - MODule (ScreamTracker)
582  's3m' => array(
583  'pattern' => '^.{44}SCRM',
584  'group' => 'audio',
585  'module' => 'mod',
586  'option' => 's3m',
587  'mime_type' => 'audio/s3m',
588  ),
589 
590  // MPC - audio - Musepack / MPEGplus
591  'mpc' => array(
592  'pattern' => '^(MP\+|[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0])',
593  'group' => 'audio',
594  'module' => 'mpc',
595  'mime_type' => 'application/octet-stream',
596  ),
597 
598  // MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS)
599  'mp3' => array(
600  'pattern' => '^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]',
601  'group' => 'audio',
602  'module' => 'mp3',
603  'mime_type' => 'audio/mpeg',
604  ),
605 
606  // OFR - audio - OptimFROG
607  'ofr' => array(
608  'pattern' => '^(\*RIFF|OFR)',
609  'group' => 'audio',
610  'module' => 'optimfrog',
611  'mime_type' => 'application/octet-stream',
612  ),
613 
614  // RKAU - audio - RKive AUdio compressor
615  'rkau' => array(
616  'pattern' => '^RKA',
617  'group' => 'audio',
618  'module' => 'rkau',
619  'mime_type' => 'application/octet-stream',
620  ),
621 
622  // SHN - audio - Shorten
623  'shn' => array(
624  'pattern' => '^ajkg',
625  'group' => 'audio',
626  'module' => 'shorten',
627  'mime_type' => 'audio/xmms-shn',
628  'fail_id3' => 'ERROR',
629  'fail_ape' => 'ERROR',
630  ),
631 
632  // TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org)
633  'tta' => array(
634  'pattern' => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)'
635  'group' => 'audio',
636  'module' => 'tta',
637  'mime_type' => 'application/octet-stream',
638  ),
639 
640  // VOC - audio - Creative Voice (VOC)
641  'voc' => array(
642  'pattern' => '^Creative Voice File',
643  'group' => 'audio',
644  'module' => 'voc',
645  'mime_type' => 'audio/voc',
646  ),
647 
648  // VQF - audio - transform-domain weighted interleave Vector Quantization Format (VQF)
649  'vqf' => array(
650  'pattern' => '^TWIN',
651  'group' => 'audio',
652  'module' => 'vqf',
653  'mime_type' => 'application/octet-stream',
654  ),
655 
656  // WV - audio - WavPack (v4.0+)
657  'wv' => array(
658  'pattern' => '^wvpk',
659  'group' => 'audio',
660  'module' => 'wavpack',
661  'mime_type' => 'application/octet-stream',
662  ),
663 
664 
665  // Audio-Video formats
666 
667  // ASF - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio
668  'asf' => array(
669  'pattern' => '^\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C',
670  'group' => 'audio-video',
671  'module' => 'asf',
672  'mime_type' => 'video/x-ms-asf',
673  'iconv_req' => false,
674  ),
675 
676  // BINK - audio/video - Bink / Smacker
677  'bink' => array(
678  'pattern' => '^(BIK|SMK)',
679  'group' => 'audio-video',
680  'module' => 'bink',
681  'mime_type' => 'application/octet-stream',
682  ),
683 
684  // FLV - audio/video - FLash Video
685  'flv' => array(
686  'pattern' => '^FLV\x01',
687  'group' => 'audio-video',
688  'module' => 'flv',
689  'mime_type' => 'video/x-flv',
690  ),
691 
692  // MKAV - audio/video - Mastroka
693  'matroska' => array(
694  'pattern' => '^\x1A\x45\xDF\xA3',
695  'group' => 'audio-video',
696  'module' => 'matroska',
697  'mime_type' => 'application/octet-stream',
698  ),
699 
700  // MPEG - audio/video - MPEG (Moving Pictures Experts Group)
701  'mpeg' => array(
702  'pattern' => '^\x00\x00\x01(\xBA|\xB3)',
703  'group' => 'audio-video',
704  'module' => 'mpeg',
705  'mime_type' => 'video/mpeg',
706  ),
707 
708  // NSV - audio/video - Nullsoft Streaming Video (NSV)
709  'nsv' => array(
710  'pattern' => '^NSV[sf]',
711  'group' => 'audio-video',
712  'module' => 'nsv',
713  'mime_type' => 'application/octet-stream',
714  ),
715 
716  // Ogg - audio/video - Ogg (Ogg-Vorbis, Ogg-FLAC, Speex, Ogg-Theora(*), Ogg-Tarkin(*))
717  'ogg' => array(
718  'pattern' => '^OggS',
719  'group' => 'audio',
720  'module' => 'ogg',
721  'mime_type' => 'application/ogg',
722  'fail_id3' => 'WARNING',
723  'fail_ape' => 'WARNING',
724  ),
725 
726  // QT - audio/video - Quicktime
727  'quicktime' => array(
728  'pattern' => '^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)',
729  'group' => 'audio-video',
730  'module' => 'quicktime',
731  'mime_type' => 'video/quicktime',
732  ),
733 
734  // RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com) / FORM = Audio Interchange File Format (AIFF)
735  'riff' => array(
736  'pattern' => '^(RIFF|SDSS|FORM)',
737  'group' => 'audio-video',
738  'module' => 'riff',
739  'mime_type' => 'audio/x-wave',
740  'fail_ape' => 'WARNING',
741  ),
742 
743  // Real - audio/video - RealAudio, RealVideo
744  'real' => array(
745  'pattern' => '^(\.RMF|.ra)',
746  'group' => 'audio-video',
747  'module' => 'real',
748  'mime_type' => 'audio/x-realaudio',
749  ),
750 
751  // SWF - audio/video - ShockWave Flash
752  'swf' => array(
753  'pattern' => '^(F|C)WS',
754  'group' => 'audio-video',
755  'module' => 'swf',
756  'mime_type' => 'application/x-shockwave-flash',
757  ),
758 
759 
760  // Still-Image formats
761 
762  // BMP - still image - Bitmap (Windows, OS/2; uncompressed, RLE8, RLE4)
763  'bmp' => array(
764  'pattern' => '^BM',
765  'group' => 'graphic',
766  'module' => 'bmp',
767  'mime_type' => 'image/bmp',
768  'fail_id3' => 'ERROR',
769  'fail_ape' => 'ERROR',
770  ),
771 
772  // GIF - still image - Graphics Interchange Format
773  'gif' => array(
774  'pattern' => '^GIF',
775  'group' => 'graphic',
776  'module' => 'gif',
777  'mime_type' => 'image/gif',
778  'fail_id3' => 'ERROR',
779  'fail_ape' => 'ERROR',
780  ),
781 
782  // JPEG - still image - Joint Photographic Experts Group (JPEG)
783  'jpg' => array(
784  'pattern' => '^\xFF\xD8\xFF',
785  'group' => 'graphic',
786  'module' => 'jpg',
787  'mime_type' => 'image/jpeg',
788  'fail_id3' => 'ERROR',
789  'fail_ape' => 'ERROR',
790  ),
791 
792  // PCD - still image - Kodak Photo CD
793  'pcd' => array(
794  'pattern' => '^.{2048}PCD_IPI\x00',
795  'group' => 'graphic',
796  'module' => 'pcd',
797  'mime_type' => 'image/x-photo-cd',
798  'fail_id3' => 'ERROR',
799  'fail_ape' => 'ERROR',
800  ),
801 
802 
803  // PNG - still image - Portable Network Graphics (PNG)
804  'png' => array(
805  'pattern' => '^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A',
806  'group' => 'graphic',
807  'module' => 'png',
808  'mime_type' => 'image/png',
809  'fail_id3' => 'ERROR',
810  'fail_ape' => 'ERROR',
811  ),
812 
813 
814  // TIFF - still image - Tagged Information File Format (TIFF)
815  'tiff' => array(
816  'pattern' => '^(II\x2A\x00|MM\x00\x2A)',
817  'group' => 'graphic',
818  'module' => 'tiff',
819  'mime_type' => 'image/tiff',
820  'fail_id3' => 'ERROR',
821  'fail_ape' => 'ERROR',
822  ),
823 
824 
825  // Data formats
826 
827  // ISO - data - International Standards Organization (ISO) CD-ROM Image
828  'iso' => array(
829  'pattern' => '^.{32769}CD001',
830  'group' => 'misc',
831  'module' => 'iso',
832  'mime_type' => 'application/octet-stream',
833  'fail_id3' => 'ERROR',
834  'fail_ape' => 'ERROR',
835  'iconv_req' => false,
836  ),
837 
838  // RAR - data - RAR compressed data
839  'rar' => array(
840  'pattern' => '^Rar\!',
841  'group' => 'archive',
842  'module' => 'rar',
843  'mime_type' => 'application/octet-stream',
844  'fail_id3' => 'ERROR',
845  'fail_ape' => 'ERROR',
846  ),
847 
848  // SZIP - audio/data - SZIP compressed data
849  'szip' => array(
850  'pattern' => '^SZ\x0A\x04',
851  'group' => 'archive',
852  'module' => 'szip',
853  'mime_type' => 'application/octet-stream',
854  'fail_id3' => 'ERROR',
855  'fail_ape' => 'ERROR',
856  ),
857 
858  // TAR - data - TAR compressed data
859  'tar' => array(
860  'pattern' => '^.{100}[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20\x00]{12}[0-9\x20\x00]{12}',
861  'group' => 'archive',
862  'module' => 'tar',
863  'mime_type' => 'application/x-tar',
864  'fail_id3' => 'ERROR',
865  'fail_ape' => 'ERROR',
866  ),
867 
868  // GZIP - data - GZIP compressed data
869  'gz' => array(
870  'pattern' => '^\x1F\x8B\x08',
871  'group' => 'archive',
872  'module' => 'gzip',
873  'mime_type' => 'application/x-gzip',
874  'fail_id3' => 'ERROR',
875  'fail_ape' => 'ERROR',
876  ),
877 
878  // ZIP - data - ZIP compressed data
879  'zip' => array(
880  'pattern' => '^PK\x03\x04',
881  'group' => 'archive',
882  'module' => 'zip',
883  'mime_type' => 'application/zip',
884  'fail_id3' => 'ERROR',
885  'fail_ape' => 'ERROR',
886  ),
887 
888 
889  // Misc other formats
890 
891  // PDF - data - ZIP compressed data
892  'pdf' => array(
893  'pattern' => '^\x25PDF',
894  'group' => 'misc',
895  'module' => 'pdf',
896  'mime_type' => 'application/pdf',
897  'fail_id3' => 'ERROR',
898  'fail_ape' => 'ERROR',
899  ),
900 
901  // MSOFFICE - data - ZIP compressed data
902  'msoffice' => array(
903  'pattern' => '^\xD0\xCF\x11\xE0', // D0CF11E == DOCFILE == Microsoft Office Document
904  'group' => 'misc',
905  'module' => 'msoffice',
906  'mime_type' => 'application/octet-stream',
907  'fail_id3' => 'ERROR',
908  'fail_ape' => 'ERROR',
909  ),
910  );
911  }
912 
913  return $format_info;
914  }
+ Here is the caller graph for this function:

◆ GetFileFormatArray() [2/2]

getID3::GetFileFormatArray ( )

Definition at line 562 of file getid3.php.

562  {
563  static $format_info = array();
564  if (empty($format_info)) {
565  $format_info = array(
566 
567  // Audio formats
568 
569  // AC-3 - audio - Dolby AC-3 / Dolby Digital
570  'ac3' => array(
571  'pattern' => '^\x0B\x77',
572  'group' => 'audio',
573  'module' => 'ac3',
574  'mime_type' => 'audio/ac3',
575  ),
576 
577  // AAC - audio - Advanced Audio Coding (AAC) - ADIF format
578  'adif' => array(
579  'pattern' => '^ADIF',
580  'group' => 'audio',
581  'module' => 'aac',
582  'mime_type' => 'application/octet-stream',
583  'fail_ape' => 'WARNING',
584  ),
585 
586 /*
587  // AA - audio - Audible Audiobook
588  'aa' => array(
589  'pattern' => '^.{4}\x57\x90\x75\x36',
590  'group' => 'audio',
591  'module' => 'aa',
592  'mime_type' => 'audio/audible',
593  ),
594 */
595  // AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
596  'adts' => array(
597  'pattern' => '^\xFF[\xF0-\xF1\xF8-\xF9]',
598  'group' => 'audio',
599  'module' => 'aac',
600  'mime_type' => 'application/octet-stream',
601  'fail_ape' => 'WARNING',
602  ),
603 
604 
605  // AU - audio - NeXT/Sun AUdio (AU)
606  'au' => array(
607  'pattern' => '^\.snd',
608  'group' => 'audio',
609  'module' => 'au',
610  'mime_type' => 'audio/basic',
611  ),
612 
613  // AMR - audio - Adaptive Multi Rate
614  'amr' => array(
615  'pattern' => '^\x23\x21AMR\x0A', // #!AMR[0A]
616  'group' => 'audio',
617  'module' => 'amr',
618  'mime_type' => 'audio/amr',
619  ),
620 
621  // AVR - audio - Audio Visual Research
622  'avr' => array(
623  'pattern' => '^2BIT',
624  'group' => 'audio',
625  'module' => 'avr',
626  'mime_type' => 'application/octet-stream',
627  ),
628 
629  // BONK - audio - Bonk v0.9+
630  'bonk' => array(
631  'pattern' => '^\x00(BONK|INFO|META| ID3)',
632  'group' => 'audio',
633  'module' => 'bonk',
634  'mime_type' => 'audio/xmms-bonk',
635  ),
636 
637  // DSS - audio - Digital Speech Standard
638  'dss' => array(
639  'pattern' => '^[\x02-\x03]ds[s2]',
640  'group' => 'audio',
641  'module' => 'dss',
642  'mime_type' => 'application/octet-stream',
643  ),
644 
645  // DTS - audio - Dolby Theatre System
646  'dts' => array(
647  'pattern' => '^\x7F\xFE\x80\x01',
648  'group' => 'audio',
649  'module' => 'dts',
650  'mime_type' => 'audio/dts',
651  ),
652 
653  // FLAC - audio - Free Lossless Audio Codec
654  'flac' => array(
655  'pattern' => '^fLaC',
656  'group' => 'audio',
657  'module' => 'flac',
658  'mime_type' => 'audio/x-flac',
659  ),
660 
661  // LA - audio - Lossless Audio (LA)
662  'la' => array(
663  'pattern' => '^LA0[2-4]',
664  'group' => 'audio',
665  'module' => 'la',
666  'mime_type' => 'application/octet-stream',
667  ),
668 
669  // LPAC - audio - Lossless Predictive Audio Compression (LPAC)
670  'lpac' => array(
671  'pattern' => '^LPAC',
672  'group' => 'audio',
673  'module' => 'lpac',
674  'mime_type' => 'application/octet-stream',
675  ),
676 
677  // MIDI - audio - MIDI (Musical Instrument Digital Interface)
678  'midi' => array(
679  'pattern' => '^MThd',
680  'group' => 'audio',
681  'module' => 'midi',
682  'mime_type' => 'audio/midi',
683  ),
684 
685  // MAC - audio - Monkey's Audio Compressor
686  'mac' => array(
687  'pattern' => '^MAC ',
688  'group' => 'audio',
689  'module' => 'monkey',
690  'mime_type' => 'application/octet-stream',
691  ),
692 
693 // has been known to produce false matches in random files (e.g. JPEGs), leave out until more precise matching available
694 // // MOD - audio - MODule (assorted sub-formats)
695 // 'mod' => array(
696 // 'pattern' => '^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)',
697 // 'group' => 'audio',
698 // 'module' => 'mod',
699 // 'option' => 'mod',
700 // 'mime_type' => 'audio/mod',
701 // ),
702 
703  // MOD - audio - MODule (Impulse Tracker)
704  'it' => array(
705  'pattern' => '^IMPM',
706  'group' => 'audio',
707  'module' => 'mod',
708  //'option' => 'it',
709  'mime_type' => 'audio/it',
710  ),
711 
712  // MOD - audio - MODule (eXtended Module, various sub-formats)
713  'xm' => array(
714  'pattern' => '^Extended Module',
715  'group' => 'audio',
716  'module' => 'mod',
717  //'option' => 'xm',
718  'mime_type' => 'audio/xm',
719  ),
720 
721  // MOD - audio - MODule (ScreamTracker)
722  's3m' => array(
723  'pattern' => '^.{44}SCRM',
724  'group' => 'audio',
725  'module' => 'mod',
726  //'option' => 's3m',
727  'mime_type' => 'audio/s3m',
728  ),
729 
730  // MPC - audio - Musepack / MPEGplus
731  'mpc' => array(
732  'pattern' => '^(MPCK|MP\+|[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0])',
733  'group' => 'audio',
734  'module' => 'mpc',
735  'mime_type' => 'audio/x-musepack',
736  ),
737 
738  // MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS)
739  'mp3' => array(
740  'pattern' => '^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\x0B\x10-\x1B\x20-\x2B\x30-\x3B\x40-\x4B\x50-\x5B\x60-\x6B\x70-\x7B\x80-\x8B\x90-\x9B\xA0-\xAB\xB0-\xBB\xC0-\xCB\xD0-\xDB\xE0-\xEB\xF0-\xFB]',
741  'group' => 'audio',
742  'module' => 'mp3',
743  'mime_type' => 'audio/mpeg',
744  ),
745 
746  // OFR - audio - OptimFROG
747  'ofr' => array(
748  'pattern' => '^(\*RIFF|OFR)',
749  'group' => 'audio',
750  'module' => 'optimfrog',
751  'mime_type' => 'application/octet-stream',
752  ),
753 
754  // RKAU - audio - RKive AUdio compressor
755  'rkau' => array(
756  'pattern' => '^RKA',
757  'group' => 'audio',
758  'module' => 'rkau',
759  'mime_type' => 'application/octet-stream',
760  ),
761 
762  // SHN - audio - Shorten
763  'shn' => array(
764  'pattern' => '^ajkg',
765  'group' => 'audio',
766  'module' => 'shorten',
767  'mime_type' => 'audio/xmms-shn',
768  'fail_id3' => 'ERROR',
769  'fail_ape' => 'ERROR',
770  ),
771 
772  // TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org)
773  'tta' => array(
774  'pattern' => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)'
775  'group' => 'audio',
776  'module' => 'tta',
777  'mime_type' => 'application/octet-stream',
778  ),
779 
780  // VOC - audio - Creative Voice (VOC)
781  'voc' => array(
782  'pattern' => '^Creative Voice File',
783  'group' => 'audio',
784  'module' => 'voc',
785  'mime_type' => 'audio/voc',
786  ),
787 
788  // VQF - audio - transform-domain weighted interleave Vector Quantization Format (VQF)
789  'vqf' => array(
790  'pattern' => '^TWIN',
791  'group' => 'audio',
792  'module' => 'vqf',
793  'mime_type' => 'application/octet-stream',
794  ),
795 
796  // WV - audio - WavPack (v4.0+)
797  'wv' => array(
798  'pattern' => '^wvpk',
799  'group' => 'audio',
800  'module' => 'wavpack',
801  'mime_type' => 'application/octet-stream',
802  ),
803 
804 
805  // Audio-Video formats
806 
807  // ASF - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio
808  'asf' => array(
809  'pattern' => '^\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C',
810  'group' => 'audio-video',
811  'module' => 'asf',
812  'mime_type' => 'video/x-ms-asf',
813  'iconv_req' => false,
814  ),
815 
816  // BINK - audio/video - Bink / Smacker
817  'bink' => array(
818  'pattern' => '^(BIK|SMK)',
819  'group' => 'audio-video',
820  'module' => 'bink',
821  'mime_type' => 'application/octet-stream',
822  ),
823 
824  // FLV - audio/video - FLash Video
825  'flv' => array(
826  'pattern' => '^FLV\x01',
827  'group' => 'audio-video',
828  'module' => 'flv',
829  'mime_type' => 'video/x-flv',
830  ),
831 
832  // MKAV - audio/video - Mastroka
833  'matroska' => array(
834  'pattern' => '^\x1A\x45\xDF\xA3',
835  'group' => 'audio-video',
836  'module' => 'matroska',
837  'mime_type' => 'video/x-matroska', // may also be audio/x-matroska
838  ),
839 
840  // MPEG - audio/video - MPEG (Moving Pictures Experts Group)
841  'mpeg' => array(
842  'pattern' => '^\x00\x00\x01(\xBA|\xB3)',
843  'group' => 'audio-video',
844  'module' => 'mpeg',
845  'mime_type' => 'video/mpeg',
846  ),
847 
848  // NSV - audio/video - Nullsoft Streaming Video (NSV)
849  'nsv' => array(
850  'pattern' => '^NSV[sf]',
851  'group' => 'audio-video',
852  'module' => 'nsv',
853  'mime_type' => 'application/octet-stream',
854  ),
855 
856  // Ogg - audio/video - Ogg (Ogg-Vorbis, Ogg-FLAC, Speex, Ogg-Theora(*), Ogg-Tarkin(*))
857  'ogg' => array(
858  'pattern' => '^OggS',
859  'group' => 'audio',
860  'module' => 'ogg',
861  'mime_type' => 'application/ogg',
862  'fail_id3' => 'WARNING',
863  'fail_ape' => 'WARNING',
864  ),
865 
866  // QT - audio/video - Quicktime
867  'quicktime' => array(
868  'pattern' => '^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)',
869  'group' => 'audio-video',
870  'module' => 'quicktime',
871  'mime_type' => 'video/quicktime',
872  ),
873 
874  // RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com) / FORM = Audio Interchange File Format (AIFF)
875  'riff' => array(
876  'pattern' => '^(RIFF|SDSS|FORM)',
877  'group' => 'audio-video',
878  'module' => 'riff',
879  'mime_type' => 'audio/x-wave',
880  'fail_ape' => 'WARNING',
881  ),
882 
883  // Real - audio/video - RealAudio, RealVideo
884  'real' => array(
885  'pattern' => '^(\\.RMF|\\.ra)',
886  'group' => 'audio-video',
887  'module' => 'real',
888  'mime_type' => 'audio/x-realaudio',
889  ),
890 
891  // SWF - audio/video - ShockWave Flash
892  'swf' => array(
893  'pattern' => '^(F|C)WS',
894  'group' => 'audio-video',
895  'module' => 'swf',
896  'mime_type' => 'application/x-shockwave-flash',
897  ),
898 
899  // TS - audio/video - MPEG-2 Transport Stream
900  'ts' => array(
901  'pattern' => '^(\x47.{187}){10,}', // packets are 188 bytes long and start with 0x47 "G". Check for at least 10 packets matching this pattern
902  'group' => 'audio-video',
903  'module' => 'ts',
904  'mime_type' => 'video/MP2T',
905  ),
906 
907 
908  // Still-Image formats
909 
910  // BMP - still image - Bitmap (Windows, OS/2; uncompressed, RLE8, RLE4)
911  'bmp' => array(
912  'pattern' => '^BM',
913  'group' => 'graphic',
914  'module' => 'bmp',
915  'mime_type' => 'image/bmp',
916  'fail_id3' => 'ERROR',
917  'fail_ape' => 'ERROR',
918  ),
919 
920  // GIF - still image - Graphics Interchange Format
921  'gif' => array(
922  'pattern' => '^GIF',
923  'group' => 'graphic',
924  'module' => 'gif',
925  'mime_type' => 'image/gif',
926  'fail_id3' => 'ERROR',
927  'fail_ape' => 'ERROR',
928  ),
929 
930  // JPEG - still image - Joint Photographic Experts Group (JPEG)
931  'jpg' => array(
932  'pattern' => '^\xFF\xD8\xFF',
933  'group' => 'graphic',
934  'module' => 'jpg',
935  'mime_type' => 'image/jpeg',
936  'fail_id3' => 'ERROR',
937  'fail_ape' => 'ERROR',
938  ),
939 
940  // PCD - still image - Kodak Photo CD
941  'pcd' => array(
942  'pattern' => '^.{2048}PCD_IPI\x00',
943  'group' => 'graphic',
944  'module' => 'pcd',
945  'mime_type' => 'image/x-photo-cd',
946  'fail_id3' => 'ERROR',
947  'fail_ape' => 'ERROR',
948  ),
949 
950 
951  // PNG - still image - Portable Network Graphics (PNG)
952  'png' => array(
953  'pattern' => '^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A',
954  'group' => 'graphic',
955  'module' => 'png',
956  'mime_type' => 'image/png',
957  'fail_id3' => 'ERROR',
958  'fail_ape' => 'ERROR',
959  ),
960 
961 
962  // SVG - still image - Scalable Vector Graphics (SVG)
963  'svg' => array(
964  'pattern' => '(<!DOCTYPE svg PUBLIC |xmlns="http:\/\/www\.w3\.org\/2000\/svg")',
965  'group' => 'graphic',
966  'module' => 'svg',
967  'mime_type' => 'image/svg+xml',
968  'fail_id3' => 'ERROR',
969  'fail_ape' => 'ERROR',
970  ),
971 
972 
973  // TIFF - still image - Tagged Information File Format (TIFF)
974  'tiff' => array(
975  'pattern' => '^(II\x2A\x00|MM\x00\x2A)',
976  'group' => 'graphic',
977  'module' => 'tiff',
978  'mime_type' => 'image/tiff',
979  'fail_id3' => 'ERROR',
980  'fail_ape' => 'ERROR',
981  ),
982 
983 
984  // EFAX - still image - eFax (TIFF derivative)
985  'efax' => array(
986  'pattern' => '^\xDC\xFE',
987  'group' => 'graphic',
988  'module' => 'efax',
989  'mime_type' => 'image/efax',
990  'fail_id3' => 'ERROR',
991  'fail_ape' => 'ERROR',
992  ),
993 
994 
995  // Data formats
996 
997  // ISO - data - International Standards Organization (ISO) CD-ROM Image
998  'iso' => array(
999  'pattern' => '^.{32769}CD001',
1000  'group' => 'misc',
1001  'module' => 'iso',
1002  'mime_type' => 'application/octet-stream',
1003  'fail_id3' => 'ERROR',
1004  'fail_ape' => 'ERROR',
1005  'iconv_req' => false,
1006  ),
1007 
1008  // RAR - data - RAR compressed data
1009  'rar' => array(
1010  'pattern' => '^Rar\!',
1011  'group' => 'archive',
1012  'module' => 'rar',
1013  'mime_type' => 'application/octet-stream',
1014  'fail_id3' => 'ERROR',
1015  'fail_ape' => 'ERROR',
1016  ),
1017 
1018  // SZIP - audio/data - SZIP compressed data
1019  'szip' => array(
1020  'pattern' => '^SZ\x0A\x04',
1021  'group' => 'archive',
1022  'module' => 'szip',
1023  'mime_type' => 'application/octet-stream',
1024  'fail_id3' => 'ERROR',
1025  'fail_ape' => 'ERROR',
1026  ),
1027 
1028  // TAR - data - TAR compressed data
1029  'tar' => array(
1030  'pattern' => '^.{100}[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20\x00]{12}[0-9\x20\x00]{12}',
1031  'group' => 'archive',
1032  'module' => 'tar',
1033  'mime_type' => 'application/x-tar',
1034  'fail_id3' => 'ERROR',
1035  'fail_ape' => 'ERROR',
1036  ),
1037 
1038  // GZIP - data - GZIP compressed data
1039  'gz' => array(
1040  'pattern' => '^\x1F\x8B\x08',
1041  'group' => 'archive',
1042  'module' => 'gzip',
1043  'mime_type' => 'application/x-gzip',
1044  'fail_id3' => 'ERROR',
1045  'fail_ape' => 'ERROR',
1046  ),
1047 
1048  // ZIP - data - ZIP compressed data
1049  'zip' => array(
1050  'pattern' => '^PK\x03\x04',
1051  'group' => 'archive',
1052  'module' => 'zip',
1053  'mime_type' => 'application/zip',
1054  'fail_id3' => 'ERROR',
1055  'fail_ape' => 'ERROR',
1056  ),
1057 
1058 
1059  // Misc other formats
1060 
1061  // PAR2 - data - Parity Volume Set Specification 2.0
1062  'par2' => array (
1063  'pattern' => '^PAR2\x00PKT',
1064  'group' => 'misc',
1065  'module' => 'par2',
1066  'mime_type' => 'application/octet-stream',
1067  'fail_id3' => 'ERROR',
1068  'fail_ape' => 'ERROR',
1069  ),
1070 
1071  // PDF - data - Portable Document Format
1072  'pdf' => array(
1073  'pattern' => '^\x25PDF',
1074  'group' => 'misc',
1075  'module' => 'pdf',
1076  'mime_type' => 'application/pdf',
1077  'fail_id3' => 'ERROR',
1078  'fail_ape' => 'ERROR',
1079  ),
1080 
1081  // MSOFFICE - data - ZIP compressed data
1082  'msoffice' => array(
1083  'pattern' => '^\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1', // D0CF11E == DOCFILE == Microsoft Office Document
1084  'group' => 'misc',
1085  'module' => 'msoffice',
1086  'mime_type' => 'application/octet-stream',
1087  'fail_id3' => 'ERROR',
1088  'fail_ape' => 'ERROR',
1089  ),
1090 
1091  // CUE - data - CUEsheet (index to single-file disc images)
1092  'cue' => array(
1093  'pattern' => '', // empty pattern means cannot be automatically detected, will fall through all other formats and match based on filename and very basic file contents
1094  'group' => 'misc',
1095  'module' => 'cue',
1096  'mime_type' => 'application/octet-stream',
1097  ),
1098 
1099  );
1100  }
1101 
1102  return $format_info;
1103  }

◆ getHashdata() [1/2]

getID3::getHashdata (   $algorithm)

Definition at line 1043 of file getid3.php.

References $file, error(), getid3_lib\hash_data(), getid3_lib\md5_file(), and getid3_lib\sha1_file().

Referenced by analyze().

1043  {
1044  switch ($algorithm) {
1045  case 'md5':
1046  case 'sha1':
1047  break;
1048 
1049  default:
1050  return $this->error('bad algorithm "'.$algorithm.'" in getHashdata()');
1051  break;
1052  }
1053 
1054  if ((@$this->info['fileformat'] == 'ogg') && (@$this->info['audio']['dataformat'] == 'vorbis')) {
1055 
1056  // We cannot get an identical md5_data value for Ogg files where the comments
1057  // span more than 1 Ogg page (compared to the same audio data with smaller
1058  // comments) using the normal getID3() method of MD5'ing the data between the
1059  // end of the comments and the end of the file (minus any trailing tags),
1060  // because the page sequence numbers of the pages that the audio data is on
1061  // do not match. Under normal circumstances, where comments are smaller than
1062  // the nominal 4-8kB page size, then this is not a problem, but if there are
1063  // very large comments, the only way around it is to strip off the comment
1064  // tags with vorbiscomment and MD5 that file.
1065  // This procedure must be applied to ALL Ogg files, not just the ones with
1066  // comments larger than 1 page, because the below method simply MD5's the
1067  // whole file with the comments stripped, not just the portion after the
1068  // comments block (which is the standard getID3() method.
1069 
1070  // The above-mentioned problem of comments spanning multiple pages and changing
1071  // page sequence numbers likely happens for OggSpeex and OggFLAC as well, but
1072  // currently vorbiscomment only works on OggVorbis files.
1073 
1074  if ((bool) ini_get('safe_mode')) {
1075 
1076  $this->info['warning'][] = 'Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)';
1077  $this->info[$algorithm.'_data'] = false;
1078 
1079  } else {
1080 
1081  // Prevent user from aborting script
1082  $old_abort = ignore_user_abort(true);
1083 
1084  // Create empty file
1085  $empty = tempnam('*', 'getID3');
1086  touch($empty);
1087 
1088 
1089  // Use vorbiscomment to make temp file without comments
1090  $temp = tempnam('*', 'getID3');
1091  $file = $this->info['filenamepath'];
1092 
1093  if (GETID3_OS_ISWINDOWS) {
1094 
1095  if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {
1096 
1097  $commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w -c "'.$empty.'" "'.$file.'" "'.$temp.'"';
1098  $VorbisCommentError = `$commandline`;
1099 
1100  } else {
1101 
1102  $VorbisCommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
1103 
1104  }
1105 
1106  } else {
1107 
1108  $commandline = 'vorbiscomment -w -c "'.$empty.'" "'.$file.'" "'.$temp.'" 2>&1';
1109  $commandline = 'vorbiscomment -w -c '.escapeshellarg($empty).' '.escapeshellarg($file).' '.escapeshellarg($temp).' 2>&1';
1110  $VorbisCommentError = `$commandline`;
1111 
1112  }
1113 
1114  if (!empty($VorbisCommentError)) {
1115 
1116  $this->info['warning'][] = 'Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError;
1117  $this->info[$algorithm.'_data'] = false;
1118 
1119  } else {
1120 
1121  // Get hash of newly created file
1122  switch ($algorithm) {
1123  case 'md5':
1124  $this->info[$algorithm.'_data'] = getid3_lib::md5_file($temp);
1125  break;
1126 
1127  case 'sha1':
1128  $this->info[$algorithm.'_data'] = getid3_lib::sha1_file($temp);
1129  break;
1130  }
1131  }
1132 
1133  // Clean up
1134  unlink($empty);
1135  unlink($temp);
1136 
1137  // Reset abort setting
1138  ignore_user_abort($old_abort);
1139 
1140  }
1141 
1142  } else {
1143 
1144  if (!empty($this->info['avdataoffset']) || (isset($this->info['avdataend']) && ($this->info['avdataend'] < $this->info['filesize']))) {
1145 
1146  // get hash from part of file
1147  $this->info[$algorithm.'_data'] = getid3_lib::hash_data($this->info['filenamepath'], $this->info['avdataoffset'], $this->info['avdataend'], $algorithm);
1148 
1149  } else {
1150 
1151  // get hash from whole file
1152  switch ($algorithm) {
1153  case 'md5':
1154  $this->info[$algorithm.'_data'] = getid3_lib::md5_file($this->info['filenamepath']);
1155  break;
1156 
1157  case 'sha1':
1158  $this->info[$algorithm.'_data'] = getid3_lib::sha1_file($this->info['filenamepath']);
1159  break;
1160  }
1161  }
1162 
1163  }
1164  return true;
1165  }
print $file
hash_data($file, $offset, $end, $algorithm)
Definition: getid3.lib.php:582
sha1_file($file)
Definition: getid3.lib.php:545
md5_file($file)
Definition: getid3.lib.php:512
error($message)
Definition: getid3.php:401
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHashdata() [2/2]

getID3::getHashdata (   $algorithm)

Definition at line 1313 of file getid3.php.

References $file, error(), getid3_lib\hash_data(), and warning().

1313  {
1314  switch ($algorithm) {
1315  case 'md5':
1316  case 'sha1':
1317  break;
1318 
1319  default:
1320  return $this->error('bad algorithm "'.$algorithm.'" in getHashdata()');
1321  break;
1322  }
1323 
1324  if (!empty($this->info['fileformat']) && !empty($this->info['dataformat']) && ($this->info['fileformat'] == 'ogg') && ($this->info['audio']['dataformat'] == 'vorbis')) {
1325 
1326  // We cannot get an identical md5_data value for Ogg files where the comments
1327  // span more than 1 Ogg page (compared to the same audio data with smaller
1328  // comments) using the normal getID3() method of MD5'ing the data between the
1329  // end of the comments and the end of the file (minus any trailing tags),
1330  // because the page sequence numbers of the pages that the audio data is on
1331  // do not match. Under normal circumstances, where comments are smaller than
1332  // the nominal 4-8kB page size, then this is not a problem, but if there are
1333  // very large comments, the only way around it is to strip off the comment
1334  // tags with vorbiscomment and MD5 that file.
1335  // This procedure must be applied to ALL Ogg files, not just the ones with
1336  // comments larger than 1 page, because the below method simply MD5's the
1337  // whole file with the comments stripped, not just the portion after the
1338  // comments block (which is the standard getID3() method.
1339 
1340  // The above-mentioned problem of comments spanning multiple pages and changing
1341  // page sequence numbers likely happens for OggSpeex and OggFLAC as well, but
1342  // currently vorbiscomment only works on OggVorbis files.
1343 
1344  if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
1345 
1346  $this->warning('Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)');
1347  $this->info[$algorithm.'_data'] = false;
1348 
1349  } else {
1350 
1351  // Prevent user from aborting script
1352  $old_abort = ignore_user_abort(true);
1353 
1354  // Create empty file
1355  $empty = tempnam(GETID3_TEMP_DIR, 'getID3');
1356  touch($empty);
1357 
1358  // Use vorbiscomment to make temp file without comments
1359  $temp = tempnam(GETID3_TEMP_DIR, 'getID3');
1360  $file = $this->info['filenamepath'];
1361 
1362  if (GETID3_OS_ISWINDOWS) {
1363 
1364  if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {
1365 
1366  $commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w -c "'.$empty.'" "'.$file.'" "'.$temp.'"';
1367  $VorbisCommentError = `$commandline`;
1368 
1369  } else {
1370 
1371  $VorbisCommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
1372 
1373  }
1374 
1375  } else {
1376 
1377  $commandline = 'vorbiscomment -w -c "'.$empty.'" "'.$file.'" "'.$temp.'" 2>&1';
1378  $commandline = 'vorbiscomment -w -c '.escapeshellarg($empty).' '.escapeshellarg($file).' '.escapeshellarg($temp).' 2>&1';
1379  $VorbisCommentError = `$commandline`;
1380 
1381  }
1382 
1383  if (!empty($VorbisCommentError)) {
1384 
1385  $this->info['warning'][] = 'Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError;
1386  $this->info[$algorithm.'_data'] = false;
1387 
1388  } else {
1389 
1390  // Get hash of newly created file
1391  switch ($algorithm) {
1392  case 'md5':
1393  $this->info[$algorithm.'_data'] = md5_file($temp);
1394  break;
1395 
1396  case 'sha1':
1397  $this->info[$algorithm.'_data'] = sha1_file($temp);
1398  break;
1399  }
1400  }
1401 
1402  // Clean up
1403  unlink($empty);
1404  unlink($temp);
1405 
1406  // Reset abort setting
1407  ignore_user_abort($old_abort);
1408 
1409  }
1410 
1411  } else {
1412 
1413  if (!empty($this->info['avdataoffset']) || (isset($this->info['avdataend']) && ($this->info['avdataend'] < $this->info['filesize']))) {
1414 
1415  // get hash from part of file
1416  $this->info[$algorithm.'_data'] = getid3_lib::hash_data($this->info['filenamepath'], $this->info['avdataoffset'], $this->info['avdataend'], $algorithm);
1417 
1418  } else {
1419 
1420  // get hash from whole file
1421  switch ($algorithm) {
1422  case 'md5':
1423  $this->info[$algorithm.'_data'] = md5_file($this->info['filenamepath']);
1424  break;
1425 
1426  case 'sha1':
1427  $this->info[$algorithm.'_data'] = sha1_file($this->info['filenamepath']);
1428  break;
1429  }
1430  }
1431 
1432  }
1433  return true;
1434  }
print $file
warning($message)
Definition: getid3.php:411
hash_data($file, $offset, $end, $algorithm)
Definition: getid3.lib.php:582
error($message)
Definition: getid3.php:401
+ Here is the call graph for this function:

◆ getID3()

getID3::getID3 ( )

Definition at line 50 of file getid3.php.

References $memory_limit, and warning().

51  {
52 
53  $this->startup_error = '';
54  $this->startup_warning = '';
55 
56  // Check for PHP version >= 4.1.0
57  if (phpversion() < '4.1.0') {
58  $this->startup_error .= 'getID3() requires PHP v4.1.0 or higher - you are running v'.phpversion();
59  }
60 
61  // Check memory
62  $memory_limit = ini_get('memory_limit');
63  if (eregi('([0-9]+)M', $memory_limit, $matches)) {
64  // could be stored as "16M" rather than 16777216 for example
65  $memory_limit = $matches[1] * 1048576;
66  }
67  if ($memory_limit <= 0) {
68  // memory limits probably disabled
69  } elseif ($memory_limit <= 3145728) {
70  $this->startup_error .= 'PHP has less than 3MB available memory and will very likely run out. Increase memory_limit in php.ini';
71  } elseif ($memory_limit <= 12582912) {
72  $this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini';
73  }
74 
75  // Check safe_mode off
76  if ((bool) ini_get('safe_mode')) {
77  $this->warning('WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.');
78  }
79 
80 
81  // define a constant rather than looking up every time it is needed
82  if (!defined('GETID3_OS_ISWINDOWS')) {
83  if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
84  define('GETID3_OS_ISWINDOWS', true);
85  } else {
86  define('GETID3_OS_ISWINDOWS', false);
87  }
88  }
89 
90  // Get base path of getID3() - ONCE
91  if (!defined('GETID3_INCLUDEPATH')) {
92  foreach (get_included_files() as $key => $val) {
93  if (basename($val) == 'getid3.php') {
94  define('GETID3_INCLUDEPATH', dirname($val).DIRECTORY_SEPARATOR);
95  break;
96  }
97  }
98  }
99 
100  // Load support library
101  if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
102  $this->startup_error .= 'getid3.lib.php is missing or corrupt';
103  }
104 
105 
106  // Needed for Windows only:
107  // Define locations of helper applications for Shorten, VorbisComment, MetaFLAC
108  // as well as other helper functions such as head, tail, md5sum, etc
109  // IMPORTANT: This path cannot have spaces in it. If neccesary, use the 8dot3 equivalent
110  // ie for "C:/Program Files/Apache/" put "C:/PROGRA~1/APACHE/"
111  // IMPORTANT: This path must include the trailing slash
112  if (GETID3_OS_ISWINDOWS && !defined('GETID3_HELPERAPPSDIR')) {
113  $helperappsdir = GETID3_INCLUDEPATH.'..'.DIRECTORY_SEPARATOR.'helperapps'; // must not have any space in this path
114 
115  if (!is_dir($helperappsdir)) {
116 
117  $this->startup_error .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist';
118 
119  } elseif (strpos(realpath($helperappsdir), ' ') !== false) {
120 
121  $DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir));
122  $DirPieces8 = $DirPieces;
123 
124  $CLIdir = $DirPieces[0].' && cd \\';
125  for ($i = 1; $i < count($DirPieces); $i++) {
126  if (strpos($DirPieces[$i], ' ') === false) {
127  $CLIdir .= ' && cd '.$DirPieces[$i];
128  } else {
129  ob_start();
130  system($CLIdir.' && dir /ad /x');
131  $subdirsraw = explode("\n", ob_get_contents());
132  ob_end_clean();
133  foreach ($subdirsraw as $dummy => $line) {
134  if (eregi('^[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2} [AP]M <DIR> ([^ ]{8}) '.preg_quote($DirPieces[$i]).'$', trim($line), $matches)) {
135  $CLIdir .= ' && cd '.$matches[1];
136  break;
137  }
138  }
139  $DirPieces8[$i] = $matches[1];
140  }
141  }
142  $helperappsdir = implode(DIRECTORY_SEPARATOR, $DirPieces8);
143 
144  }
145  define('GETID3_HELPERAPPSDIR', realpath($helperappsdir).DIRECTORY_SEPARATOR);
146 
147  }
148 
149  }
warning($message)
Definition: getid3.php:411
$memory_limit
Definition: getid3.php:106
+ Here is the call graph for this function:

◆ getid3_tempnam() [1/2]

getID3::getid3_tempnam ( )

Definition at line 1299 of file getid3.php.

1299  {
1300  return tempnam($this->tempdir, 'gI3');
1301  }

◆ getid3_tempnam() [2/2]

getID3::getid3_tempnam ( )

Definition at line 1602 of file getid3.php.

1602  {
1603  return tempnam($this->tempdir, 'gI3');
1604  }

◆ HandleAllTags() [1/2]

getID3::HandleAllTags ( )

Definition at line 973 of file getid3.php.

References $encoding, CharConvert(), and getid3_lib\MultiByteCharString2HTML().

Referenced by analyze().

973  {
974 
975  // key name => array (tag name, character encoding)
976  static $tags;
977  if (empty($tags)) {
978  $tags = array(
979  'asf' => array('asf' , 'UTF-16LE'),
980  'midi' => array('midi' , 'ISO-8859-1'),
981  'nsv' => array('nsv' , 'ISO-8859-1'),
982  'ogg' => array('vorbiscomment' , 'UTF-8'),
983  'png' => array('png' , 'UTF-8'),
984  'tiff' => array('tiff' , 'ISO-8859-1'),
985  'quicktime' => array('quicktime' , 'ISO-8859-1'),
986  'real' => array('real' , 'ISO-8859-1'),
987  'vqf' => array('vqf' , 'ISO-8859-1'),
988  'zip' => array('zip' , 'ISO-8859-1'),
989  'riff' => array('riff' , 'ISO-8859-1'),
990  'lyrics3' => array('lyrics3' , 'ISO-8859-1'),
991  'id3v1' => array('id3v1' , $this->encoding_id3v1),
992  'id3v2' => array('id3v2' , 'UTF-8'), // not according to the specs (every frame can have a different encoding), but getID3() force-converts all encodings to UTF-8
993  'ape' => array('ape' , 'UTF-8')
994  );
995  }
996 
997  // loop thru comments array
998  foreach ($tags as $comment_name => $tagname_encoding_array) {
999  list($tag_name, $encoding) = $tagname_encoding_array;
1000 
1001  // fill in default encoding type if not already present
1002  if (isset($this->info[$comment_name]) && !isset($this->info[$comment_name]['encoding'])) {
1003  $this->info[$comment_name]['encoding'] = $encoding;
1004  }
1005 
1006  // copy comments if key name set
1007  if (!empty($this->info[$comment_name]['comments'])) {
1008 
1009  foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) {
1010  foreach ($valuearray as $key => $value) {
1011  if (strlen(trim($value)) > 0) {
1012  $this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value; // do not trim!! Unicode characters will get mangled if trailing nulls are removed!
1013  }
1014  }
1015  }
1016 
1017  if (!isset($this->info['tags'][$tag_name])) {
1018  // comments are set but contain nothing but empty strings, so skip
1019  continue;
1020  }
1021 
1022  if ($this->option_tags_html) {
1023  foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {
1024  foreach ($valuearray as $key => $value) {
1025  if (is_string($value)) {
1026  //$this->info['tags_html'][$tag_name][$tag_key][$key] = getid3_lib::MultiByteCharString2HTML($value, $encoding);
1027  $this->info['tags_html'][$tag_name][$tag_key][$key] = str_replace('&#0;', '', getid3_lib::MultiByteCharString2HTML($value, $encoding));
1028  } else {
1029  $this->info['tags_html'][$tag_name][$tag_key][$key] = $value;
1030  }
1031  }
1032  }
1033  }
1034 
1035  $this->CharConvert($this->info['tags'][$tag_name], $encoding); // only copy gets converted!
1036  }
1037 
1038  }
1039  return true;
1040  }
MultiByteCharString2HTML($string, $charset='ISO-8859-1')
CharConvert(&$array, $encoding)
Definition: getid3.php:950
$encoding
Definition: getid3.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleAllTags() [2/2]

getID3::HandleAllTags ( )

Definition at line 1169 of file getid3.php.

References $encoding, CharConvert(), and getid3_lib\recursiveMultiByteCharString2HTML().

1169  {
1170 
1171  // key name => array (tag name, character encoding)
1172  static $tags;
1173  if (empty($tags)) {
1174  $tags = array(
1175  'asf' => array('asf' , 'UTF-16LE'),
1176  'midi' => array('midi' , 'ISO-8859-1'),
1177  'nsv' => array('nsv' , 'ISO-8859-1'),
1178  'ogg' => array('vorbiscomment' , 'UTF-8'),
1179  'png' => array('png' , 'UTF-8'),
1180  'tiff' => array('tiff' , 'ISO-8859-1'),
1181  'quicktime' => array('quicktime' , 'UTF-8'),
1182  'real' => array('real' , 'ISO-8859-1'),
1183  'vqf' => array('vqf' , 'ISO-8859-1'),
1184  'zip' => array('zip' , 'ISO-8859-1'),
1185  'riff' => array('riff' , 'ISO-8859-1'),
1186  'lyrics3' => array('lyrics3' , 'ISO-8859-1'),
1187  'id3v1' => array('id3v1' , $this->encoding_id3v1),
1188  'id3v2' => array('id3v2' , 'UTF-8'), // not according to the specs (every frame can have a different encoding), but getID3() force-converts all encodings to UTF-8
1189  'ape' => array('ape' , 'UTF-8'),
1190  'cue' => array('cue' , 'ISO-8859-1'),
1191  'matroska' => array('matroska' , 'UTF-8'),
1192  'flac' => array('vorbiscomment' , 'UTF-8'),
1193  'divxtag' => array('divx' , 'ISO-8859-1'),
1194  'iptc' => array('iptc' , 'ISO-8859-1'),
1195  );
1196  }
1197 
1198  // loop through comments array
1199  foreach ($tags as $comment_name => $tagname_encoding_array) {
1200  list($tag_name, $encoding) = $tagname_encoding_array;
1201 
1202  // fill in default encoding type if not already present
1203  if (isset($this->info[$comment_name]) && !isset($this->info[$comment_name]['encoding'])) {
1204  $this->info[$comment_name]['encoding'] = $encoding;
1205  }
1206 
1207  // copy comments if key name set
1208  if (!empty($this->info[$comment_name]['comments'])) {
1209  foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) {
1210  foreach ($valuearray as $key => $value) {
1211  if (is_string($value)) {
1212  $value = trim($value, " \r\n\t"); // do not trim nulls from $value!! Unicode characters will get mangled if trailing nulls are removed!
1213  }
1214  if ($value) {
1215  if (!is_numeric($key)) {
1216  $this->info['tags'][trim($tag_name)][trim($tag_key)][$key] = $value;
1217  } else {
1218  $this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value;
1219  }
1220  }
1221  }
1222  if ($tag_key == 'picture') {
1223  unset($this->info[$comment_name]['comments'][$tag_key]);
1224  }
1225  }
1226 
1227  if (!isset($this->info['tags'][$tag_name])) {
1228  // comments are set but contain nothing but empty strings, so skip
1229  continue;
1230  }
1231 
1232  if ($this->option_tags_html) {
1233  foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {
1234  $this->info['tags_html'][$tag_name][$tag_key] = getid3_lib::recursiveMultiByteCharString2HTML($valuearray, $encoding);
1235  }
1236  }
1237 
1238  // ID3v1 encoding detection hack start
1239  // ID3v1 is defined as always using ISO-8859-1 encoding, but it is not uncommon to find files tagged with ID3v1 using Windows-1251 or other character sets
1240  // Since ID3v1 has no concept of character sets there is no certain way to know we have the correct non-ISO-8859-1 character set, but we can guess
1241  if ($comment_name == 'id3v1') {
1242  if ($encoding == 'ISO-8859-1') {
1243  if (function_exists('iconv')) {
1244  foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {
1245  foreach ($valuearray as $key => $value) {
1246  if (preg_match('#^[\\x80-\\xFF]+$#', $value)) {
1247  foreach (array('windows-1251', 'KOI8-R') as $id3v1_bad_encoding) {
1248  if (@iconv($id3v1_bad_encoding, $id3v1_bad_encoding, $value) === $value) {
1249  $encoding = $id3v1_bad_encoding;
1250  break 3;
1251  }
1252  }
1253  }
1254  }
1255  }
1256  }
1257  }
1258  }
1259  // ID3v1 encoding detection hack end
1260 
1261  $this->CharConvert($this->info['tags'][$tag_name], $encoding); // only copy gets converted!
1262  }
1263 
1264  }
1265 
1266  // pictures can take up a lot of space, and we don't need multiple copies of them
1267  // let there be a single copy in [comments][picture], and not elsewhere
1268  if (!empty($this->info['tags'])) {
1269  $unset_keys = array('tags', 'tags_html');
1270  foreach ($this->info['tags'] as $tagtype => $tagarray) {
1271  foreach ($tagarray as $tagname => $tagdata) {
1272  if ($tagname == 'picture') {
1273  foreach ($tagdata as $key => $tagarray) {
1274  $this->info['comments']['picture'][] = $tagarray;
1275  if (isset($tagarray['data']) && isset($tagarray['image_mime'])) {
1276  if (isset($this->info['tags'][$tagtype][$tagname][$key])) {
1277  unset($this->info['tags'][$tagtype][$tagname][$key]);
1278  }
1279  if (isset($this->info['tags_html'][$tagtype][$tagname][$key])) {
1280  unset($this->info['tags_html'][$tagtype][$tagname][$key]);
1281  }
1282  }
1283  }
1284  }
1285  }
1286  foreach ($unset_keys as $unset_key) {
1287  // remove possible empty keys from (e.g. [tags][id3v2][picture])
1288  if (empty($this->info[$unset_key][$tagtype]['picture'])) {
1289  unset($this->info[$unset_key][$tagtype]['picture']);
1290  }
1291  if (empty($this->info[$unset_key][$tagtype])) {
1292  unset($this->info[$unset_key][$tagtype]);
1293  }
1294  if (empty($this->info[$unset_key])) {
1295  unset($this->info[$unset_key]);
1296  }
1297  }
1298  // remove duplicate copy of picture data from (e.g. [id3v2][comments][picture])
1299  if (isset($this->info[$tagtype]['comments']['picture'])) {
1300  unset($this->info[$tagtype]['comments']['picture']);
1301  }
1302  if (empty($this->info[$tagtype]['comments'])) {
1303  unset($this->info[$tagtype]['comments']);
1304  }
1305  if (empty($this->info[$tagtype])) {
1306  unset($this->info[$tagtype]);
1307  }
1308  }
1309  }
1310  return true;
1311  }
CharConvert(&$array, $encoding)
Definition: getid3.php:950
$encoding
Definition: getid3.php:21
static recursiveMultiByteCharString2HTML($data, $charset='ISO-8859-1')
+ Here is the call graph for this function:

◆ include_module()

getID3::include_module (   $name)

Definition at line 1606 of file getid3.php.

Referenced by analyze().

1606  {
1607  //if (!file_exists($this->include_path.'module.'.$name.'.php')) {
1608  if (!file_exists(GETID3_INCLUDEPATH.'module.'.$name.'.php')) {
1609  throw new getid3_exception('Required module.'.$name.'.php is missing.');
1610  }
1611  include_once(GETID3_INCLUDEPATH.'module.'.$name.'.php');
1612  return true;
1613  }
+ Here is the caller graph for this function:

◆ openfile()

getID3::openfile (   $filename,
  $filesize = null 
)

Definition at line 246 of file getid3.php.

References $encoding, $filename, error(), getid3_lib\getFileSizeSyscall(), getid3_lib\intValueSupported(), getid3_lib\mb_basename(), version(), and warning().

Referenced by analyze().

246  {
247  try {
248  if (!empty($this->startup_error)) {
249  throw new getid3_exception($this->startup_error);
250  }
251  if (!empty($this->startup_warning)) {
252  $this->warning($this->startup_warning);
253  }
254 
255  // init result array and set parameters
256  $this->filename = $filename;
257  $this->info = array();
258  $this->info['GETID3_VERSION'] = $this->version();
259  $this->info['php_memory_limit'] = (($this->memory_limit > 0) ? $this->memory_limit : false);
260 
261  // remote files not supported
262  if (preg_match('/^(ht|f)tp:\/\//', $filename)) {
263  throw new getid3_exception('Remote files are not supported - please copy the file locally first');
264  }
265 
266  $filename = str_replace('/', DIRECTORY_SEPARATOR, $filename);
267  $filename = preg_replace('#(.+)'.preg_quote(DIRECTORY_SEPARATOR).'{2,}#U', '\1'.DIRECTORY_SEPARATOR, $filename);
268 
269  // open local file
270  //if (is_readable($filename) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) { // see http://www.getid3.org/phpBB3/viewtopic.php?t=1720
271  if ((is_readable($filename) || file_exists($filename)) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) {
272  // great
273  } else {
274  $errormessagelist = array();
275  if (!is_readable($filename)) {
276  $errormessagelist[] = '!is_readable';
277  }
278  if (!is_file($filename)) {
279  $errormessagelist[] = '!is_file';
280  }
281  if (!file_exists($filename)) {
282  $errormessagelist[] = '!file_exists';
283  }
284  if (empty($errormessagelist)) {
285  $errormessagelist[] = 'fopen failed';
286  }
287  throw new getid3_exception('Could not open "'.$filename.'" ('.implode('; ', $errormessagelist).')');
288  }
289 
290  $this->info['filesize'] = (!is_null($filesize) ? $filesize : filesize($filename));
291  // set redundant parameters - might be needed in some include file
292  // filenames / filepaths in getID3 are always expressed with forward slashes (unix-style) for both Windows and other to try and minimize confusion
293  $filename = str_replace('\\', '/', $filename);
294  $this->info['filepath'] = str_replace('\\', '/', realpath(dirname($filename)));
295  $this->info['filename'] = getid3_lib::mb_basename($filename);
296  $this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename'];
297 
298 
299  // option_max_2gb_check
300  if ($this->option_max_2gb_check) {
301  // PHP (32-bit all, and 64-bit Windows) doesn't support integers larger than 2^31 (~2GB)
302  // filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
303  // ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
304  $fseek = fseek($this->fp, 0, SEEK_END);
305  if (($fseek < 0) || (($this->info['filesize'] != 0) && (ftell($this->fp) == 0)) ||
306  ($this->info['filesize'] < 0) ||
307  (ftell($this->fp) < 0)) {
308  $real_filesize = getid3_lib::getFileSizeSyscall($this->info['filenamepath']);
309 
310  if ($real_filesize === false) {
311  unset($this->info['filesize']);
312  fclose($this->fp);
313  throw new getid3_exception('Unable to determine actual filesize. File is most likely larger than '.round(PHP_INT_MAX / 1073741824).'GB and is not supported by PHP.');
314  } elseif (getid3_lib::intValueSupported($real_filesize)) {
315  unset($this->info['filesize']);
316  fclose($this->fp);
317  throw new getid3_exception('PHP seems to think the file is larger than '.round(PHP_INT_MAX / 1073741824).'GB, but filesystem reports it as '.number_format($real_filesize, 3).'GB, please report to info@getid3.org');
318  }
319  $this->info['filesize'] = $real_filesize;
320  $this->warning('File is larger than '.round(PHP_INT_MAX / 1073741824).'GB (filesystem reports it as '.number_format($real_filesize, 3).'GB) and is not properly supported by PHP.');
321  }
322  }
323 
324  // set more parameters
325  $this->info['avdataoffset'] = 0;
326  $this->info['avdataend'] = $this->info['filesize'];
327  $this->info['fileformat'] = ''; // filled in later
328  $this->info['audio']['dataformat'] = ''; // filled in later, unset if not used
329  $this->info['video']['dataformat'] = ''; // filled in later, unset if not used
330  $this->info['tags'] = array(); // filled in later, unset if not used
331  $this->info['error'] = array(); // filled in later, unset if not used
332  $this->info['warning'] = array(); // filled in later, unset if not used
333  $this->info['comments'] = array(); // filled in later, unset if not used
334  $this->info['encoding'] = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired
335 
336  return true;
337 
338  } catch (Exception $e) {
339  $this->error($e->getMessage());
340  }
341  return false;
342  }
static intValueSupported($num)
Definition: getid3.lib.php:80
warning($message)
Definition: getid3.php:411
$filename
Definition: getid3.php:46
static getFileSizeSyscall($path)
version()
Definition: getid3.php:222
$encoding
Definition: getid3.php:21
static mb_basename($path, $suffix=null)
Workaround for Bug #37268 (https://bugs.php.net/bug.php?id=37268)
error($message)
Definition: getid3.php:401
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ProcessAudioStreams() [1/2]

getID3::ProcessAudioStreams ( )

Definition at line 1286 of file getid3.php.

Referenced by analyze().

1286  {
1287  if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) {
1288  if (!isset($this->info['audio']['streams'])) {
1289  foreach ($this->info['audio'] as $key => $value) {
1290  if ($key != 'streams') {
1291  $this->info['audio']['streams'][0][$key] = $value;
1292  }
1293  }
1294  }
1295  }
1296  return true;
1297  }
+ Here is the caller graph for this function:

◆ ProcessAudioStreams() [2/2]

getID3::ProcessAudioStreams ( )

Definition at line 1589 of file getid3.php.

1589  {
1590  if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) {
1591  if (!isset($this->info['audio']['streams'])) {
1592  foreach ($this->info['audio'] as $key => $value) {
1593  if ($key != 'streams') {
1594  $this->info['audio']['streams'][0][$key] = $value;
1595  }
1596  }
1597  }
1598  }
1599  return true;
1600  }

◆ setOption() [1/2]

getID3::setOption (   $optArray)

Definition at line 153 of file getid3.php.

153  {
154  if (!is_array($optArray) || empty($optArray)) {
155  return false;
156  }
157  foreach ($optArray as $opt => $val) {
158  if (isset($this, $opt) === false) {
159  continue;
160  }
161  $this->$opt = $val;
162  }
163  return true;
164  }

◆ setOption() [2/2]

getID3::setOption (   $optArray)

Definition at line 232 of file getid3.php.

232  {
233  if (!is_array($optArray) || empty($optArray)) {
234  return false;
235  }
236  foreach ($optArray as $opt => $val) {
237  if (isset($this->$opt) === false) {
238  continue;
239  }
240  $this->$opt = $val;
241  }
242  return true;
243  }

◆ version()

getID3::version ( )

Definition at line 222 of file getid3.php.

Referenced by openfile().

222  {
223  return self::VERSION;
224  }
+ Here is the caller graph for this function:

◆ warning() [1/2]

getID3::warning (   $message)

Definition at line 411 of file getid3.php.

Referenced by __construct(), analyze(), getHashdata(), getID3(), openfile(), and getid3_handler\saveAttachment().

411  {
412  $this->info['warning'][] = $message;
413  return true;
414  }
+ Here is the caller graph for this function:

◆ warning() [2/2]

getID3::warning (   $message)

Definition at line 507 of file getid3.php.

507  {
508  $this->info['warning'][] = $message;
509  return true;
510  }

Field Documentation

◆ $encoding

getID3::$encoding = 'ISO-8859-1'

Definition at line 21 of file getid3.php.

Referenced by analyze(), CharConvert(), HandleAllTags(), and openfile().

◆ $encoding_id3v1

getID3::$encoding_id3v1 = 'ISO-8859-1'

Definition at line 24 of file getid3.php.

◆ $filename

◆ $fp

getID3::$fp

Definition at line 103 of file getid3.php.

Referenced by analyze().

◆ $info

getID3::$info

Definition at line 104 of file getid3.php.

Referenced by analyze(), error(), and GetFileFormat().

◆ $memory_limit

getID3::$memory_limit = 0

Definition at line 106 of file getid3.php.

Referenced by getID3().

◆ $option_extra_info

getID3::$option_extra_info = true

Definition at line 37 of file getid3.php.

◆ $option_fread_buffer_size

getID3::$option_fread_buffer_size = 32768

Definition at line 99 of file getid3.php.

Referenced by fread_buffer_size().

◆ $option_max_2gb_check

getID3::$option_max_2gb_check = true

Definition at line 43 of file getid3.php.

◆ $option_md5_data

getID3::$option_md5_data = false

Definition at line 40 of file getid3.php.

◆ $option_md5_data_source

getID3::$option_md5_data_source = false

Definition at line 41 of file getid3.php.

◆ $option_save_attachments

getID3::$option_save_attachments = true

Definition at line 90 of file getid3.php.

◆ $option_sha1_data

getID3::$option_sha1_data = false

Definition at line 42 of file getid3.php.

◆ $option_tag_apetag

getID3::$option_tag_apetag = true

Definition at line 32 of file getid3.php.

◆ $option_tag_id3v1

getID3::$option_tag_id3v1 = true

Definition at line 29 of file getid3.php.

◆ $option_tag_id3v2

getID3::$option_tag_id3v2 = true

Definition at line 30 of file getid3.php.

◆ $option_tag_lyrics3

getID3::$option_tag_lyrics3 = true

Definition at line 31 of file getid3.php.

◆ $option_tags_html

getID3::$option_tags_html = true

Definition at line 34 of file getid3.php.

◆ $option_tags_process

getID3::$option_tags_process = true

Definition at line 33 of file getid3.php.

◆ $startup_error

getID3::$startup_error = ''
protected

Definition at line 109 of file getid3.php.

◆ $startup_warning

getID3::$startup_warning = ''
protected

Definition at line 110 of file getid3.php.

◆ $tempdir

getID3::$tempdir = '*'

Definition at line 26 of file getid3.php.

◆ ATTACHMENTS_INLINE

const getID3::ATTACHMENTS_INLINE = true

Definition at line 116 of file getid3.php.

Referenced by getid3_handler\saveAttachment().

◆ ATTACHMENTS_NONE

const getID3::ATTACHMENTS_NONE = false

◆ FREAD_BUFFER_SIZE

const getID3::FREAD_BUFFER_SIZE = 32768

Definition at line 113 of file getid3.php.

Referenced by getid3_lib\CopyFileParts().

◆ VERSION


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