ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 //
7 // See readme.txt for more details //
9 // //
10 // write.lyrics3.php //
11 // module for writing Lyrics3 tags //
12 // dependencies: module.tag.lyrics3.php //
13 // ///
15 
16 
18 {
19  var $filename;
20  var $tag_data;
21  //var $lyrics3_version = 2; // 1 or 2
22  var $warnings = array(); // any non-critical errors will be stored here
23  var $errors = array(); // any critical errors will be stored here
24 
25  function getid3_write_lyrics3() {
26  return true;
27  }
28 
29  function WriteLyrics3() {
30  $this->errors[] = 'WriteLyrics3() not yet functional - cannot write Lyrics3';
31  return false;
32  }
33 
34  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 ($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'], SEEK_SET);
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'], SEEK_SET);
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 
65  $this->errors[] = 'Cannot open "'.$this->filename.'" in "a+b" mode';
66  return false;
67 
68  }
69  }
70  // no Lyrics3 present
71  return true;
72  }
73 
74 
75 
76 }
77 
78 ?>