芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/fmd/vendor/james-heinrich/getid3/demos/demo.write.php
// // available at http://getid3.sourceforge.net // // or http://www.getid3.org // // also https://github.com/JamesHeinrich/getID3 // ///////////////////////////////////////////////////////////////// // // // /demo/demo.write.php - part of getID3() // // sample script for demonstrating writing ID3v1 and ID3v2 // // tags for MP3, or Ogg comment tags for Ogg Vorbis // // See readme.txt for more details // // /// ///////////////////////////////////////////////////////////////// die('Due to a security issue, this demo has been disabled. It can be enabled by removing line '.__LINE__.' in '.$_SERVER['PHP_SELF']); $TaggingFormat = 'UTF-8'; header('Content-Type: text/html; charset='.$TaggingFormat); echo ''; echo '
getID3() - Sample tag writer
'; require_once('../getid3/getid3.php'); // Initialize getID3 engine $getID3 = new getID3; $getID3->setOption(array('encoding'=>$TaggingFormat)); getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'write.php', __FILE__, true); $browsescriptfilename = 'demo.browse.php'; $Filename = (isset($_REQUEST['Filename']) ? $_REQUEST['Filename'] : ''); if (isset($_POST['WriteTags'])) { $TagFormatsToWrite = (isset($_POST['TagFormatsToWrite']) ? $_POST['TagFormatsToWrite'] : array()); if (!empty($TagFormatsToWrite)) { echo 'starting to write tag(s)
'; $tagwriter = new getid3_writetags; $tagwriter->filename = $Filename; $tagwriter->tagformats = $TagFormatsToWrite; $tagwriter->overwrite_tags = false; $tagwriter->tag_encoding = $TaggingFormat; if (!empty($_POST['remove_other_tags'])) { $tagwriter->remove_other_tags = true; } $commonkeysarray = array('Title', 'Artist', 'Album', 'Year', 'Comment'); foreach ($commonkeysarray as $key) { if (!empty($_POST[$key])) { $TagData[strtolower($key)][] = $_POST[$key]; } } if (!empty($_POST['Genre'])) { $TagData['genre'][] = $_POST['Genre']; } if (!empty($_POST['GenreOther'])) { $TagData['genre'][] = $_POST['GenreOther']; } if (!empty($_POST['Track'])) { $TagData['track'][] = $_POST['Track'].(!empty($_POST['TracksTotal']) ? '/'.$_POST['TracksTotal'] : ''); } if (!empty($_FILES['userfile']['tmp_name'])) { if (in_array('id3v2.4', $tagwriter->tagformats) || in_array('id3v2.3', $tagwriter->tagformats) || in_array('id3v2.2', $tagwriter->tagformats)) { if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { if ($APICdata = file_get_contents($_FILES['userfile']['tmp_name'])) { if ($exif_imagetype = exif_imagetype($_FILES['userfile']['tmp_name'])) { $TagData['attached_picture'][0]['data'] = $APICdata; $TagData['attached_picture'][0]['picturetypeid'] = $_POST['APICpictureType']; $TagData['attached_picture'][0]['description'] = $_FILES['userfile']['name']; $TagData['attached_picture'][0]['mime'] = image_type_to_mime_type($exif_imagetype), } else { echo '
invalid image format (only GIF, JPEG, PNG)
'; } } else { echo '
cannot open '.htmlentities($_FILES['userfile']['tmp_name']).'
'; } } else { echo '
!is_uploaded_file('.htmlentities($_FILES['userfile']['tmp_name']).')
'; } } else { echo '
WARNING:
Can only embed images for ID3v2
'; } } $tagwriter->tag_data = $TagData; if ($tagwriter->WriteTags()) { echo 'Successfully wrote tags
'; if (!empty($tagwriter->warnings)) { echo 'There were some warnings:
'.implode('
', $tagwriter->warnings).'
'; } } else { echo 'Failed to write tags!
'.implode('
', $tagwriter->errors).'
'; } } else { echo 'WARNING: no tag formats selected for writing - nothing written'; } echo '
'; } echo '
Sample tag editor/writer
'; echo '
Browse current directory
'; if (!empty($Filename)) { echo '
Start Over
'; echo '
'; echo '
'; echo '
Filename:
'.$Filename.'
'; if (file_exists($Filename)) { // Initialize getID3 engine $getID3 = new getID3; $OldThisFileInfo = $getID3->analyze($Filename); getid3_lib::CopyTagsToComments($OldThisFileInfo); switch ($OldThisFileInfo['fileformat']) { case 'mp3': case 'mp2': case 'mp1': $ValidTagTypes = array('id3v1', 'id3v2.3', 'ape'); break; case 'mpc': $ValidTagTypes = array('ape'); break; case 'ogg': if (!empty($OldThisFileInfo['audio']['dataformat']) && ($OldThisFileInfo['audio']['dataformat'] == 'flac')) { //$ValidTagTypes = array('metaflac'); // metaflac doesn't (yet) work with OggFLAC files $ValidTagTypes = array(); } else { $ValidTagTypes = array('vorbiscomment'); } break; case 'flac': $ValidTagTypes = array('metaflac'); break; case 'real': $ValidTagTypes = array('real'); break; default: $ValidTagTypes = array(); break; } echo '
Title
'; echo '
Artist
'; echo '
Album
'; echo '
Year
'; $TracksTotal = ''; $TrackNumber = ''; if (!empty($OldThisFileInfo['comments']['track_number']) && is_array($OldThisFileInfo['comments']['track_number'])) { $RawTrackNumberArray = $OldThisFileInfo['comments']['track_number']; } elseif (!empty($OldThisFileInfo['comments']['track']) && is_array($OldThisFileInfo['comments']['track'])) { $RawTrackNumberArray = $OldThisFileInfo['comments']['track']; } else { $RawTrackNumberArray = array(); } foreach ($RawTrackNumberArray as $key => $value) { if (strlen($value) > strlen($TrackNumber)) { // ID3v1 may store track as "3" but ID3v2/APE would store as "03/16" $TrackNumber = $value; } } if (strstr($TrackNumber, '/')) { list($TrackNumber, $TracksTotal) = explode('/', $TrackNumber); } echo '
Track
of
'; $ArrayOfGenresTemp = getid3_id3v1::ArrayOfGenres(); // get the array of genres foreach ($ArrayOfGenresTemp as $key => $value) { // change keys to match displayed value $ArrayOfGenres[$value] = $value; } unset($ArrayOfGenresTemp); // remove temporary array unset($ArrayOfGenres['Cover']); // take off these special cases unset($ArrayOfGenres['Remix']); unset($ArrayOfGenres['Unknown']); $ArrayOfGenres[''] = '- Unknown -'; // Add special cases back in with renamed key/value $ArrayOfGenres['Cover'] = '-Cover-'; $ArrayOfGenres['Remix'] = '-Remix-'; asort($ArrayOfGenres); // sort into alphabetical order echo '
Genre
'; $AllGenresArray = (!empty($OldThisFileInfo['comments']['genre']) ? $OldThisFileInfo['comments']['genre'] : array()); foreach ($ArrayOfGenres as $key => $value) { echo '
'.htmlentities($value).'
'; } echo '
'; echo '
Write Tags
'; foreach ($ValidTagTypes as $ValidTagType) { echo '
'.$ValidTagType.'
'; } if (count($ValidTagTypes) > 1) { echo '
Remove non-selected tag formats when writing new tag
'; } echo '
'; echo '
Comment
'.((isset($OldThisFileInfo['comments']['comment']) && is_array($OldThisFileInfo['comments']['comment'])) ? implode("\n", $OldThisFileInfo['comments']['comment']) : '').'</textarea>
'; echo '
Picture
(ID3v2 only)
'; echo '
'; $APICtypes = getid3_id3v2::APICPictureTypeLookup('', true); foreach ($APICtypes as $key => $value) { echo '
'.htmlentities($value).'
'; } echo '
'; echo '
'; echo '
'; } else { echo '
Error
'.htmlentities($Filename).' does not exist
'; } echo '
'; echo '
'; } echo '';