if (!defined(JZ_SECURE_ACCESS)) { die('Security breach detected.'); } /** * Displays the track details for the currently playing track in WMP * * @author Ross Carlson * @since 8.3.06 * @version 8.3.06 **/ global $this_site, $root_dir, $jzSERVICES, $web_root; // Let's setup our display object $display = new jzDisplay(); // Let's create the track object $track = new jzMediaTrack($_GET['jz_path']); $meta = $track->getMeta(); // Now let's get the album and artist $album = $track->getNaturalParent("album"); $artist = $album->getNaturalParent("artist"); $desc = $album->getDescription(); while (substr($desc, 0, 4) == "<br>" or substr($desc, 0, 6) == "<br />") { if (substr($desc, 0, 4) == "<br>") { $desc = substr($desc, 5); } if (substr($desc, 0, 6) == "<br />") { $desc = substr($desc, 7); } } // Now let's get the art $art = $album->getMainArt("200x200");
/** * 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; }
<?php if (!defined(JZ_SECURE_ACCESS)) { die('Security breach detected.'); } /** * Pulls the lyrics from a track and displays just them * * @author Ross Carlson * @since 04/08/05 * @version 04/08/05 * @param $node object The node we are viewing * **/ global $node; $track = new jzMediaTrack($node->getPath('String')); $meta = $track->getMeta(); $this->displayPageTop("", word("Lyrics for:") . " " . $meta['title']); $this->openBlock(); echo nl2br($meta['lyrics']); echo '<br><br><center>'; $this->closeButton(); $this->closeBlock();
function handleRules() { global $jzSERVICES; if ($this->getPlType() != "dynamic") { return false; } $temp = array(); $this->list = array(); foreach ($this->rulelist as $rule) { $source = new jzMediaNode($rule['source']); $count = $rule['amount']; if ($rule['type'] == "track" || $rule['type'] == "tracks") { $type = "tracks"; $distance = -1; } else { $type = "nodes"; $distance = distanceTo("album", $source); } switch ($rule['function']) { case "exact": if ($type == "tracks") { $source = new jzMediaTrack($rule['source']); } $temp = array($source); break; case "random": $temp = $source->getSubNodes($type, $distance, true, $count); break; case "topplayed": $temp = $source->getMostPlayed($type, $distance, $count); break; case "recentlyadded": $temp = $source->getRecentlyAdded($type, $distance, $count); break; case "similar": if ($source->getPType() == "artist") { $mainArray = $source->getSubNodes($type, $distance, true, $count); // Now let's get the top 5 similar artists $simArray = $jzSERVICES->getSimilar($source); $simArray = seperateSimilar($simArray); $i = 0; $limit = 8; // Now let's shuffle $similarArray = array(); for ($e = 0; $e < count($simArray['matches']); $e++) { if (isset($simArray['matches'][$e])) { // Ok, this is one that we want, let's get it's path $simArt = $simArray['matches'][$e]; $subArray = $simArt->getSubNodes($type, $distance, true, $count / 1.5); $similarArray = array_merge($similarArray, $subArray); $i++; if ($limit) { if ($i > $limit) { break; } } } } $finArray = array_merge($similarArray, $mainArray); shuffle($finArray); $temp = array(); for ($i = 0; $i < $count; $i++) { $temp[] = $finArray[$i]; } } else { $temp = $source->getSubNodes($type, $distance, true, $count); } break; } foreach ($temp as $l) { $this->list[] = $l; } } shuffle($this->list); if (isset($this->limit) && $this->limit > 0) { $this->truncate($this->limit); } }
function setLyrics($lyrics, $path) { global $jzUSER; if (!checkPermission($jzUSER, 'admin', $path)) { echo word('Insufficient permissions.'); } else { $track = new jzMediaTrack($path); $meta = array(); $meta['lyrics'] = $lyrics; $track->setMeta($meta); echo word('Lyrics updated.'); } }
/** * Returns the current playing track * * @author Ross Carlson * @version 2/9/05 * @since 2/9/05 * @return Returns the name of the current playing track */ function getCurTrackName() { global $jbArr; $myMpd = _mpdConnection(); if ($myMpd->current_track_id == -1) { return false; } if (isset($jbArr[$_SESSION['jb_id']]['prefix']) && $jbArr[$_SESSION['jb_id']]['prefix'] == "http") { $id = getTrackIdFromURL($myMpd->playlist[$myMpd->current_track_id]['file']); if (false !== $id) { $track = new jzMediaTrack($id, 'id'); $meta = $track->getMeta(); return $meta['artist'] . ' - ' . $meta['title']; } else { return 'Unknown'; } } else { return $myMpd->playlist[$myMpd->current_track_id]['Artist'] . " - " . $myMpd->playlist[$myMpd->current_track_id]['Title']; } }
/** * Gets the length of the current track * * @author Ross Carlson * @version 2/9/05 * @since 2/9/05 * @param return returns the amount of time remaining in seconds */ function getCurTrackLength() { global $jbArr, $media_dirs; // Ok, now we need to get the length of this track by reading it's meta data $path = getCurTrackPath(); $mArr = explode("|", $media_dirs); for ($i = 0; $i < count($mArr); $i++) { $path = str_replace($mArr[$i] . "/", "", $path); } $track = new jzMediaTrack($path); $meta = $track->getMeta(); return $meta['length']; }
/** * Gets the track title from * its ID. */ function idToName($id) { $track = new jzMediaTrack($id, 'id'); $meta = $track->getMeta(); $title = ''; if (!isNothing($meta['artist'])) { $title .= $meta['artist']; } if (!isNothing($meta['title'])) { if (!isNothing($title)) { $title .= ' - '; } $title .= $meta['title']; } if (isNothing($title)) { $title = $track->getName(); } return $title; }
/** * Unsets the 'currently playing' info for the user. * If $user is false, removes all tracks. * If $sid is false, removes all tracks for $user. * * @author Ben Dodson * @since 1/23/05 * @version 1/23/05 **/ function unsetPlaying($user = false, $sid = false) { $filename = $this->getDataDir() . "/now-playing.dat"; if (file_exists($filename)) { $array = unserialize(file_get_contents($filename)); } else { $array = array(); } // First let's make sure we didn't do this too fast // If we're using some players they just buffer too fast // And we think the file is done when it's not if (isset($array[$user][$sid]['path'])) { $track = new jzMediaTrack($array[$user][$sid]['path']); $meta = $track->getMeta(); } else { $meta = array(); $meta['length'] = 60; } if ($user === false) { $array = array(); } else { if ($sid === false) { unset($array[$user]); } else { if (time() + $meta['length'] - 30 < time()) { unset($array[$user][$sid]); } } } $handle = fopen($filename, "w"); fwrite($handle, serialize($array)); fclose($handle); }
$output = ""; $returnvalue = ""; if (exec($command, $output, $returnvalue)) { ?> <SCRIPT LANGUAGE=JAVASCRIPT><!--\ s = document.getElementById("status"); s.innerHTML = '<nobr><?php echo word("Status: updating tags..."); ?> </nobr>'; --> </SCRIPT> <?php flushdisplay(); // Now we need to get the meta data from the orginal file so we can write it to the new file $tMeta = new jzMediaTrack($track->getPath("String")); $meta = $tMeta->getMeta(); // Now let's write this $jzSERVICES->setTagData($newPath, $meta); ?> <SCRIPT LANGUAGE=JAVASCRIPT><!--\ p = document.getElementById("path"); o = document.getElementById("oldname"); n = document.getElementById("newname"); s = document.getElementById("status"); p.innerHTML = '<?php echo word("Complete!"); ?> '; o.innerHTML = ' '; n.innerHTML = ' ';
/** * * 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 current playing track * * @author Ben Dodson * @version 12/04/08 * @since 12/04/08 * @return Returns the name of the current playing track */ function getCurTrackName() { $box = Quickbox::load(); if (sizeof($box['playlist']) > 0 && isset($box['pos'])) { $entry = $box['playlist'][$box['pos']]; } if (false !== ($id = getTrackIdFromURL($entry))) { $track = new jzMediaTrack($id, 'id'); $meta = $track->getMeta(); return $meta['artist'] . ' - ' . $meta['title']; } else { return word('Unknown'); } }
/** * Returns the currently playing playlist * * @author Ross Carlson * @version 2/9/05 * @since 2/9/05 * @param return Returns the currently playling playlist */ function getCurPlaylist() { global $jbArr; $val = array(); if (isset($jbArr[$_SESSION['jb_id']]['prefix']) && $jbArr[$_SESSION['jb_id']]['prefix'] == "http") { $arr = httpqRequest('getplaylistfile', array('delim' => ';;;')); $arr = explode(';;;', $arr); foreach ($arr as $i => $url) { if (false != ($id = getTrackIdFromURL($url))) { $track = new jzMediaTrack($id, 'id'); $meta = $track->getMeta(); $title = ''; if (!isNothing($meta['artist'])) { $title .= $meta['artist']; } if (!isNothing($meta['title'])) { if (!isNothing($title)) { $title .= ' - '; } $title .= $meta['title']; } if (isNothing($title)) { $title = $track->getName(); } $val[] = $title; } else { // $val[] = $url; // faster $val[] = httpqRequest('getplaylisttitle', array('index' => $i)); // better } } } else { $val = explode(";;;", @file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . ":" . $jbArr[$_SESSION['jb_id']]['port'] . "/getplaylisttitle?p=" . $jbArr[$_SESSION['jb_id']]['password'] . "&delim=;;;")); } writeLogData("messages", "Winamp3: Returning the current playlist"); return $val; }