Example #1
0
         if (!empty($ThisFileInfo['tags'])) {
             $Album = trim(str_replace(strstr($ThisFileInfo['comments']['album'][0], ' ['), '', $ThisFileInfo['comments']['album'][0]));
             $Track = (string) intval(str_replace(' [', '', str_replace(']', '', strstr($ThisFileInfo['comments']['album'][0], ' ['))));
             if ($Track == '0') {
                 $Track = '';
             }
             if ($Album && $Track) {
                 echo '<hr>' . htmlentities($row['filename']) . '<br>';
                 echo '<i>' . htmlentities($Album) . '</i> (track #' . $Track . ')<br>';
                 echo '<b>ID3v2:</b> ' . (RemoveID3v2($row['filename'], false) ? 'removed' : 'REMOVAL FAILED!') . ', ';
                 $WriteID3v1_title = isset($ThisFileInfo['comments']['title'][0]) ? $ThisFileInfo['comments']['title'][0] : '';
                 $WriteID3v1_artist = isset($ThisFileInfo['comments']['artist'][0]) ? $ThisFileInfo['comments']['artist'][0] : '';
                 $WriteID3v1_year = isset($ThisFileInfo['comments']['year'][0]) ? $ThisFileInfo['comments']['year'][0] : '';
                 $WriteID3v1_comment = isset($ThisFileInfo['comments']['comment'][0]) ? $ThisFileInfo['comments']['comment'][0] : '';
                 $WriteID3v1_genreid = isset($ThisFileInfo['comments']['genreid'][0]) ? $ThisFileInfo['comments']['genreid'][0] : '';
                 echo '<b>ID3v1:</b> ' . (WriteID3v1($row['filename'], $WriteID3v1_title, $WriteID3v1_artist, $Album, $WriteID3v1_year, $WriteID3v1_comment, $WriteID3v1_genreid, $Track, false) ? 'updated' : 'UPDATE FAILED') . '<br>';
             } else {
                 echo ' . ';
             }
         } else {
             echo '<hr>FAILED<br>' . htmlentities($row['filename']) . '<hr>';
         }
         flush();
     }
 } else {
     echo '<b>' . number_format(mysql_num_rows($result)) . '</b> files with <b>[??]</b>-format track numbers in album field:<br>';
     if (mysql_num_rows($result) > 0) {
         echo '(<a href="' . htmlentities($_SERVER['PHP_SELF'] . '?trackinalbum=1&m3u=.m3u') . '">.m3u version</a>)<br>';
         echo '<a href="' . htmlentities($_SERVER['PHP_SELF'] . '?trackinalbum=1&autofix=1') . '">Try to auto-fix</a><br>';
         echo '<table border="1" cellspacing="0" cellpadding="4">';
         while ($row = mysql_fetch_array($result)) {
 function alterFile($file, $data)
 {
     echo 'starting to write tag to ' . $file . "<br>";
     $data['tags']['id3v2']['TIT2']['encodingid'] = 0;
     $data['tags']['id3v2']['TPE1']['encodingid'] = 0;
     $data['tags']['id3v2']['TALB']['encodingid'] = 0;
     $data['tags']['id3v2']['TYER']['encodingid'] = 0;
     $data['tags']['id3v2']['TRCK']['encodingid'] = 0;
     $data['tags']['id3v2']['TCON']['encodingid'] = 0;
     //$data['tags']['id3v2']['COMM'][0]['encodingid'] = 0;
     //$data['tags']['id3v2']['COMM'][0]['language'] = 'eng';
     $data['tags']['id3v2']['TIT2']['data'] = $data['name'];
     $data['tags']['id3v2']['TPE1']['data'] = $data['artist'];
     $data['tags']['id3v2']['TALB']['data'] = $data['album'];
     $data['tags']['id3v2']['TYER']['data'] = $data['year'];
     $data['tags']['id3v2']['TRCK']['data'] = $data['track'];
     $data['tags']['id3v2']['TCON']['data'] = '(' . $data['genre'] . ')';
     //$data['tags']['id3v2']['COMM'][0]['data'] = $data['comment'];
     //$filename, $title='', $artist='', $album='', $year='', $comment='', $genre=255, $track='', $showerrors=FALSE
     // The  COMM fields generated errors. Commenting them out dit not render any trouble while altering the file, but
     // still - we need to check what is going on here..
     echo 'writing ID3v1 changes...';
     $result = WriteID3v1($file, $data['name'], $data['artist'], $data['album'], $data['year'], $data['comment'], $data['genre'], $data['track'], TRUE);
     if ($result) {
         echo "success<br>";
     } else {
         echo "FAILED";
     }
     echo 'writing ID3v2 changes...';
     $result = WriteID3v2($file, $data, 3, 0, TRUE, 0, TRUE);
     if ($result) {
         echo "success<br>";
     } else {
         echo "FAILED";
     }
 }
Example #3
0
     getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.tag.id3v2.php', __FILE__, true);
     while ($row = mysql_fetch_array($result)) {
         set_time_limit(30);
         $ThisFileInfo = $getID3->analyze($filename);
         getid3_lib::CopyTagsToComments($ThisFileInfo);
         if (!empty($ThisFileInfo['tags'])) {
             $Album = trim(str_replace(strstr($ThisFileInfo['comments']['album'][0], ' ['), '', $ThisFileInfo['comments']['album'][0]));
             $Track = (string) intval(str_replace(' [', '', str_replace(']', '', strstr($ThisFileInfo['comments']['album'][0], ' ['))));
             if ($Track == '0') {
                 $Track = '';
             }
             if ($Album && $Track) {
                 echo '<hr>' . FixTextFields($row['filename']) . '<br>';
                 echo '<i>' . $Album . '</i> (track #' . $Track . ')<br>';
                 echo '<b>ID3v2:</b> ' . (RemoveID3v2($row['filename'], false) ? 'removed' : 'REMOVAL FAILED!') . ', ';
                 echo '<b>ID3v1:</b> ' . (WriteID3v1($row['filename'], @$ThisFileInfo['comments']['title'][0], @$ThisFileInfo['comments']['artist'][0], $Album, @$ThisFileInfo['comments']['year'][0], @$ThisFileInfo['comments']['comment'][0], @$ThisFileInfo['comments']['genreid'][0], $Track, false) ? 'updated' : 'UPDATE FAILED') . '<br>';
             } else {
                 echo ' . ';
             }
         } else {
             echo '<hr>FAILED<br>' . FixTextFields($row['filename']) . '<hr>';
         }
         flush();
     }
 } else {
     echo '<b>' . number_format(mysql_num_rows($result)) . '</b> files with <b>[??]</b>-format track numbers in album field:<br>';
     if (mysql_num_rows($result) > 0) {
         echo '(<a href="' . $_SERVER['SCRIPT_NAME'] . '?trackinalbum=1&m3u=.m3u">.m3u version</a>)<br>';
         echo '<a href="' . $_SERVER['SCRIPT_NAME'] . '?trackinalbum=1&autofix=1">Try to auto-fix</a><br>';
         echo '<table border="1" cellspacing="0" cellpadding="4">';
         while ($row = mysql_fetch_array($result)) {
            }
        } else {
            echo '<B>!is_uploaded_file(' . $_FILES['userfile']['tmp_name'] . ')</B><BR>';
        }
    }
    $data['id3v2']['TXXX'][0]['encodingid'] = 0;
    $data['id3v2']['TXXX'][0]['description'] = 'ID3v2-tagged by';
    $data['id3v2']['TXXX'][0]['data'] = 'getID3() v' . GETID3VERSION . ' (www.silisoftware.com)';
    if ($_POST['WriteOrDelete'] == 'W') {
        // write tags
        if (isset($_POST['VersionToEdit1']) && $_POST['VersionToEdit1'] == '1') {
            if (!is_numeric($_POST['EditorGenre'])) {
                $EditorGenre = 255;
                // ID3v1 only supports predefined numeric genres (255 = unknown)
            }
            echo 'ID3v1 changes' . (WriteID3v1($EditorFilename, $_POST['EditorTitle'], $_POST['EditorArtist'], $_POST['EditorAlbum'], $_POST['EditorYear'], $_POST['EditorComment'], $_POST['EditorGenre'], $_POST['EditorTrack'], true) ? '' : ' NOT') . ' written successfully<HR>';
        }
        if (isset($_POST['VersionToEdit2']) && $_POST['VersionToEdit2'] == '2') {
            echo 'ID3v2 changes' . (WriteID3v2($EditorFilename, $data, 3, 0, true, 0, true) ? '' : ' NOT') . ' written successfully<HR>';
        }
    } else {
        // delete tags
        if (isset($_POST['VersionToEdit1']) && $_POST['VersionToEdit1'] == '1') {
            echo 'ID3v1 tag' . (RemoveID3v1($EditorFilename, true) ? '' : ' NOT') . ' successfully deleted<HR>';
        }
        if (isset($_POST['VersionToEdit2']) && $_POST['VersionToEdit2'] == '2') {
            echo 'ID3v2 tag' . (RemoveID3v2($EditorFilename, true) ? '' : ' NOT') . ' successfully deleted<HR>';
        }
    }
}
echo '<A HREF="' . $_SERVER['PHP_SELF'] . '">Start Over</A><BR>';
            echo '<B>cannot open $userfile</B><BR>';
        }
    } else {
        echo '<B>$userfile != is_uploaded_file()</B><BR>';
    }
    $data['id3']['id3v2']['TXXX'][0]['encodingid'] = 0;
    $data['id3']['id3v2']['TXXX'][0]['description'] = 'ID3v2-tagged by';
    $data['id3']['id3v2']['TXXX'][0]['data'] = 'getID3() v' . GETID3VERSION . ' (www.silisoftware.com)';
    if ($WriteOrDelete == 'W') {
        // write tags
        if ($VersionToEdit1 == '1') {
            if (!is_numeric($EditorGenre)) {
                $EditorGenre = 255;
                // ID3v1 only supports predefined numeric genres (255 = unknown)
            }
            echo 'ID3v1 changes' . (WriteID3v1($EditorFilename, $EditorTitle, $EditorArtist, $EditorAlbum, $EditorYear, $EditorComment, $EditorGenre, $EditorTrack, TRUE) ? '' : ' NOT') . ' written successfully<BR>';
        }
        if ($VersionToEdit2 == '2') {
            echo 'ID3v2 changes' . (WriteID3v2($EditorFilename, $data, 3, 0, TRUE, 0, TRUE) ? '' : ' NOT') . ' written successfully<BR>';
        }
    } else {
        // delete tags
        if ($VersionToEdit1 == '1') {
            echo 'ID3v1 tag' . (RemoveID3v1($EditorFilename, TRUE) ? '' : ' NOT') . ' successfully deleted<BR>';
        }
        if ($VersionToEdit2 == '2') {
            echo 'ID3v2 tag' . (RemoveID3v2($EditorFilename, TRUE) ? '' : ' NOT') . ' successfully deleted<BR>';
        }
    }
}
echo '<A HREF="' . $PHP_SELF . '">Start Over</A><BR>';
 function saveID3($file)
 {
     global $config;
     $fileInfo = $file->allInfo;
     $id3 = $fileInfo['id3v1'];
     //$id3['comment'] =  substr(substr($config['rootUrl'], 7), 0, 30);
     $id3['comment'] = "id: " . $this->id;
     //$id3['album'] =  "id: " . $this->id;
     //if(!$id3['title'])
     // $id3['title'] = substr($this->get('title'), 0, 30);
     //if(!$id3['artist'])
     //	$id3['artist'] = substr($this->getCreatorNames(), 0, 30);
     debug("writing ID3V1", $id3);
     //$succ = WriteID3v1($file->path, $id3['title'], $id3['artist'], $id3['album'], $id3['year'], $id3['comment'], $id3['genre'], NULL /*track*/);
     $succ = WriteID3v1($file->path, $id3['comment'], NULL);
     if (!$succ) {
         logError("Could not change ID3V1 tags in file " . $file->path);
     }
 }