Beispiel #1
0
function SynchronizeAllTags($filename, $synchronizefrom = 'all', $synchronizeto = 'A12', &$errors)
{
    global $getID3;
    set_time_limit(30);
    $ThisFileInfo = $getID3->analyze($filename);
    getid3_lib::CopyTagsToComments($ThisFileInfo);
    if ($synchronizefrom == 'all') {
        $SourceArray = !empty($ThisFileInfo['comments']) ? $ThisFileInfo['comments'] : array();
    } elseif (!empty($ThisFileInfo['tags'][$synchronizefrom])) {
        $SourceArray = !empty($ThisFileInfo['tags'][$synchronizefrom]) ? $ThisFileInfo['tags'][$synchronizefrom] : array();
    } else {
        die('ERROR: $ThisFileInfo[tags][' . $synchronizefrom . '] does not exist');
    }
    $SQLquery = 'DELETE FROM `' . mysql_real_escape_string(GETID3_DB_TABLE) . '`';
    $SQLquery .= ' WHERE (`filename` = "' . mysql_real_escape_string($filename) . '")';
    mysql_query_safe($SQLquery);
    $TagFormatsToWrite = array();
    if (strpos($synchronizeto, '2') !== false && $synchronizefrom != 'id3v2') {
        $TagFormatsToWrite[] = 'id3v2.3';
    }
    if (strpos($synchronizeto, 'A') !== false && $synchronizefrom != 'ape') {
        $TagFormatsToWrite[] = 'ape';
    }
    if (strpos($synchronizeto, 'L') !== false && $synchronizefrom != 'lyrics3') {
        $TagFormatsToWrite[] = 'lyrics3';
    }
    if (strpos($synchronizeto, '1') !== false && $synchronizefrom != 'id3v1') {
        $TagFormatsToWrite[] = 'id3v1';
    }
    getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'write.php', __FILE__, true);
    $tagwriter = new GetId3_Write_Tags();
    $tagwriter->filename = $filename;
    $tagwriter->tagformats = $TagFormatsToWrite;
    $tagwriter->overwrite_tags = true;
    $tagwriter->tag_encoding = $getID3->encoding;
    $tagwriter->tag_data = $SourceArray;
    if ($tagwriter->WriteTags()) {
        $errors = $tagwriter->errors;
        return true;
    }
    $errors = $tagwriter->errors;
    return false;
}
Beispiel #2
0
                            echo '<b>invalid image format (only GIF, JPEG, PNG)</b><br>';
                        }
                    } else {
                        $errormessage = ob_get_contents();
                        ob_end_clean();
                        echo '<b>cannot open ' . $_FILES['userfile']['tmp_name'] . '</b><br>';
                    }
                } else {
                    echo '<b>!is_uploaded_file(' . $_FILES['userfile']['tmp_name'] . ')</b><br>';
                }
            } else {
                echo '<b>WARNING:</b> Can only embed images for ID3v2<br>';
            }
        }
        $tagwriter->tag_data = $TagData;
        if ($tagwriter->WriteTags()) {
            echo 'Successfully wrote tags<BR>';
            if (!empty($tagwriter->warnings)) {
                echo 'There were some warnings:<BLOCKQUOTE STYLE="background-color:#FFCC33; padding: 10px;">' . implode('<BR><BR>', $tagwriter->warnings) . '</BLOCKQUOTE>';
            }
        } else {
            echo 'Failed to write tags!<BLOCKQUOTE STYLE="background-color:#FF9999; padding: 10px;">' . implode('<BR><BR>', $tagwriter->errors) . '</BLOCKQUOTE>';
        }
    } else {
        echo 'WARNING: no tag formats selected for writing - nothing written';
    }
    echo '<HR>';
}
echo '<div style="font-size: 1.2em; font-weight: bold;">Sample tag editor/writer</div>';
echo '<a href="' . htmlentities($browsescriptfilename . '?listdirectory=' . rawurlencode(realpath(dirname($Filename))), ENT_QUOTES) . '">Browse current directory</a><br>';
if (!empty($Filename)) {