21                $info = &$this->getid3->info;
 
   24                $info[
'bonk'] = array();
 
   25                $thisfile_bonk        = &
$info[
'bonk'];
 
   27                $thisfile_bonk[
'dataoffset'] = 
$info[
'avdataoffset'];
 
   28                $thisfile_bonk[
'dataend']    = 
$info[
'avdataend'];
 
   32                        $this->
warning(
'Unable to parse BONK file from end (v0.6+ preferred method) because PHP filesystem functions only support up to '.round(PHP_INT_MAX / 1073741824).
'GB');
 
   37                        $this->
fseek($thisfile_bonk[
'dataend'] - 8);
 
   38                        $PossibleBonkTag = $this->
fread(8);
 
   41                                $this->
fseek(0 - $BonkTagSize, SEEK_CUR);
 
   42                                $BonkTagOffset = $this->
ftell();
 
   43                                $TagHeaderTest = $this->
fread(5);
 
   44                                if (($TagHeaderTest{0} != 
"\x00") || (substr($PossibleBonkTag, 4, 4) != strtolower(substr($PossibleBonkTag, 4, 4)))) {
 
   48                                $BonkTagName = substr($TagHeaderTest, 1, 4);
 
   50                                $thisfile_bonk[$BonkTagName][
'size']   = $BonkTagSize;
 
   51                                $thisfile_bonk[$BonkTagName][
'offset'] = $BonkTagOffset;
 
   53                                $NextTagEndOffset = $BonkTagOffset - 8;
 
   54                                if ($NextTagEndOffset < $thisfile_bonk[
'dataoffset']) {
 
   55                                        if (empty(
$info[
'audio'][
'encoder'])) {
 
   56                                                $info[
'audio'][
'encoder'] = 
'Extended BONK v0.9+';
 
   60                                $this->
fseek($NextTagEndOffset);
 
   61                                $PossibleBonkTag = $this->
fread(8);
 
   67                if (empty($thisfile_bonk[
'BONK'])) {
 
   68                        $this->
fseek($thisfile_bonk[
'dataoffset']);
 
   70                                $TagHeaderTest = $this->
fread(5);
 
   71                                switch ($TagHeaderTest) {
 
   73                                                if (empty(
$info[
'audio'][
'encoder'])) {
 
   74                                                        $info[
'audio'][
'encoder'] = 
'BONK v0.4';
 
   79                                                $info[
'audio'][
'encoder'] = 
'Extended BONK v0.5';
 
   85                                $BonkTagName = substr($TagHeaderTest, 1, 4);
 
   86                                $thisfile_bonk[$BonkTagName][
'size']   = $thisfile_bonk[
'dataend'] - $thisfile_bonk[
'dataoffset'];
 
   87                                $thisfile_bonk[$BonkTagName][
'offset'] = $thisfile_bonk[
'dataoffset'];
 
   94                if (empty($thisfile_bonk[
'INFO']) && isset($thisfile_bonk[
'META'][
'tags'][
'info'])) {
 
   95                        $this->
fseek($thisfile_bonk[
'META'][
'tags'][
'info']);
 
   96                        $TagHeaderTest = $this->
fread(5);
 
   97                        if ($TagHeaderTest == 
"\x00".
'INFO') {
 
   98                                $info[
'audio'][
'encoder'] = 
'Extended BONK v0.6 - v0.8';
 
  100                                $BonkTagName = substr($TagHeaderTest, 1, 4);
 
  101                                $thisfile_bonk[$BonkTagName][
'size']   = $thisfile_bonk[
'dataend'] - $thisfile_bonk[
'dataoffset'];
 
  102                                $thisfile_bonk[$BonkTagName][
'offset'] = $thisfile_bonk[
'dataoffset'];
 
  107                if (empty(
$info[
'audio'][
'encoder'])) {
 
  108                        $info[
'audio'][
'encoder'] = 
'Extended BONK v0.9+';
 
  110                if (empty($thisfile_bonk[
'BONK'])) {
 
  111                        unset(
$info[
'bonk']);
 
  118                $info = &$this->getid3->info;
 
  119                switch ($BonkTagName) {
 
  122                                $thisfile_bonk_BONK = &
$info[
'bonk'][
'BONK'];
 
  124                                $BonkData = 
"\x00".
'BONK'.$this->
fread(17);
 
  136                                $info[
'avdataoffset'] = $thisfile_bonk_BONK[
'offset'] + 5 + 17;
 
  137                                $info[
'avdataend']    = $thisfile_bonk_BONK[
'offset'] + $thisfile_bonk_BONK[
'size'];
 
  139                                $info[
'fileformat']               = 
'bonk';
 
  140                                $info[
'audio'][
'dataformat']      = 
'bonk';
 
  141                                $info[
'audio'][
'bitrate_mode']    = 
'vbr'; 
 
  142                                $info[
'audio'][
'channels']        = $thisfile_bonk_BONK[
'channels'];
 
  143                                $info[
'audio'][
'sample_rate']     = $thisfile_bonk_BONK[
'sample_rate'];
 
  144                                $info[
'audio'][
'channelmode']     = ($thisfile_bonk_BONK[
'joint_stereo'] ? 
'joint stereo' : 
'stereo');
 
  145                                $info[
'audio'][
'lossless']        = $thisfile_bonk_BONK[
'lossless'];
 
  146                                $info[
'audio'][
'codec']           = 
'bonk';
 
  148                                $info[
'playtime_seconds'] = $thisfile_bonk_BONK[
'number_samples'] / ($thisfile_bonk_BONK[
'sample_rate'] * $thisfile_bonk_BONK[
'channels']);
 
  149                                if (
$info[
'playtime_seconds'] > 0) {
 
  150                                        $info[
'audio'][
'bitrate'] = ((
$info[
'bonk'][
'dataend'] - 
$info[
'bonk'][
'dataoffset']) * 8) / 
$info[
'playtime_seconds'];
 
  156                                $thisfile_bonk_INFO = &
$info[
'bonk'][
'INFO'];
 
  159                                $thisfile_bonk_INFO[
'entries_count'] = 0;
 
  160                                $NextInfoDataPair = $this->
fread(5);
 
  162                                        while (!
feof($this->getid3->fp)) {
 
  167                                                $NextInfoDataPair = $this->
fread(5);
 
  169                                                        $this->
fseek(-5, SEEK_CUR);
 
  172                                                $thisfile_bonk_INFO[
'entries_count']++;
 
  178                                $BonkData = 
"\x00".
'META'.$this->
fread(
$info[
'bonk'][
'META'][
'size'] - 5);
 
  181                                $MetaTagEntries = floor(((strlen($BonkData) - 8) - 6) / 8); 
 
  183                                for (
$i = 0; 
$i < $MetaTagEntries; 
$i++) {
 
  184                                        $MetaEntryTagName   =                              substr($BonkData, $offset, 4);
 
  188                                        $info[
'bonk'][
'META'][
'tags'][$MetaEntryTagName] = $MetaEntryTagOffset;
 
  193                                $info[
'audio'][
'encoder'] = 
'Extended BONK v0.9+';
 
  196                                if (class_exists(
'getid3_id3v2')) {
 
  197                                        $getid3_temp = 
new getID3();
 
  198                                        $getid3_temp->openfile($this->getid3->filename);
 
  200                                        $getid3_id3v2->StartingOffset = 
$info[
'bonk'][
' ID3'][
'offset'] + 2;
 
  201                                        $info[
'bonk'][
' ID3'][
'valid'] = $getid3_id3v2->Analyze();
 
  202                                        if (
$info[
'bonk'][
' ID3'][
'valid']) {
 
  203                                                $info[
'id3v2'] = $getid3_temp->info[
'id3v2'];
 
  205                                        unset($getid3_temp, $getid3_id3v2);
 
  210                                $this->
warning(
'Unexpected Bonk tag "'.$BonkTagName.
'" at offset '.
$info[
'bonk'][$BonkTagName][
'offset']);
 
  217                static $BonkIsValidTagName = array(
'BONK', 
'INFO', 
' ID3', 
'META');
 
  218                foreach ($BonkIsValidTagName as $validtagname) {
 
  219                        if ($validtagname == $PossibleBonkTag) {
 
  221                        } elseif ($ignorecase && (strtolower($validtagname) == strtolower($PossibleBonkTag))) {
 
An exception for terminatinating execution or to throw for unit testing.
getID3() by James Heinrich info@getid3.org //
HandleBonkTags($BonkTagName)
static BonkIsValidTagName($PossibleBonkTag, $ignorecase=false)
fseek($bytes, $whence=SEEK_SET)
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
static LittleEndian2Int($byteword, $signed=false)
static intValueSupported($num)