File indexing completed on 2024-05-12 05:58:15

0001 <?php
0002 /////////////////////////////////////////////////////////////////
0003 /// getID3() by James Heinrich <info@getid3.org>               //
0004 //  available at http://getid3.sourceforge.net                 //
0005 //            or http://www.getid3.org                         //
0006 //          also https://github.com/JamesHeinrich/getID3       //
0007 /////////////////////////////////////////////////////////////////
0008 // See readme.txt for more details                             //
0009 /////////////////////////////////////////////////////////////////
0010 //                                                             //
0011 // module.archive.efax.php                                     //
0012 // module for analyzing eFax files                             //
0013 // dependencies: NONE                                          //
0014 //                                                            ///
0015 /////////////////////////////////////////////////////////////////
0016 
0017 
0018 class getid3_efax extends getid3_handler
0019 {
0020 
0021   public function Analyze() {
0022     $info = &$this->getid3->info;
0023 
0024     $this->fseek($info['avdataoffset']);
0025     $efaxheader = $this->fread(1024);
0026 
0027     $info['efax']['header']['magic'] = substr($efaxheader, 0, 2);
0028     if ($info['efax']['header']['magic'] != "\xDC\xFE") {
0029       $info['error'][] = 'Invalid eFax byte order identifier (expecting DC FE, found '.getid3_lib::PrintHexBytes($info['efax']['header']['magic']).') at offset '.$info['avdataoffset'];
0030       return false;
0031     }
0032     $info['fileformat'] = 'efax';
0033 
0034     $info['efax']['header']['filesize'] = getid3_lib::LittleEndian2Int(substr($efaxheader, 2, 4));
0035     if ($info['efax']['header']['filesize'] != $info['filesize']) {
0036       $info['error'][] = 'Probable '.(($info['efax']['header']['filesize'] > $info['filesize']) ? 'truncated' : 'corrupt').' file, expecting '.$info['efax']['header']['filesize'].' bytes, found '.$info['filesize'].' bytes';
0037     }
0038     $info['efax']['header']['software1'] =                        rtrim(substr($efaxheader,  26, 32), "\x00");
0039     $info['efax']['header']['software2'] =                        rtrim(substr($efaxheader,  58, 32), "\x00");
0040     $info['efax']['header']['software3'] =                        rtrim(substr($efaxheader,  90, 32), "\x00");
0041 
0042     $info['efax']['header']['pages']      = getid3_lib::LittleEndian2Int(substr($efaxheader, 198, 2));
0043     $info['efax']['header']['data_bytes'] = getid3_lib::LittleEndian2Int(substr($efaxheader, 202, 4));
0044 
0045 $info['error'][] = 'eFax parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
0046 return false;
0047 
0048     return true;
0049   }
0050 
0051 }