Ampache PHP Cross Reference Groupware Applications

Source: /modules/getid3/write.lyrics3.php - 72 lines - 2657 bytes - Summary - Text - Print

   1  <?php
   2  /////////////////////////////////////////////////////////////////
   3  /// getID3() by James Heinrich <info@getid3.org>               //
   4  //  available at http://getid3.sourceforge.net                 //
   5  //            or http://www.getid3.org                         //
   6  //          also https://github.com/JamesHeinrich/getID3       //
   7  /////////////////////////////////////////////////////////////////
   8  // See readme.txt for more details                             //
   9  /////////////////////////////////////////////////////////////////
  10  //                                                             //
  11  // write.lyrics3.php                                           //
  12  // module for writing Lyrics3 tags                             //
  13  // dependencies: module.tag.lyrics3.php                        //
  14  //                                                            ///
  15  /////////////////////////////////////////////////////////////////
  16  
  17  
  18  class getid3_write_lyrics3
  19  {
  20      public $filename;
  21      public $tag_data;
  22      //public $lyrics3_version = 2;       // 1 or 2
  23      public $warnings        = array(); // any non-critical errors will be stored here
  24      public $errors          = array(); // any critical errors will be stored here
  25  
  26  	public function getid3_write_lyrics3() {
  27          return true;
  28      }
  29  
  30  	public function WriteLyrics3() {
  31          $this->errors[] = 'WriteLyrics3() not yet functional - cannot write Lyrics3';
  32          return false;
  33      }
  34  	public function DeleteLyrics3() {
  35          // Initialize getID3 engine
  36          $getID3 = new getID3;
  37          $ThisFileInfo = $getID3->analyze($this->filename);
  38          if (isset($ThisFileInfo['lyrics3']['tag_offset_start']) && isset($ThisFileInfo['lyrics3']['tag_offset_end'])) {
  39              if (is_readable($this->filename) && is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'a+b'))) {
  40  
  41                  flock($fp, LOCK_EX);
  42                  $oldignoreuserabort = ignore_user_abort(true);
  43  
  44                  fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_end']);
  45                  $DataAfterLyrics3 = '';
  46                  if ($ThisFileInfo['filesize'] > $ThisFileInfo['lyrics3']['tag_offset_end']) {
  47                      $DataAfterLyrics3 = fread($fp, $ThisFileInfo['filesize'] - $ThisFileInfo['lyrics3']['tag_offset_end']);
  48                  }
  49  
  50                  ftruncate($fp, $ThisFileInfo['lyrics3']['tag_offset_start']);
  51  
  52                  if (!empty($DataAfterLyrics3)) {
  53                      fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_start']);
  54                      fwrite($fp, $DataAfterLyrics3, strlen($DataAfterLyrics3));
  55                  }
  56  
  57                  flock($fp, LOCK_UN);
  58                  fclose($fp);
  59                  ignore_user_abort($oldignoreuserabort);
  60  
  61                  return true;
  62  
  63              } else {
  64                  $this->errors[] = 'Cannot fopen('.$this->filename.', "a+b")';
  65                  return false;
  66              }
  67          }
  68          // no Lyrics3 present
  69          return true;
  70      }
  71  
  72  }

title

Description

title

Description

title

Description

title

title

Body