// | This program is distributed in the hope that it will be useful, | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | // | GNU General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program. If not, see <http://www.gnu.org/licenses/>. | // +------------------------------------------------------------------------+ require_once 'include/initialize.inc.php'; $cfg['menu'] = 'playlist'; authenticate('access_playlist'); require_once 'include/play.inc.php'; require_once 'include/header.inc.php'; global $cfg, $db; $index = (int) get('index'); mpd('delete ' . $index); ?> <table cellspacing="0" cellpadding="0" class="border"> <tr class="header"> <td class="space left"></td> <td class="trackNumber"> # </td> <td>Title</td> <td>Artist</td> <td>Genre</td> <td><?php if ($featuring) { echo 'Featuring'; } ?> </td><!-- optional featuring -->
function playlistStatus() { global $cfg, $db; authenticate('access_playlist', false, false, true); require_once 'include/play.inc.php'; $track_id = get('track_id'); if ($cfg['player_type'] == NJB_HTTPQ) { // volume $volume = (int) httpq('getvolume'); // get mute volume if ($volume == 0) { $query = mysql_query('SELECT mute_volume FROM player WHERE player_id = ' . (int) $cfg['player_id']); $temp = mysql_fetch_assoc($query); $volume = -$temp['mute_volume']; } $data = array(); $data['hash'] = (string) httpq('gethash'); $data['miliseconds'] = (int) httpq('getoutputtime', 'frmt=0'); $data['listpos'] = (int) httpq('getlistpos'); $data['isplaying'] = (int) httpq('isplaying'); $data['repeat'] = (int) httpq('repeat_status'); $data['shuffle'] = (int) httpq('shuffle_status'); $data['volume'] = (int) $volume; $data['gain'] = -1; echo safe_json_encode($data); } if ($cfg['player_type'] == NJB_MPD) { $playlist = mpd('playlist'); $status = mpd('status'); $data = array(); $data['hash'] = md5(implode('<seperation>', $playlist)); $data['listpos'] = isset($status['song']) ? (int) $status['song'] : 0; $data['volume'] = (int) $status['volume']; $data['repeat'] = (int) $status['repeat']; $data['shuffle'] = (int) $status['random']; $data['isplaying'] = 0; if ($status['state'] == 'stop') { $data['isplaying'] = 0; } if ($status['state'] == 'play') { $data['isplaying'] = 1; } if ($status['state'] == 'pause') { $data['isplaying'] = 3; } $data['miliseconds'] = $status['state'] == 'stop' ? 0 : (int) round($status['elapsed'] * 1000); $data['gain'] = -1; if (version_compare($cfg['mpd_version'], '0.16.0', '>=')) { $gain = mpd('replay_gain_status'); $data['gain'] = (string) $gain['replay_gain_mode']; } // get mute volume if ($data['volume'] == 0) { $query = mysql_query('SELECT mute_volume FROM player WHERE player_id = ' . (int) $cfg['player_id']); $temp = mysql_fetch_assoc($query); $data['volume'] = -$temp['mute_volume']; } echo safe_json_encode($data); } }
function importFavorite($favorite_id, $mode) { global $cfg, $db; authenticate('access_admin', false, true, true); require_once 'include/play.inc.php'; $name = post('name'); $comment = post('comment'); $url = post('url'); if ($url != '') { $file = array(); $items = @file($url, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) or message(__FILE__, __LINE__, 'error', '[b]Failed to open url:[/b][br]' . $url); foreach ($items as $item) { // pls: // File1=http://example.com:80 // m3u: // http://example.com:80 if (preg_match('#^(?:File[0-9]{1,3}=|)((?:ftp|http|https|mms|mmst|pnm|rtp|rtsp|sdp)://.+)#', $item, $match)) { $file[] = $match[1]; } } } elseif ($cfg['player_type'] == NJB_HTTPQ) { $file = httpq('getplaylistfilelist', 'delim=*'); $file = str_replace('\\', '/', $file); $file = explode('*', $file); // Get relative directory based on $cfg['media_share'] foreach ($file as $i => $value) { if (strtolower(substr($file[$i], 0, strlen($cfg['media_share']))) == strtolower($cfg['media_share'])) { $file[$i] = substr($file[$i], strlen($cfg['media_share'])); } } } elseif ($cfg['player_type'] == NJB_MPD) { $file = mpd('playlist'); $file = implode('<seperation>', $file); $file = iconv(NJB_DEFAULT_CHARSET, 'UTF-8', $file); $file = explode('<seperation>', $file); } else { message(__FILE__, __LINE__, 'error', '[b]Player not supported[/b]'); } $stream = 0; for ($i = 0; $i < count($file); $i++) { if (preg_match('#^(ftp|http|https|mms|mmst|pnm|rtp|rtsp|sdp)://#', $file[$i])) { $stream = 1; } } if (count($file) > 0) { if ($mode == 'import') { mysql_query('DELETE FROM favoriteitem WHERE favorite_id = ' . (int) $favorite_id); $offset = 0; } if ($mode = 'add') { $query = mysql_query('SELECT position FROM favoriteitem WHERE favorite_id = ' . (int) $favorite_id . ' ORDER BY position DESC'); $track = mysql_fetch_assoc($query); $offset = $track['position']; } // Update favorite stream status mysql_query('UPDATE favorite SET stream = "' . (int) $stream . '" WHERE favorite_id = ' . (int) $favorite_id); // Don't allow stream_url and track_id in the same playlist! if ($stream) { mysql_query('DELETE FROM favoriteitem WHERE favorite_id = ' . (int) $favorite_id . ' AND track_id != ""'); } else { mysql_query('DELETE FROM favoriteitem WHERE favorite_id = ' . (int) $favorite_id . ' AND stream_url != ""'); } } for ($i = 0; $i < count($file); $i++) { $query = mysql_query('SELECT track_id FROM track WHERE relative_file = "' . mysql_real_escape_string($file[$i]) . '"'); $track = mysql_fetch_assoc($query); if ($stream == 0 && $track['track_id']) { $position = $i + $offset + 1; mysql_query('INSERT INTO favoriteitem (track_id, position, favorite_id) VALUES ("' . mysql_real_escape_string($track['track_id']) . '", ' . (int) $position . ', ' . (int) $favorite_id . ')'); } if ($stream == 1 && preg_match('#^(ftp|http|https|mms|mmst|pnm|rtp|rtsp|sdp)://#', $file[$i])) { $position = $i + $offset + 1; mysql_query('INSERT INTO favoriteitem (stream_url, position, favorite_id) VALUES ("' . mysql_real_escape_string($file[$i]) . '", ' . (int) $position . ', ' . (int) $favorite_id . ')'); } } editFavorite($favorite_id); }
$file = httpq('getplaylistfilelist', 'delim=*'); $file = str_replace('\\', '/', $file); $file = explode('*', $file); $listlength = empty($file[0]) ? 0 : count($file); $volume = true; $max_volume = 255; // Get relative directory based on $cfg['media_share'] foreach ($file as $i => $value) { if (strtolower(substr($file[$i], 0, strlen($cfg['media_share']))) == strtolower($cfg['media_share'])) { $file[$i] = substr($file[$i], strlen($cfg['media_share'])); } } } elseif ($cfg['player_type'] == NJB_MPD) { $status = mpd('status'); $listpos = isset($status['song']) ? $status['song'] : 0; $file = mpd('playlist'); $hash = md5(implode('<seperation>', $file)); $listlength = $status['playlistlength']; $volume = isset($status['volume']) == false || $status['volume'] == -1 ? false : true; $max_volume = 100; } elseif ($cfg['player_type'] == NJB_VLC) { message(__FILE__, __LINE__, 'warning', '[b]videoLAN playlist not supported yet[/b]'); } else { message(__FILE__, __LINE__, 'error', '[b]Player not supported[/b]'); } $featuring = false; for ($i = 0; $i < $listlength && !$featuring; $i++) { if ($cfg['media_dir_alternative_path'] !== '' && $file[$i][0] === '/') { $file[$i] = substr($file[$i], strlen($cfg['media_dir_alternative_path'])); } $query = mysql_query('SELECT featuring FROM track WHERE featuring != "" AND relative_file = "' . mysql_real_escape_string($file[$i]) . '"');
/* * * Developed by Clayton Dukes <*****@*****.**> * Copyright (c) 2009 gdd.net * All rights reserved. * * Changelog: * 2009-12-13 - created * */ session_start(); $basePath = dirname( __FILE__ ); require_once ($basePath . "/../common_funcs.php"); require_once ($basePath . "/../jqNewChart.php"); require_once ($basePath . "/../ajax/ChartFunctions.php"); ?> <div id="chart_mpd"></div> <?php if ((has_portlet_access($_SESSION['username'], 'Events Per Day') == TRUE) || ($_SESSION['AUTHTYPE'] == "none")) { mpd(); } else { ?> <script type="text/javascript"> $('#portlet_Events_Per_Day').remove() $(document).ready(function(){ error("Access Denied"); }); </script> <?php } ?>