ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Lyrics3.php
Go to the documentation of this file.
1<?php
2
3namespace GetId3\Write;
4
6
9// available at http://getid3.sourceforge.net //
10// or http://www.getid3.org //
12// See readme.txt for more details //
14// //
15// write.lyrics3.php //
16// module for writing Lyrics3 tags //
17// dependencies: module.tag.lyrics3.php //
18// ///
20
30{
31 public $filename;
32 public $tag_data;
33 //var $lyrics3_version = 2; // 1 or 2
38 public $warnings = array(); // any non-critical errors will be stored here
43 public $errors = array(); // any critical errors will be stored here
44
49 public function __construct()
50 {
51 return true;
52 }
53
58 public function WriteLyrics3()
59 {
60 $this->errors[] = 'WriteLyrics3() not yet functional - cannot write Lyrics3';
61
62 return false;
63 }
64 public function DeleteLyrics3()
65 {
66 // Initialize GetId3 engine
67 $getID3 = new GetId3Core();
68 $ThisFileInfo = $getID3->analyze($this->filename);
69 if (isset($ThisFileInfo['lyrics3']['tag_offset_start']) && isset($ThisFileInfo['lyrics3']['tag_offset_end'])) {
70 if (is_readable($this->filename) && is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'a+b'))) {
71
72 flock($fp, LOCK_EX);
73 $oldignoreuserabort = ignore_user_abort(true);
74
75 fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_end'], SEEK_SET);
76 $DataAfterLyrics3 = '';
77 if ($ThisFileInfo['filesize'] > $ThisFileInfo['lyrics3']['tag_offset_end']) {
78 $DataAfterLyrics3 = fread($fp, $ThisFileInfo['filesize'] - $ThisFileInfo['lyrics3']['tag_offset_end']);
79 }
80
81 ftruncate($fp, $ThisFileInfo['lyrics3']['tag_offset_start']);
82
83 if (!empty($DataAfterLyrics3)) {
84 fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_start'], SEEK_SET);
85 fwrite($fp, $DataAfterLyrics3, strlen($DataAfterLyrics3));
86 }
87
88 flock($fp, LOCK_UN);
89 fclose($fp);
90 ignore_user_abort($oldignoreuserabort);
91
92 return true;
93
94 } else {
95 $this->errors[] = 'Cannot fopen('.$this->filename.', "a+b")';
96
97 return false;
98 }
99 }
100 // no Lyrics3 present
101 return true;
102 }
103
104}
An exception for terminatinating execution or to throw for unit testing.
GetId3() by James Heinrich info@getid3.org //.
Definition: GetId3Core.php:26
fseek($bytes, $whence=SEEK_SET)
GetId3() by James Heinrich info@getid3.org //.
Definition: Lyrics3.php:32
$errors