function import_show($showid, $dir, $type) { // Initialize getID3 engine $getID3 = new getID3(); // Read files and directories if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { $full_name = $dir . "/" . $file; if (is_file($full_name) || $file[0] != '.') { $ThisFileInfo = $getID3->analyze($full_name); if ($ThisFileInfo['fileformat'] == "mp3") { getid3_lib::CopyTagsToComments($ThisFileInfo); $album = mysql_real_escape_string(@implode(@$ThisFileInfo['comments_html']['album'])); $play_time = mysql_real_escape_string(@$ThisFileInfo['playtime_seconds']); $title_name = mysql_real_escape_string(@implode(@$ThisFileInfo['comments_html']['title'])); $artist_name = mysql_real_escape_string(@implode(@$ThisFileInfo['comments_html']['artist'])); $full_name = mysql_real_escape_string($full_name); if ($id = song_non_existant($full_name, $showid)) { $artist_id = check_or_insert_artist($artist_name); insert_into_tunes($title_name, $artist_id, $full_name, $album, $play_time, $showid, -1, $type); } else { $artist_id = check_or_insert_artist($artist_name); update_tunes($title_name, $id, $artist_id, $full_name, $album, $play_time); } } } } closedir($dh); } } }
<?php include "header.php"; include "helpers.php"; require_once "/var/www/freetag/freetag.class.php"; require_once "mp3id3write.php"; if (isset($_GET['showid'])) { $showid = $_GET["showid"]; } else { if (isset($_POST['showid'])) { $showid = $_POST['showid']; $artistid = check_or_insert_artist($_POST['artistname']); if ($showid != -1) { update_tunes($_POST['songname'], $_POST['tuneid'], $artistid, $_POST['filename'], $_POST['album'], $_POST['time'], $_POST['order']); } else { update_tunes($_POST['songname'], $_POST['tuneid'], $artistid, $_POST['filename'], $_POST['album'], $_POST['time'], -1); } tag_mp3($_POST['filename'], $_POST['songname'], $_POST['album'], $_POST['artistname'], $_POST['time']); if ($showid == -1) { $freetag_options = array('db_user' => 'root', 'db_pass' => '', 'db_host' => 'localhost', 'db_name' => 'tunequeue'); $freetag = new freetag($freetag_options); $freetag->delete_all_object_tags_for_user(1, $_POST['tuneid']); if (isset($_POST['tags']) && trim($_POST['tags']) != "") { $freetag->tag_object(1, $tuneid, $_POST['tags']); } header("Location:randomizer.php"); } else { header("Location:create-show.php?showid=" . $showid); } } }