static function getJbArr() { global $jbArr; if (isset($jbArr)) { return $jbArr; } @(include_once $include_path . "jukebox/settings.php"); /** * Get names of available 'quickboxes' */ $backend = new jzBackend(); $boxes = $backend->loadData('quickboxes'); $newboxes = array(); $clear_old = false; if ($boxes) { foreach ($boxes as $id => $box) { if ($box['poll_time'] * 5 + $box['active_time'] < time()) { $clear_old = true; continue; } $newboxes[$id] = $box; $jb = array('type' => 'quickbox'); $jb['description'] = $id; $jbArr[] = $jb; } // clear old jukeboxes if ($clear_old) { $backend->storeData('quickboxes', $newboxes, 1); } } return $jbArr; }
function doUserBrowsing($node) { global $jzUSER; $jzBackend = new jzBackend(); $oldHist = $jzUSER->loadData('history'); $jzUSER->storeData('history', $node->getPType() . "|" . $node->getName() . "|" . $node->getPath("String") . "|" . time() . "\n" . substr($oldHist, 0, 5000)); $oldHist = $jzBackend->loadData('history'); // Now let's find the history for this user $dArr = explode("\n", $oldHist); for ($i = 0; $i < count($dArr); $i++) { $vArr = explode("|", $dArr[$i]); if ($vArr[6] == $_SESSION['sid']) { unset($dArr[$i]); } } $oldHist = implode("\n", $dArr); $jzBackend->storeData('history', $node->getPType() . "|" . $node->getName() . "|" . $node->getPath("String") . "|" . time() . "|" . $jzUSER->getName() . "|" . $jzUSER->getSetting('fullname') . "|" . $_SESSION['sid'] . "|" . $_SERVER['REMOTE_ADDR'] . "\n" . substr($oldHist, 0, 50000)); }
return; } if (isset($_POST['update_postsettings'])) { echo word("Settings updated") . "<br>"; } $page_array = array(); $page_array['action'] = "popup"; $page_array['ptype'] = "usermanager"; $page_array['subaction'] = "registration"; $display->openSettingsTable(urlize($page_array)); $display->settingsCheckbox(word("Allow Self-Registration") . ":", 'allow_registration', $data); $keys = array_keys($classes); $display->settingsDropdown(word("User Template:"), 'classname', $keys, $data); $display->closeSettingsTable(true); if (isset($_POST['update_postsettings'])) { $be->storeData('registration', $data); } return; } // * * * * * * * * // // ANONYMOUS USER SUBSECTION // * * * * * * * * // if ($_GET['subaction'] == "default_access") { $_GET['subaction'] = "edituser"; $_POST['user_to_edit'] = $jzUSER->lookupUID(NOBODY); } // * * * * * * * * // // EDIT USER SUBSECTION // * * * * * * * * // if ($_GET['subaction'] == "edituser") { if (!isset($_POST['user_to_edit'])) {
/** * Shows the chart system * * @author Ross Carlson * @version 01/26/05 * @since 01/26/05 * @param $node The node we are viewing so we can filter * @param $types The charts to display. Comma seperated list of: * topplayalbum, topplayartist, topdownalbum, newalbums, newartists, newtracks * recentplayalbum, recentplayartist, recentplaytrack, * topratedalbum, topratedartist, topviewartist, topplaytrack * @param $numItems The number of items we want to return (defaults to 5) * @param $format Should we format this or return raw data (defaults to true) * @param $opts an array of extra options (transitioning to new parameter scheme) * */ function showCharts($node, $types = false, $numItems = false, $format = true, $vertAlign = false, $opts = false) { global $album_name_truncate, $img_tiny_play, $img_tiny_play_dis, $jzUSER, $img_rss, $root_dir, $advanced_tooltips, $rss_in_charts, $num_items_in_charts, $chart_timeout_days, $chart_types; $be = new jzBackend(); if ($be->hasFeature('charts') === false) { return; } // Let's setup our objects $blocks = new jzBlocks(); $display = new jzDisplay(); $nobr = true; if ($opts !== false) { if (isset($opts['allow_breaks'])) { $nobr = false; } else { $nobr = true; } } // Now let's do a loop creating all our blocks if ($types === false || $types == "") { if (isset($chart_types) && !isNothing($chart_types)) { $b = $chart_types; } else { $b = "topplayalbum,topplayartist,topviewartist,newalbums"; } } else { $b = $types; } $bArray = explode(",", $b); for ($e = 0; $e < count($bArray); $e++) { // Now let's create our blocks $showPlays = false; switch ($bArray[$e]) { case "topplayalbum": $func = "getMostPlayed"; $arr['action'] = "popup"; $arr['ptype'] = "topstuff"; $arr['tptype'] = "played-albums"; $title = word("Top Played Albums"); $distance = "album"; $showPlays = true; $showDownload = false; $rss = "most-played"; break; case "topplayartist": $func = "getMostPlayed"; $arr['action'] = "popup"; $arr['ptype'] = "topstuff"; $arr['tptype'] = "played-artists"; $title = word("Top Played Artists"); $distance = "artist"; $showPlays = true; $showDownload = false; $rss = "most-played-artist"; break; case "topdownalbum": $func = "getMostDownloaded"; $arr['action'] = "popup"; $arr['ptype'] = "topstuff"; $arr['tptype'] = "downloaded-albums"; $title = word("Top Downloaded Albums"); $distance = "album"; $showDownload = true; $rss = "most-downloaded"; break; case "newalbums": $func = "getRecentlyAdded"; $arr['action'] = "popup"; $arr['ptype'] = "topstuff"; $arr['tptype'] = "new-albums"; $title = word("New Albums"); $distance = "album"; $showDownload = false; $rss = "last-added"; break; case "newartists": $func = "getRecentlyAdded"; $arr['action'] = "popup"; $arr['ptype'] = "topstuff"; $arr['tptype'] = "new-artists"; $title = word("New Artists"); $distance = "artist"; $showDownload = false; $rss = "last-added-artists"; break; case "newtracks": $func = "getRecentlyAdded"; $arr['action'] = "popup"; $arr['ptype'] = "topstuff"; $arr['tptype'] = "new-tracks"; $title = word("New Tracks"); $distance = "track"; $showDownload = false; $rss = "last-added-tracks"; break; case "recentplaytrack": $func = "getRecentlyPlayed"; $arr['action'] = "popup"; $arr['ptype'] = "topstuff"; $arr['tptype'] = "recentplayed-tracks"; $title = word("Recently Played Tracks"); $distance = "track"; $showDownload = false; $rss = "recentplayed-track"; break; case "topplaytrack": $func = "getMostPlayed"; $arr['action'] = "popup"; $arr['ptype'] = "topstuff"; $arr['tptype'] = "played-tracks"; $title = word("Top Played Tracks"); $distance = "track"; $showDownload = false; $rss = "most-played-tracks"; break; case "recentplayalbum": $func = "getRecentlyPlayed"; $arr['action'] = "popup"; $arr['ptype'] = "topstuff"; $arr['tptype'] = "recentplayed-albums"; $title = word("Recently Played Albums"); $distance = "album"; $showDownload = false; $rss = "recentplayed-album"; break; case "recentplayartist": $func = "getRecentlyPlayed"; $arr['action'] = "popup"; $arr['ptype'] = "topstuff"; $arr['tptype'] = "recentplayed-artists"; $title = word("Recently Played Artists"); $distance = "artist"; $showDownload = false; $rss = "recentplayed-artist"; break; case "topratedalbum": $func = "getTopRated"; $arr['action'] = "popup"; $arr['ptype'] = "topstuff"; $arr['tptype'] = "toprated-albums"; $title = word("Top Rated Albums"); $distance = "album"; $showDownload = false; $rss = "toprated-album"; break; case "topratedartist": $func = "getTopRated"; $arr['action'] = "popup"; $arr['ptype'] = "topstuff"; $arr['tptype'] = "toprated-artists"; $title = word("Top Rated Artists"); $distance = "artist"; $showDownload = false; $rss = "toprated-artist"; break; case "topviewartist": $func = "getMostViewed"; $arr['action'] = "popup"; $arr['ptype'] = "topstuff"; $arr['tptype'] = "topviewed-artists"; $title = word("Most Viewed Artists"); $distance = "artist"; $showDownload = false; $rss = "topviewed-artist"; break; default: continue; } // Now let's get the data if ($distance == "track") { $returnType = "tracks"; } else { $returnType = "nodes"; } if ($numItems) { $num_items_in_charts = $numItems; } if ($chart_timeout_days > 0) { $be = new jzBackend(); $data_id .= pathize('chart-' . $node->getPath("String")) . "-{$func}-{$distance}-{$num_items_in_charts}"; if (($recent = $be->loadData($data_id, true)) === false) { $recent = $node->{$func}($returnType, distanceTo($distance, $node), $num_items_in_charts); $be->storeData($data_id, $recent, $chart_timeout_days); } } else { $recent = $node->{$func}($returnType, distanceTo($distance, $node), $num_items_in_charts); } // Now let's see if we got data if (count($recent) == 0) { continue; } ?> <td width="25%" valign="top"> <?php if ($format) { echo '<div id="slickMainBlockBody">'; } ?> <table width="95%" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="100%" valign="middle"> <?php if ($nobr) { echo '<nobr>'; } ?> <?php if ($format) { // Now let's display the link to the FULL top played list echo '<a onclick="openPopup(this, 300, 450); return false;" title="' . $title . '" href="' . urlize($arr) . '"><strong>' . $title . '</strong></a>'; // Let's link to the RSS feed if ($rss_in_charts == "true") { echo ' - <a href="' . $root_dir . '/rss.php?type=' . $rss; if ($node->getLevel() != 0) { echo '&root=' . $node->getPath("String"); } echo '">' . $img_rss . '</a>'; } echo '<br>'; } // Now let's loop through the results for ($i = 0; $i < count($recent); $i++) { // Now let's create our node and get the properties $item = $artnode = $recent[$i]; $album = $item->getName(); $parent = $item->getAncestor("artist"); if ($parent !== false) { $artist = $parent->getName(); } $albumDLCount = $item->getDownloadCount(); $year = $item->getYear(); $dispYear = ""; if ($year != "-") { $dispYear = " (" . $year . ")"; } // Now let's create our links if ($distance == "track") { $artnode = $item->getAncestor("album"); if (is_object($artnode)) { $albumArr['jz_path'] = $artnode->getPath("String"); $gp = $item->getAncestor("artist"); if (is_object($gp)) { $artistArr['jz_path'] = $gp->getPath("String"); } else { $artistArr['jz_path'] = ''; } } else { $albumArr['jz_path'] = ''; $artistArr['jz_path'] = ''; } } else { $albumArr['jz_path'] = $item->getPath("String"); if ($parent !== false) { $artistArr['jz_path'] = $parent->getPath("String"); } } // Now let's create our short names $artistTitle = returnItemShortName($artist, $album_name_truncate); $albumTitle = returnItemShortName($album, $album_name_truncate); // Now let's display it if ($nobr) { echo "<nobr>"; } if (!$jzUSER->getSetting('stream')) { echo $img_tiny_play_dis; } else { $display->playLink($item, $img_tiny_play, $album); } // Ok, did they want advanced tooltips? if ($advanced_tooltips == "true") { // Now let's set the hover code $innerOver = ""; $showTip = false; if (($art = $artnode->getMainArt("75x75")) != false) { $innerOver .= $display->returnImage($art, $artnode->getName(), 75, 75, "limit", false, false, "left", "3", "3"); $showTip = true; $bTitle = $artist . " - " . $album . $dispYear; } else { // Ok, no art so let's make this look better $innerOver .= "<strong>" . $artist . "<br>" . $album . $dispYear . "</strong><br>"; $bTitle = $album . $dispYear; } $desc_truncate = 200; $desc = $item->getDescription(); if (!isNothing($desc)) { $innerOver .= $display->returnShortName($desc, $desc_truncate); $showTip = true; } // Now let's fix up $innerOver = str_replace("'", "", str_replace('"', "", $innerOver)); $bTitle = str_replace("'", "", str_replace('"', "", $bTitle)); if ($showTip) { $title = $display->returnToolTip($innerOver, $bTitle); } else { $title = ' title="' . $artist . ' - ' . $album . $dispYear . '"'; } } else { // Standard tooltips $title = ' title="' . $artist . ' - ' . $album . $dispYear . '"'; } echo ' <a ' . $title . ' href="' . urlize($albumArr) . '">' . $albumTitle; if ($showPlays) { if ($bArray[$e] == "topplayalbum") { $albumPlayCount = $item->getSubNodeCount('tracks', -1); if ($albumPlayCount > 0) { $albumPlayCount = ceil($item->getPlayCount() / $albumPlayCount); } } else { $albumPlayCount = $item->getPlayCount(); } echo ' (' . $albumPlayCount . ')'; } if ($showDownload) { echo ' (' . $albumDLCount . ')'; } echo "</a><br>"; if ($nobr) { echo "</nobr>"; } } if ($nobr) { echo '</nobr>'; } ?> </td> </tr> </table> <?php if ($format) { echo '</div>'; } ?> </td> <?php if ($vertAlign) { echo '</tr><tr>'; } ?> <?php } }
$be = new jzBackend(); $classes = array(); $settings = array(); $settings['ratingweight'] = 1; $settings['stream'] = "true"; $settings['view'] = "true"; $settings['lofi'] = "true"; $settings['download'] = "true"; $settings['discuss'] = "true"; $settings['powersearch'] = "true"; $settings['edit_prefs'] = "true"; $settings['frontend'] = $_POST['frontend']; $settings['theme'] = $_POST['style']; $settings['language'] = $_POST['jz_lang_file']; $classes[word('Standard')] = $settings; $be->storeData('userclasses', $classes); $jzUSER = new jzUser(false); $ausr = stripSlashes($_POST['admin_user']); $apass = stripSlashes($_POST['admin_pass']); if (($id = $jzUSER->lookupUID('NOBODY')) !== false) { $settings = array(); $settings['edit_prefs'] = "false"; switch ($_POST['default_access']) { case "noaccess": $settings['ratingweight'] = 0; $settings['stream'] = "false"; $settings['view'] = "false"; $settings['lofi'] = "false"; $settings['download'] = "false"; break; case "viewonly":
/** * Returns an array of similar artists * * @author Ross Carlson, Ben Dodson * @version 01/14/05 * @since 01/14/05 * @param $node The node for the artist/album * @param $limit Limit the number of results */ function SERVICE_SIMILAR_echocloud($element, $limit = false) { if ($element === false) { return; } // Let's setup the backend to read the cache to see if we can just return it $be = new jzBackend(); $data = $be->loadData("similar-data-" . $element->getName()); $tArr = explode("\n", $data); // Now let's see if this is more than 1 week old, if so let's update if ($data !== false && $tArr[0] + 604800 > time()) { // Ok, the cache is less than 1 week old let's return it return unserialize($tArr[1]); } // Let's setup the root node $root = new jzMediaNode(); $artist = $element->getName(); $artist = preg_replace("/^{$artist}, *the\$/i", "The {$artist}", $artist); // Let's grab the data first $ec_con = returnEchocloudData($artist); if (!$ec_con) { return false; } // Let's make sure that opened ok and if so parse the data if ($ec_con != "" and strlen($ec_con) > 600) { // Ok, now let's clean up what we got back $ec_con = substr($ec_con, 0, strpos($ec_con, "</rs>")); $ec_con = substr($ec_con, strpos($ec_con, "</date>") + 7, strlen($ec_con)); // Now let's split it out by each item $ecArray = explode("<r>", $ec_con); $nonMatch = ""; $search_array = array(); for ($i = 0; $i < count($ecArray); $i++) { if ($ecArray[$i] != "") { // Ok, now let's read the items $ecArtist = substr($ecArray[$i], 3, strlen($ecArray[$i])); $ecArtist = substr($ecArtist, 0, strpos($ecArtist, "<")); $ecArtist = str_replace("'", "", $ecArtist); if ($ecArtist != $artist and $ecArtist != "") { $retArray[] = $ecArtist; } } } // Now we know all the artists that are 'similar'. // Now should we limit? if ($limit) { $retArray = @array_slice($retArray, 0, $limit); } // Now let's store this for later caching $be->storeData("similar-data-" . $element->getName(), time() . "\n" . serialize($retArray)); // Now let's return return $retArray; } return false; }
function moveMedia($element, $newpath) { $root = new jzMediaNode(); $be = new jzBackend(); $playpath = $element->getFilePath(); $type = $element->isLeaf() ? "leaf" : "node"; if (is_string($newpath)) { $path = explode("/", $newpath); } else { if (is_array($newpath)) { $path = $newpath; } else { return false; } } if ($type == "node") { return false; } $pc = $element->getPlayCount(); $dc = $element->getDownloadCount(); $vc = $element->getViewCount(); $desc = $element->getDescription(); $sdesc = $element->getShortDescription(); $art = $element->getMainArt(); $discussion = $element->getDiscussion(); $rating = $element->getRating(); $rating_count = $element->getRatingCount(); if ($be->hasFeature('setID')) { $mid = $element->getID(); } // TODO: // This does not work correctly with nodes yet. // You should pull the above data, then recursively move children, // then remove me, and finally set the data as below. // I did not do this yet (8/11/05) because I would not have been // able to test it. (for things like collisions, // and also how to handle the filesystem) // If the backend has a lookup file, update it. if ($element->isLeaf()) { $media_path = getMediaDir($element); $be = new jzBackend(); $rl_name = 'reverse_lookup-' . str_replace(':', '', str_replace('\\', '-', str_replace('/', '-', $media_path))); $LOOKUP = $be->loadData($rl_name); if (is_array($LOOKUP)) { if (isset($LOOKUP[$element->getFilename("host")])) { $LOOKUP[$element->getFilename("host")] = implode('/', $path); $be->storeData($rl_name, $LOOKUP); } } } $this->removeMedia($element); if (false !== ($new = $root->inject($path, $playpath))) { $new->setPlayCount($pc); $new->setDownloadCount($dc); $new->setViewCount($vc); $new->addRating($rating, $rating_count); if ($be->hasFeature('setID')) { $new->setID($mid); } if (!isNothing($desc)) { $new->addDescription($desc); } if (!isNothing($sdesc)) { $new->addShortDescription($sdesc); } if (!isNothing($art)) { $new->addMainArt($art); } if ($discussion != array() && !isNothing($discussion)) { $new->addFullDiscussion($discussion); } return $new; } }
/** * Returns an array of similar artists * * @author Ross Carlson, Ben Dodson * @version 01/14/05 * @since 01/14/05 * @param $node The node for the artist/album * @param $limit Limit the number of results */ function SERVICE_SIMILAR_audioscrobbler($element, $limit = false) { if ($element === false) { return; } $cachename = "similar-scrobbler-" . $element->getName(); // Let's setup the backend to read the cache to see if we can just return it $be = new jzBackend(); if (false !== ($data = $be->loadData($cachename))) { if ($limit && $limit > sizeof($data)) { return array_slice($data, 0, $limit); } else { return $data; } } $artist = $element->getName(); if (stristr($artist, ", The") !== false) { $artist = str_replace(", The", "", $artist); $artist = "The " . $artist; } // Let's grab the data first $server = "ws.audioscrobbler.com"; $page = "/1.0/artist/" . rawurlencode($artist) . "/similar.txt"; $fp = @fsockopen($server, 80, $errno, $errstr, 2); if ($fp) { fputs($fp, "GET {$page} HTTP/1.1\r\nHost:{$server}\r\n\r\n"); fputs($fp, "Connection: close\n\n"); $data = ""; $blnHeader = true; while (!feof($fp)) { if ($blnHeader) { if (fgets($fp, 1024) == "\r\n") { $blnHeader = false; } } else { $data .= fread($fp, 1024); } } fclose($fp); if (stristr($data, 'No artist exists with this name')) { $sim_artists = array(); } else { $sim_artists = array(); $data = explode("\n", $data); foreach ($data as $entry) { $match = substr($entry, 0, strpos($entry, ',')); if ($match > 50) { // a decent match... let's add it. $sim_artists[] = substr($entry, strpos($entry, ',', strpos($entry, ',') + 1) + 1); // Get it after the second comma. } else { break; } } } } else { return false; } // Now let's store this for later caching $be->storeData($cachename, $sim_artists, 7); // expires in 7 days // Now let's return if ($limit) { return array_slice($sim_artists, 0, $limit); } else { return $sim_artists; } }
$pData = $be->loadData("podcast"); $i = count($pData) + 1; $pArr[$i]['title'] = $_POST['edit_podcast_title']; $pArr[$i]['url'] = $_POST['edit_podcast_url']; $pArr[$i]['path'] = $_POST['edit_podcast_path']; $pArr[$i]['number'] = $_POST['edit_podcast_max']; if (is_array($pData)) { $add = true; foreach ($pData as $data) { if ($data['title'] == $_POST['edit_podcast_title']) { $add = false; } } if ($add) { $nArr = array_merge($pData, $pArr); $be->storeData("podcast", $nArr); } } else { $be->storeData("podcast", $pArr); } // Now let's get the data $retArray = parsePodcastXML($_POST['edit_podcast_url']); $title = $retArray['title']; unset($retArray['title']); $desc = $retArray['desc']; unset($retArray['desc']); $desc = str_replace("]]>", "", str_replace("<![CDATA[", "", $desc)); $pubDate = $retArray['pubDate']; unset($retArray['pubDate']); $image = $retArray['image']; unset($retArray['image']);
} $be = new jzBackend(); // Let's figure out the news location if ($node->getName() == "") { $news = "site-news"; $title = word("Site News"); } else { $news = $node->getName() . "-news"; $title = word("Site News") . ": " . $node->getName(); } $this->displayPageTop("", $title); $this->openBlock(); // Did they submit the form to edit the news? if (isset($_POST['updateSiteNews'])) { // Now let's store the data $be->storeData($news, nl2br(str_replace("<br />", "", $_POST['siteNewsData']))); } // Let's show the form to edit with $arr = array(); $arr['action'] = "popup"; $arr['ptype'] = "sitenews"; $arr['jz_path'] = $_GET['jz_path']; echo '<form action="' . urlize($arr) . '" method="POST">'; ?> <br> <center> <textarea name="siteNewsData" cols="60" rows="20" class="jz_input"><?php echo $be->loadData($news); ?> </textarea> <br><br>
$be = new jzBackend(); // Get a semi-unique ID $id = getMyId(); $boxes = $be->loadData('quickboxes'); if (!isset($boxes[$id])) { $box = array('id' => $id); } else { $box = $boxes[$id]; } $box['active_time'] = time(); $box['poll_time'] = $POLL_TIME; if (isset($_REQUEST['update_pos'])) { $box['pos'] = $_REQUEST['update_pos']; } $boxes[$id] = $box; $be->storeData('quickboxes', $boxes, 1); //$be->storeData('quickboxes',array(),1); // clear if (isset($_REQUEST['update']) && !isset($_REQUEST['update_pos'])) { require_once dirname(__FILE__) . '/../lib/json.php'; $obj = array(); $obj['command'] = ''; $obj['time'] = ''; if (isset($box['command'])) { $obj['command'] = $box['command']; $obj['time'] = $box['command_time']; if ($box['command'] == 'playlist') { $obj['playlist'] = $box['playlist']; $obj['addtype'] = $box['addtype']; } if ($box['command'] == 'jumpto') { $obj['pos'] = $box['pos'];