getid3_apetag::Analyze() –

You appear to be a bot. Output may be restricted

Description

Usage

$bool = getid3_apetag::Analyze();

Parameters

Returns

bool

Source

File name: wordpress/wp-includes/ID3/module.tag.apetag.php
Lines:

1 to 100 of 315
  public function Analyze() {
    $info = &$this->getid3->info;

    if (!getid3_lib::intValueSupported($info['filesize'])) {
      $this->warning('Unable to check for APEtags because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB');
      return false;
    }

    $id3v1tagsize     = 128;
    $apetagheadersize = 32;
    $lyrics3tagsize   = 10;

    if ($this->overrideendoffset == 0) {

      $this->fseek(0 - $id3v1tagsize - $apetagheadersize - $lyrics3tagsize, SEEK_END);
      $APEfooterID3v1 = $this->fread($id3v1tagsize + $apetagheadersize + $lyrics3tagsize);

      //if (preg_match('/APETAGEX.{24}TAG.{125}$/i', $APEfooterID3v1)) {
      if (substr($APEfooterID3v1, strlen($APEfooterID3v1) - $id3v1tagsize - $apetagheadersize, 8) == 'APETAGEX') {

        // APE tag found before ID3v1
        $info['ape']['tag_offset_end'] = $info['filesize'] - $id3v1tagsize;

      //} elseif (preg_match('/APETAGEX.{24}$/i', $APEfooterID3v1)) {
      } elseif (substr($APEfooterID3v1, strlen($APEfooterID3v1) - $apetagheadersize, 8) == 'APETAGEX') {

        // APE tag found, no ID3v1
        $info['ape']['tag_offset_end'] = $info['filesize'];

      }

    } else {

      $this->fseek($this->overrideendoffset - $apetagheadersize);
      if ($this->fread(8) == 'APETAGEX') {
        $info['ape']['tag_offset_end'] = $this->overrideendoffset;
      }

    }
    if (!isset($info['ape']['tag_offset_end'])) {

      // APE tag not found
      unset($info['ape']);
      return false;

    }

    // shortcut
    $thisfile_ape = &$info['ape'];

    $this->fseek($thisfile_ape['tag_offset_end'] - $apetagheadersize);
    $APEfooterData = $this->fread(32);
    if (!($thisfile_ape['footer'] = $this->getid3_apetag::parseAPEheaderFooter($APEfooterData))) {
      $this->error('Error parsing APE footer at offset '.$thisfile_ape['tag_offset_end']);
      return false;
    }

    if (isset($thisfile_ape['footer']['flags']['header']) && $thisfile_ape['footer']['flags']['header']) {
      $this->fseek($thisfile_ape['tag_offset_end'] - $thisfile_ape['footer']['raw']['tagsize'] - $apetagheadersize);
      $thisfile_ape['tag_offset_start'] = $this->ftell();
      $APEtagData = $this->fread($thisfile_ape['footer']['raw']['tagsize'] + $apetagheadersize);
    } else {
      $thisfile_ape['tag_offset_start'] = $thisfile_ape['tag_offset_end'] - $thisfile_ape['footer']['raw']['tagsize'];
      $this->fseek($thisfile_ape['tag_offset_start']);
      $APEtagData = $this->fread($thisfile_ape['footer']['raw']['tagsize']);
    }
    $info['avdataend'] = $thisfile_ape['tag_offset_start'];

    if (isset($info['id3v1']['tag_offset_start']) && ($info['id3v1']['tag_offset_start'] < $thisfile_ape['tag_offset_end'])) {
      $this->warning('ID3v1 tag information ignored since it appears to be a false synch in APEtag data');
      unset($info['id3v1']);
      foreach ($info['warning'] as $key => $value) {
        if ($value == 'Some ID3v1 fields do not use NULL characters for padding') {
          unset($info['warning'][$key]);
          sort($info['warning']);
          break;
        }
      }
    }

    $offset = 0;
    if (isset($thisfile_ape['footer']['flags']['header']) && $thisfile_ape['footer']['flags']['header']) {
      if ($thisfile_ape['header'] = $this->getid3_apetag::parseAPEheaderFooter(substr($APEtagData, 0, $apetagheadersize))) {
        $offset += $apetagheadersize;
      } else {
        $this->error('Error parsing APE header at offset '.$thisfile_ape['tag_offset_start']);
        return false;
      }
    }

    // shortcut
    $info['replay_gain'] = array();
    $thisfile_replaygain = &$info['replay_gain'];

    for ($i = 0; $i < $thisfile_ape['footer']['raw']['tag_items']; $i++) {
      $value_size = getid3_lib::LittleEndian2Int(substr($APEtagData, $offset, 4));
      $offset += 4;
      $item_flags = getid3_lib::LittleEndian2Int(substr($APEtagData, $offset, 4));
      $offset += 4;
      if (strstr(substr($APEtagData, $offset), "\x00") === false) {
 

 View on GitHub View on Trac