ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
write.lyrics3.php
Go to the documentation of this file.
1 <?php
4 // available at http://getid3.sourceforge.net //
5 // or http://www.getid3.org //
6 // also https://github.com/JamesHeinrich/getID3 //
8 // See readme.txt for more details //
10 // //
11 // write.lyrics3.php //
12 // module for writing Lyrics3 tags //
13 // dependencies: module.tag.lyrics3.php //
14 // ///
16 
17 
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 __construct() {
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 }
analyze($filename, $filesize=null, $original_filename='')
Definition: getid3.php:357
getID3() by James Heinrich info@getid3.org //
Create styles array
The data for the language used.