/** * Checks whether or not a track * can be played right now. * This is based on media_lock_mode * and the user's permissions. * * @author Ben Dodson * @version 7/7/05 * @since 7/7/05 **/ function canPlay($el, $user) { global $media_lock_mode; // What to return: $permissions = false; $locked = false; $valid = true; // First, is the user allowed to play it in general? if (checkPermission($user, "stream", $el->getPath("String")) === false) { return $permissions; } // Fast case: if (isNothing($media_lock_mode) || $media_lock_mode == "off") { return $valid; } $be = new jzBackend(); if ($media_lock_mode == "track") { $arr = $be->getPlaying(); foreach ($arr as $key => $more) { if ($more['fpath'] == $el->getFileName("host")) { return $locked; } } return $valid; } if ($media_lock_mode == "album") { $alb = $el->getAncestor("album"); if ($alb === false) { return $valid; } $arr = $be->getPlaying(); foreach ($arr as $key => $more) { $t = new jzMediaTrack($more['path']); $ta = $t->getAncestor("album"); if ($ta !== false) { if ($ta->getPath("String") == $alb->getPath("String")) { return $locked; } } } return $valid; } if ($media_lock_mode == "artist") { $artist = $el->getAncestor("artist"); if ($artist === false) { return $valid; } $arr = $be->getPlaying(); foreach ($arr as $key => $more) { $t = new jzMediaTrack($more['path']); $ta = $t->getAncestor("artist"); if ($ta !== false) { if ($ta->getPath("String") == $artist->getPath("String")) { return $locked; } } } return $valid; } if ($media_lock_mode == "genre") { $gen = $el->getAncestor("genre"); if ($gen === false) { return $valid; } $arr = $be->getPlaying(); foreach ($arr as $key => $more) { $t = new jzMediaTrack($more['path']); $ta = $t->getAncestor("genre"); if ($ta !== false) { if ($ta->getPath("String") == $gen->getPath("String")) { return $locked; } } } return $valid; } return $valid; }
/** * * Echos out the XML header information * * @author Ross Carlson * @since 3/31/05 * **/ function getCurrentTrack() { global $jzUSER, $this_site, $root_dir; // What kind of output? if (isset($_REQUEST['type'])) { $type = $_REQUEST['type']; } else { $type = "xml"; } // Now let's set the width if (isset($_REQUEST['imagesize'])) { $imagesize = $_REQUEST['imagesize'] . "x" . $_REQUEST['imagesize']; } else { $imagesize = "150x150"; } // Now let's see when to stop if (isset($_REQUEST['count'])) { $total = $_REQUEST['count']; } else { $total = 1; } // Let's start the page if ($type == "xml") { echoXMLHeader(); } // Now let's get the data $be = new jzBackend(); $ar = $be->getPlaying(); $display = new jzDisplay(); $fullList = ""; $found = false; foreach ($ar as $user => $tracks) { $name = $jzUSER->getSetting("full_name"); if ($name == "") { $name = $jzUSER->lookupName($user); // that's the user name } $i = 0; foreach ($tracks as $time => $song) { // Now let's make sure this is the right user if ($name == $jzUSER->getName()) { // Now let's make sure we don't list this twice if (stristr($fullList, $song['path'] . "-" . $name . "\n")) { continue; } $fullList .= $song['path'] . "-" . $name . "\n"; // Now let's create the objects we need $node = new jzMediaNode($song['path']); $track = new jzMediaTrack($song['path']); $album = $node->getParent(); $artist = $album->getParent(); $meta = $track->getMeta(); // Now, now let's echo out the data switch ($type) { case "xml": echo " <item>\n"; echo " <title>" . $this_site . xmlUrlClean($meta['title']) . "</title>\n"; echo " <album>\n"; echo " <name>" . $this_site . xmlUrlClean($album->getName()) . "</name>\n"; echo " <image>" . $this_site . xmlUrlClean($display->returnImage($album->getMainArt(false, true, "audio", true), $album->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true)) . "</image>\n"; echo " </album>\n"; echo " <artist>\n"; echo " <name>" . $this_site . xmlUrlClean($artist->getName()) . "</name>\n"; echo " <image>" . $this_site . xmlUrlClean($display->returnImage($artist->getMainArt(false, true, "audio", true), $artist->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true)) . "</image>\n"; echo " </artist>\n"; echo " </item>\n"; break; case "html": if (isset($_REQUEST['align'])) { if ($_REQUEST['align'] == "center") { echo "<center>"; } } echo $meta['title'] . "<br>"; echo $album->getName() . "<br>"; echo $this_site . $display->returnImage($album->getMainArt(false, true, "audio", true), $album->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true) . "<br>"; echo $artist->getName() . "<br>"; echo $display->returnImage($artist->getMainArt(false, true, "audio", true), $artist->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true) . "<br>"; break; case "mt": $art = $album->getMainArt($imagesize, true, "audio", true); if ($art) { // Now let's try to get the link from the amazon meta data service if ($_REQUEST['amazon_id'] != "") { $jzService = new jzServices(); $jzService->loadService("metadata", "amazon"); $id = $jzService->getAlbumMetadata($album, false, "id"); echo '<a target="_blank" href="http://www.amazon.com/exec/obidos/tg/detail/-/' . $id . '/' . $_REQUEST['amazon_id'] . '/">'; } $display->image($art, $album->getName(), 150, false, "limit"); if ($_REQUEST['amazon_id'] != "") { echo '</a>'; } echo "<br>"; } echo $meta['title'] . "<br>"; if ($_REQUEST['amazon_id'] != "") { $jzService = new jzServices(); $jzService->loadService("metadata", "amazon"); $id = $jzService->getAlbumMetadata($album, false, "id"); echo '<a target="_blank" href="http://www.amazon.com/exec/obidos/tg/detail/-/' . $id . '/' . $_REQUEST['amazon_id'] . '/">' . $album->getName() . "</a><br>"; } else { echo $album->getName() . "<br>"; } echo $artist->getName() . "<br>"; break; } $found = true; // Now should we stop? $i++; if ($i >= $total) { break; } } } } if (!$found) { // Ok, we didn't find anything so let's get the last thing they played... $be = new jzBackend(); $history = explode("\n", $be->loadData("playhistory-" . $jzUSER->getID())); $track = new jzMediatrack($history[count($history) - 1]); $album = $track->getParent(); $artist = $album->getParent(); $meta = $track->getMeta(); // Now, now let's echo out the data switch ($type) { case "xml": echo " <item>\n"; echo " <title>" . $this_site . xmlUrlClean($meta['title']) . "</title>\n"; echo " <album>\n"; echo " <name>" . $this_site . xmlUrlClean($album->getName()) . "</name>\n"; echo " <image>" . $this_site . xmlUrlClean($display->returnImage($album->getMainArt(false, true, "audio", true), $album->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true)) . "</image>\n"; echo " </album>\n"; echo " <artist>\n"; echo " <name>" . $this_site . xmlUrlClean($artist->getName()) . "</name>\n"; echo " <image>" . $this_site . xmlUrlClean($display->returnImage($artist->getMainArt(false, true, "audio", true), $artist->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true)) . "</image>\n"; echo " </artist>\n"; echo " </item>\n"; break; case "html": if (isset($_REQUEST['align'])) { if ($_REQUEST['align'] == "center") { echo "<center>"; } } echo $meta['title'] . "<br>"; echo $album->getName() . "<br>"; echo $this_site . $display->returnImage($album->getMainArt(false, true, "audio", true), $album->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true) . "<br>"; echo $artist->getName() . "<br>"; echo $display->returnImage($artist->getMainArt(false, true, "audio", true), $artist->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true) . "<br>"; break; case "mt": if (isset($_REQUEST['align'])) { if ($_REQUEST['align'] == "center") { echo "<center>"; } } $art = $album->getMainArt($imagesize, true, "audio", true); if ($art) { // Now let's try to get the link from the amazon meta data service if ($_REQUEST['amazon_id'] != "") { $jzService = new jzServices(); $jzService->loadService("metadata", "amazon"); $id = $jzService->getAlbumMetadata($album, false, "id"); echo '<a target="_blank" href="http://www.amazon.com/exec/obidos/tg/detail/-/' . $id . '/' . $_REQUEST['amazon_id'] . '/">'; } $display->image($art, $album->getName(), 150, false, "limit"); if ($_REQUEST['amazon_id'] != "") { echo '</a>'; } echo "<br>"; } echo $meta['title'] . "<br>"; if ($_REQUEST['amazon_id'] != "") { $jzService = new jzServices(); $jzService->loadService("metadata", "amazon"); $id = $jzService->getAlbumMetadata($album, false, "id"); echo '<a target="_blank" href="http://www.amazon.com/exec/obidos/tg/detail/-/' . $id . '/' . $_REQUEST['amazon_id'] . '/">' . $album->getName() . "</a><br>"; } else { echo $album->getName() . "<br>"; } echo $artist->getName() . "<br>"; break; } } // Now let's close out switch ($type) { case "xml": echoXMLFooter(); break; case "html": echo '<a target="_blank" title="Jinzora :: Free Your Media!" href="http://www.jinzora.com"><img src="http://www.jinzora.com/downloads/button-stream.gif" border="0"></a>'; break; case "mt": echo '<a target="_blank" title="Jinzora :: Free Your Media!" href="http://www.jinzora.com"><img src="http://www.jinzora.com/downloads/button-stream.gif" border="0"></a>'; break; } if (isset($_REQUEST['align'])) { if ($_REQUEST['align'] == "center") { echo "</center>"; } } }
/** * Returns the AJAX code for the NSB * * @author Ross Carlson * @since 8.21.05 * **/ function returnNowStreaming() { global $jzUSER, $img_tiny_play, $im_tiny_play_dis, $css, $img_tiny_info, $skin, $root_dir, $include_path, $jzSERVICES, $who_is_where_height; $define_only = true; //include_once($include_path. $css); writeLogData("messages", "NSB: starting up"); // Now let's figure out the height $be = new jzBackend(); $display = new jzDisplay(); $tracks = $be->getPlaying(); $retVal = ""; $count = 0; foreach ($tracks as $sid => $song) { // Let's make sure we got data if (count($song) != 0) { // Now let's setup for our links $url_array = array(); $url_array['jz_path'] = $song['path']; $url_array['action'] = "playlist"; $url_array['type'] = "track"; $urlArr = array(); $urlArr['session'] = $sid; $urlArr['action'] = "popup"; $urlArr['ptype'] = "viewcurrentinfo"; $infoLink = '<a href="' . str_replace("ajax_request", "index", urlize($urlArr)) . '" onclick="openPopup(this, 450, 300); return false;">' . $img_tiny_info . '</a>'; $arr = array(); $pArr = explode("/", $song['path']); unset($pArr[count($pArr) - 1]); $arr['jz_path'] = implode("/", $pArr); $songTrack = $display->returnShortName($song['track'], 15); /* if ($lyricsLink == ""){ $songTrack = $display->returnShortName($song['track'],15); } else { $songTrack = $display->returnShortName($song['track'],13); } */ $track = new jzMediaNode($song['path']); $item = $track->getParent(); if ($item->getPType() == "disk") { $item = $item->getParent(); } $album = $item->getName(); $artParent = $item->getParent(); $artist = $artParent->getName(); $art = $item->getMainArt("75x75"); if ($art) { $albumImage = str_replace("'", "\\'", str_replace('"', '', $display->returnImage($art, $album, 75, 75, "limit", false, false, "left", "3", "3"))); } else { $albumImage = ""; } $desc_truncate = 200; $desc = htmlentities(str_replace("'", "\\'", str_replace('"', '', $item->getDescription()))); // Now let's set the title and body $title = htmlentities(str_replace("'", "\\'", str_replace('"', '', $artist . " - " . $song['track']))); $userName = $song['name']; if ($userName == "") { $userName = word("Anonymous"); } if ($song['fullname'] != "") { $userName = $song['fullname']; } $body = "<strong>" . word("Streaming to: ") . $userName . "</strong><br>" . $albumImage . $display->returnShortName($desc, $desc_truncate); //$albumImage; $count++; if ($jzUSER->getSetting('stream')) { $retVal .= ' <a href="' . str_replace("ajax_request.php", "index.php", urlize($url_array)) . '"'; if (checkPlayback() == "embedded") { //$jzSERVICES = new jzServices(); $jzSERVICES->loadUserServices(); $retVal .= ' ' . $jzSERVICES->returnPlayerHref(); } $retVal .= '>' . $img_tiny_play . '</a>' . $infoLink . '<a ' . $display->returnToolTip($body, $title) . ' target="_parent" href="' . str_replace("ajax_request", "index", urlize($arr)) . '">' . $songTrack . '</a><br>'; } else { $retVal .= '' . $img_tiny_play_dis . '' . $infoLink . '<a ' . $display->returnToolTip($body, $title) . ' target="_parent" ' . $title . ' href="' . str_replace("ajax_request", "index", urlize($arr)) . '">' . $songTrack . '</a><br>'; } } } if ($count == 1 or $count == 0) { $tCtr = ""; } else { $tCtr = " (" . $count . ")"; } $retVal = "<strong>" . word("Now Streaming") . $tCtr . "</strong><br />" . $retVal; $maxHeight = $who_is_where_height * 13 + 26; $style = ""; if ($maxHeight < $count * 13 + 26) { $style = "<style>#whoiswhere{height: " . $maxHeight . "px;overflow:auto;}</style>"; } $return = $style . $retVal; writeLogData("messages", "NSB: displaying data"); echo $retVal; exit; }
function getCurrentlyPlayingTrack($mysid = false) { if ($mysid === false) { if (isset($_SESSION['sid'])) { $mysid = $_SESSION['sid']; } else { return false; } } $be = new jzBackend(); $tracks = $be->getPlaying(); foreach ($tracks as $sid => $song) { if ($mysid == $sid) { $track = new jzMediaTrack($song['path']); return $track; } } return false; }