function scan_songs() { require_once 'getid3.php'; $dir_handle = opendir(get_songs_path()); // Initialize getID3 engine $getID3 = new getID3(); $songlist_struct = get_songlist_struct(); $songlist_struct_original = $songlist_struct; $songlist_new_items = array(); // List all the files while (false !== ($file = readdir($dir_handle))) { if (strcmp($file, ".") && strcmp($file, "..") && !strcasecmp(end(explode(".", $file)), "mp3")) { // error_log("Analyzing: " . constant("SONGS_PATH") . $file . " file_exists=" . file_exists(constant("SONGS_PATH") . $file)); // error_log("id3_structure: " . print_r($id3_info,1) . "\nID3v2:" . $id3_info['id3v2']['comments']['artist'][0] . " - " . $id3_info['id3v2']['comments']['title'][0]); // error_log("ID3v1:" . $id3_info['id3v1']['artist'] . " - " . $id3_info['id3v1']['title']); if (!isset($songlist_struct[get_tape_path()][base64_encode(rawurlencode($file))])) { $id3_info = $getID3->analyze(get_songs_path() . $file); $song_item = array(); // Check id3 v2 tags, if (!empty($id3_info['id3v2']['comments']['artist'][0])) { $song_item['artist'] = clean_titles($id3_info['id3v2']['comments']['artist'][0]); } elseif (!empty($id3_info['id3v1']['artist'])) { $song_item['artist'] = clean_titles($id3_info['id3v1']['artist']); } /*else { $song_item['artist'] = "Unknown artist"; } */ if (!empty($id3_info['id3v2']['comments']['title'][0])) { $song_item['title'] = clean_titles($id3_info['id3v2']['comments']['title'][0]); } elseif (!empty($id3_info['id3v1']['title'])) { $song_item['title'] = clean_titles($id3_info['id3v1']['title']); } /*else { $song_item['title'] = "Unknown title"; } */ // if we are missing tags, set the title to the filename, sans ".mp3" if (!isset($song_item['artist']) && !isset($song_item['title'])) { $song_item['artist'] = ""; $song_item['title'] = preg_replace('/\\.mp3$/i', '', $id3_info['filename']); } elseif (!isset($song_item['artist'])) { // fill in some of the blanks otherwise $song_item['artist'] = "Unknown artist"; } elseif (!isset($song_item['title'])) { $song_item['title'] = "Unknown track"; } $song_item['filename'] = $id3_info['filename']; $song_item['playtime_seconds'] = $id3_info['playtime_seconds']; $song_item['playtime_string'] = $id3_info['playtime_string']; $song_item['mtime'] = filemtime(get_songs_path() . $file); $song_item['size'] = filesize(get_songs_path() . $file); $songlist_new_items[base64_encode(rawurlencode($id3_info['filename']))] = $song_item; } } } // if changed, save it if (!empty($songlist_new_items)) { if (!isset($songlist_struct[get_tape_path()])) { $songlist_struct[get_tape_path()] = array(); } $songlist_struct[get_tape_path()] = array_merge($songlist_new_items, $songlist_struct[get_tape_path()]); announce_songs($songlist_struct); write_songlist_struct($songlist_struct); } return $songlist_struct; }
} else { $upload_success = 0; } } $songlist_struct = scan_songs(); $songlist_struct_original = $songlist_struct; $prefs_struct = get_opentape_prefs(); // 604800 = week in seconds if ((!isset($prefs_struct['check_updates']) || $prefs_struct['check_updates'] == 1) && (!isset($prefs_struct['last_update_check']) || time() - $prefs_struct['last_update_check'] > 604800)) { $prefs_struct = check_for_update(); if ($prefs_struct === false) { header("Location: " . $REL_PATH . "code/warning.php"); } } if (isset($prefs_struct['announce']) && $prefs_struct['announce'] == 1 && !isset($prefs_struct['last_announce_songs'])) { announce_songs($songlist_struct); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Opentape / Edit Mixtape</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="<?php echo $REL_PATH; ?> res/style.css" /> </head> <body> <div class="container"> <div class="banner">