function playlistTrack() { global $cfg, $db; authenticate('access_playlist', false, false, true); $track_id = get('track_id'); $query = mysql_query('SELECT track.artist, album.artist AS album_artist, title, featuring, miliseconds, relative_file, album, album.image_id, album.album_id, track.genre, track.audio_bitrate, track.audio_dataformat, track.audio_bits_per_sample, track.audio_sample_rate, album.genre_id, track.audio_profile, track.track_artist, album.year as year, track.number, track.comment, track.track_id, track.year as trackYear, track.dr, album.album_dr FROM track, album WHERE track.album_id = album.album_id AND track_id = "' . mysql_real_escape_string($track_id) . '"'); $track = mysql_fetch_assoc($query); $query = mysql_query('SELECT image_front FROM bitmap WHERE image_id="' . mysql_real_escape_string($track['image_id']) . '"'); $bitmap = mysql_fetch_assoc($query); $title = $track['title']; /* $query_ = mysql_query('SELECT title FROM track WHERE DIFFERENCE(SOUNDEX(title), SOUNDEX("' . (mysql_real_escape_like($title)) . '")) > 0'); $query_ = mysql_query('SELECT SOUNDEX(title) FROM track'); */ /* $title = strtolower($title); $separator = $cfg['separator']; $count = count($separator); $i=0; for ($i=0; $i<$count; $i++) { $pos = strpos($title,strtolower($separator[$i])); if ($pos !== false) { $title = trim(substr($title, 0 , $pos)); //break; } } */ $other_track_version = false; if ($cfg['enable_core_track_search'] === TRUE) { $title = findCoreTrackTitle($title); $title = mysql_real_escape_like($title); $separator = $cfg['separator']; $count = count($separator); $query_string = ''; $i = 0; for ($i = 0; $i < $count; $i++) { $query_string = $query_string . ' OR LOWER(title) LIKE "' . $title . $separator[$i] . '%"'; } $filter_query = 'WHERE (LOWER(title) = "' . $title . '" ' . $query_string . ')'; $query = mysql_query('SELECT title FROM track ' . $filter_query); if (strlen($title) > 0) { $num_rows = mysql_num_rows($query); if ($num_rows > 1) { $other_track_version = true; } } } $exploded = multiexplode($cfg['artist_separator'], $track['track_artist']); $inFavorite = false; if (isset($cfg['favorite_id'])) { $query = mysql_query("SELECT track_id FROM favoriteitem WHERE track_id = '" . $track_id . "' AND favorite_id = '" . $cfg['favorite_id'] . "' LIMIT 1"); if (mysql_num_rows($query) > 0) { $inFavorite = true; } } $data = array(); $data['album_artist'] = (string) ($track['album_artist'] == "Various Artists") ? rawurlencode($track['track_artist']) : rawurlencode($track['album_artist']); $data['track_artist'] = $exploded; $data['track_artist_url'] = $exploded; $data['track_artist_url_all'] = (string) rawurlencode($track['track_artist']); $data['title'] = (string) (trim($track['title']) !== '') ? $track['title'] : basename($track['relative_file']); $data['album'] = (string) (trim($track['album']) !== '') ? $track['album'] : basename(dirname($track['relative_file'])); //$data['album'] = (string) $title; $data['by'] = (string) $by; $data['image_id'] = (string) $track['image_id']; $data['album_id'] = (string) $track['album_id']; $data['year'] = is_null($track['year']) ? (string) $track['trackYear'] : (string) $track['year']; $data['genre'] = (string) $track['genre']; $data['audio_dataformat'] = (string) strtoupper($track['audio_dataformat']); $data['audio_bits_per_sample'] = (string) $track['audio_bits_per_sample']; $data['audio_sample_rate'] = (string) $track['audio_sample_rate']; $data['genre_id'] = (string) $track['genre_id']; if ($track['audio_profile'] == 'Lossless compression') { $data['audio_profile'] = (string) floor($track['audio_bitrate'] / 1000) . ' kbps'; } else { $data['audio_profile'] = (string) $track['audio_profile']; } $data['number'] = (string) $track['number'] . '. '; $data['miliseconds'] = (string) $track['miliseconds']; $data['other_track_version'] = (bool) $other_track_version; $data['comment'] = (string) $track['comment']; $data['track_id'] = (string) $track['track_id']; $data['relative_file'] = (string) $track['relative_file']; $data['inFavorite'] = (bool) $inFavorite; $data['dr'] = (string) $track['dr']; $data['album_dr'] = (string) $track['album_dr']; $data['title_core'] = $title; echo safe_json_encode($data); }
function view3all() { global $cfg, $db; authenticate('access_media'); $artist = get('artist'); $title = get('title'); $filter = get('filter') or $filter = 'start'; $order = get('order') or $order = 'title'; $sort = get('sort') == 'desc' ? 'desc' : 'asc'; $sort_artist = 'asc'; $sort_title = 'asc'; $sort_featuring = 'asc'; $sort_album = 'asc'; $order_bitmap_artist = '<span class="typcn"></span>'; $order_bitmap_title = '<span class="typcn"></span>'; $order_bitmap_featuring = '<span class="typcn"></span>'; $order_bitmap_album = '<span class="typcn"></span>'; if (strlen($title) >= 1) { // formattedNavigator $nav = array(); $nav['name'][] = 'Library'; $nav['url'][] = 'index.php'; $nav['name'][] = $title; require_once 'include/header.inc.php'; if ($filter == 'start') { /* $title = strtolower($title); $separator = $cfg['separator']; $count = count($separator); $i=0; for ($i=0; $i<$count; $i++) { $pos = strpos($title,strtolower($separator[$i])); if ($pos !== false) { $title = trim(substr($title, 0 , $pos)); //break; } } */ $separator = $cfg['separator']; $count = count($separator); $title = findCoreTrackTitle($title); $title = mysql_real_escape_like($title); $query_string = ''; $i = 0; for ($i = 0; $i < $count; $i++) { $query_string = $query_string . ' OR LOWER(track.title) LIKE "' . $title . $separator[$i] . '%"'; } $filter_query = 'WHERE (LOWER(track.title) = "' . $title . '" ' . $query_string . ') AND track.album_id = album.album_id'; //echo $filter_query; } elseif ($filter == 'smart') { $filter_query = 'WHERE (track.title LIKE "%' . mysql_real_escape_like($title) . '%" OR track.title SOUNDS LIKE "' . mysql_real_escape_string($title) . '") AND track.album_id = album.album_id'; } elseif ($filter == 'exact') { $filter_query = 'WHERE track.title = "' . mysql_real_escape_string($title) . '" AND track.album_id = album.album_id'; } else { message(__FILE__, __LINE__, 'error', '[b]Unsupported input value for[/b][br]filter'); } $url = 'index.php?action=view3all&title=' . rawurlencode($title) . '&filter=' . $filter; } elseif (strlen($artist) >= 1) { // formattedNavigator $nav = array(); $nav['name'][] = 'Library'; $nav['url'][] = 'index.php'; $nav['name'][] = $artist; $nav['url'][] = 'index.php?action=view2&artist=' . rawurlencode($artist) . '&order=year'; $nav['name'][] = 'All tracks'; require_once 'include/header.inc.php'; $filter_query = 'WHERE track.artist="' . mysql_real_escape_string($artist) . '" AND track.album_id = album.album_id'; //$filter_query = 'WHERE track.artist="' . mysql_real_escape_string($artist) . '"'; $url = 'index.php?action=view3all&artist=' . rawurlencode($artist); } else { message(__FILE__, __LINE__, 'warning', '[b]Search string too short - min. 2 characters[/b][br][url=index.php][img]small_back.png[/img]Back to previous page[/url]'); } if ($order == 'artist' && $sort == 'asc') { $order_query = 'ORDER BY artist, title'; $order_bitmap_artist = '<span class="fa fa-sort-alpha-asc"></span>'; $sort_artist = 'desc'; } elseif ($order == 'artist' && $sort == 'desc') { $order_query = 'ORDER BY artist DESC, title DESC'; $order_bitmap_artist = '<span class="fa fa-sort-alpha-desc"></span>'; $sort_artist = 'asc'; } elseif ($order == 'title' && $sort == 'asc') { $order_query = 'ORDER BY title, album'; $order_bitmap_title = '<span class="fa fa-sort-alpha-asc"></span>'; $sort_title = 'desc'; } elseif ($order == 'title' && $sort == 'desc') { $order_query = 'ORDER BY title DESC, album DESC'; $order_bitmap_title = '<span class="fa fa-sort-alpha-desc"></span>'; $sort_title = 'asc'; } elseif ($order == 'featuring' && $sort == 'asc') { $order_query = 'ORDER BY featuring, title, artist'; $order_bitmap_featuring = '<span class="fa fa-sort-alpha-asc"></span>'; $sort_featuring = 'desc'; } elseif ($order == 'featuring' && $sort == 'desc') { $order_query = 'ORDER BY featuring DESC, title DESC, artist DESC'; $order_bitmap_featuring = '<span class="fa fa-sort-alpha-desc"></span>'; $sort_featuring = 'asc'; } elseif ($order == 'album' && $sort == 'asc') { $order_query = 'ORDER BY album, relative_file'; $order_bitmap_album = '<span class="fa fa-sort-alpha-asc"></span>'; $sort_album = 'desc'; } elseif ($order == 'album' && $sort == 'desc') { $order_query = 'ORDER BY album DESC, relative_file DESC'; $order_bitmap_album = '<span class="fa fa-sort-alpha-desc"></span>'; $sort_album = 'asc'; } else { message(__FILE__, __LINE__, 'error', '[b]Unsupported input value for[/b][br]order'); } /*$query = mysql_query('SELECT featuring FROM track, album ' . $filter_query . ' AND featuring <> ""'); if (mysql_fetch_row($query)) $featuring = true; else $featuring = false; */ ?> <table cellspacing="0" cellpadding="0" class="border"> <tr class="header"> <td class="icon"> </td><!-- track menu --> <td class="icon"> </td><!-- add track --> <td class="track-list-artist"><a <?php echo $order_bitmap_artist == '<span class="typcn"></span>' ? '' : 'class="sort_selected"'; ?> href="<?php echo $url; ?> &order=artist&sort=<?php echo $sort_artist; ?> ">Artist <?php echo $order_bitmap_artist; ?> </a></td> <td><a <?php echo $order_bitmap_title == '<span class="typcn"></span>' ? '' : 'class="sort_selected"'; ?> href="<?php echo $url; ?> &order=title&sort=<?php echo $sort_title; ?> ">Title <?php echo $order_bitmap_title; ?> </a></td> <td><a <?php echo $order_bitmap_album == '<span class="typcn"></span>' ? '' : 'class="sort_selected"'; ?> href="<?php echo $url; ?> &order=album&sort=<?php echo $sort_album; ?> ">Album <?php echo $order_bitmap_album; ?> </a></td> <td align="right" class="time">Time</td> <td class="space right"></td> </tr> <?php $i = 0; $query = mysql_query('SELECT track.artist, track.title, track.number, track.featuring, track.album_id, track.track_id, track.miliseconds, track.relative_file, album.image_id, album.album FROM track, album ' . $filter_query . ' ' . $order_query); //$query = mysql_query('SELECT track.artist, track.title, track.featuring, track.album_id, track.track_id, track.miliseconds FROM track ' . $filter_query . ' ' . $order_query); while ($track = mysql_fetch_assoc($query)) { ?> <tr class="<?php echo $i++ & 1 ? 'even' : 'odd'; ?> mouseover"> <td class="icon"> <span id="menu-track<?php echo $i; ?> "> <div onclick='toggleMenuSub(<?php echo $i; ?> );'> <i id="menu-icon<?php echo $i; ?> " class="fa fa-bars icon-small"></i> </div> </span> </td> <td class="icon"> <span> <?php if ($cfg['access_add']) { echo '<a href="javascript:ajaxRequest(\'play.php?action=addSelect&track_id=' . $track['track_id'] . '\');" onMouseOver="return overlib(\'Add track ' . $track['number'] . '\');" onMouseOut="return nd();"><i class="fa fa-plus-circle fa-fw icon-small"></i></a>'; } ?> </span> </td> <td class="track-list-artist"><?php if (mysql_num_rows(mysql_query('SELECT track_id FROM track WHERE artist="' . mysql_real_escape_string($track['artist']) . '"')) > 1) { echo '<a href="index.php?action=view2&artist=' . rawurlencode($track['artist']) . '&order=year">' . html($track['artist']) . '</a>'; } else { echo html($track['artist']); } ?> </td> <td><?php if ($cfg['access_play']) { echo '<a href="javascript:ajaxRequest(\'play.php?action=insertSelect&playAfterInsert=yes&track_id=' . $track['track_id'] . '\');" onMouseOver="return overlib(\'Play track\');" onMouseOut="return nd();">' . html($track['title']) . '</a>'; } elseif ($cfg['access_add']) { echo '<a href="javascript:ajaxRequest(\'play.php?action=addSelect&track_id=' . $track['track_id'] . '\');" onMouseOver="return overlib(\'Add track\');" onMouseOut="return nd();">' . html($track['title']) . '</a>'; } elseif ($cfg['access_stream']) { echo '<a href="stream.php?action=playlist&track_id=' . $track['track_id'] . '&stream_id=' . $cfg['stream_id'] . '" onMouseOver="return overlib(\'Stream track\');" onMouseOut="return nd();">' . html($track['title']) . '</a>'; } else { echo html($track['title']); } ?> <span class="track-list-artist-narrow">by <?php echo html($track['artist']); ?> </span> </td> <td><a href="index.php?action=view3&album_id=<?php echo $track['album_id']; ?> " <?php echo onmouseoverImage($track['image_id']); ?> ><?php echo html($track['album']); ?> </a></td> <td align="right"><?php echo formattedTime($track['miliseconds']); ?> </td> <td></td> </tr> <tr class="line"> <td></td> <td colspan="16"></td> </tr> <tr> <td colspan="20"> <div class="menuSub" id="menu-sub-track<?php echo $i; ?> " onclick='offMenuSub(<?php echo $i; ?> );'> <div><?php if ($cfg['access_play']) { echo '<a href="javascript:ajaxRequest(\'play.php?action=insertSelect&playAfterInsert=yes&track_id=' . $track['track_id'] . '\');" onMouseOver="return overlib(\'Play track ' . $track['number'] . '\');" onMouseOut="return nd();"><i class="fa fa-play-circle-o fa-fw icon-small"></i>Insert after currently playing track and play</a>'; } ?> </div> <div> <?php if ($cfg['access_add']) { echo '<a href="javascript:ajaxRequest(\'play.php?action=insertSelect&track_id=' . $track['track_id'] . '\');" onMouseOver="return overlib(\'Insert track ' . $track['number'] . '\');" onMouseOut="return nd();"><i class="fa fa-indent fa-fw icon-small"></i>Insert after currently playing track</a>'; } ?> </div> <div> <?php if ($cfg['access_add']) { echo '<a href="javascript:ajaxRequest(\'play.php?action=addSelect&track_id=' . $track['track_id'] . '\');" onMouseOver="return overlib(\'Add track ' . $track['number'] . '\');" onMouseOut="return nd();"><i class="fa fa-plus-circle fa-fw icon-small"></i>Add track to playlist</a>'; } ?> </div> <div><?php if ($cfg['access_play']) { echo '<a href="javascript:ajaxRequest(\'play.php?action=playSelect&track_id=' . $track['track_id'] . '\');" onMouseOver="return overlib(\'Play track ' . $track['number'] . '\');" onMouseOut="return nd();"><i class="fa fa-play-circle-o fa-fw icon-small"></i>Remove all from playlist and play track</a>'; } ?> </div> <div><?php if ($cfg['access_stream']) { echo '<a href="stream.php?action=playlist&track_id=' . $track['track_id'] . '&stream_id=' . $cfg['stream_id'] . '" onMouseOver="return overlib(\'Stream track ' . $track['number'] . '\');" onMouseOut="return nd();"><i class="fa fa-rss fa-fw icon-small"></i>Stream track</a>'; } ?> </div> <div><?php if ($cfg['access_download']) { echo '<a href="download.php?action=downloadTrack&track_id=' . $track['track_id'] . '&download_id=' . $cfg['download_id'] . '" ' . onmouseoverDownloadTrack($track['track_id']) . '><i class="fa fa-download fa-fw icon-small"></i>Download track</a>'; } ?> </div> <div><?php if ($cfg['access_play']) { echo '<a href="getid3/demos/demo.browse.php?filename=' . $cfg['media_dir'] . urlencode($track['relative_file']) . '" onClick="showSpinner();"><i class="fa fa-info-circle fa-fw icon-small"></i>File details</a>'; } ?> </div> </div> </td> </tr> <?php } echo '</table>' . "\n"; require_once 'include/footer.inc.php'; }