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; }
/** * 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 SERVICE_IMPORTMEDIA_filesystem($node, $root_path = false, $flags = array()) { global $ext_graphic, $audio_types, $video_types, $playlist_types, $default_art; if (!isset($playlist_types)) { $playlist_types = "m3u"; } global $importerLevel; if (!isset($importerLevel)) { $importerLevel = 0; } $be = new jzBackend(); if ($root_path !== false) { $folder = $root_path; } else { $folder = $node->getFilePath(); } $bestImage = ""; // TODO: FIX THE PARAMETER HERE FOR 3.0 $thisPath = array_values($flags['path']); $parent = new jzMediaNode($thisPath); if (isset($flags['showstatus']) && $flags['showstatus'] && !(is_string($flags['showstatus']) && $flags['showstatus'] == "cli")) { if (!isset($_SESSION['jz_import_full_progress'])) { $_SESSION['jz_import_full_progress'] = 0; } } if (!($handle = opendir($folder))) { echo 'SERVICE_IMPORTMEDIA_filesystem: could not open ' . $folder; return false; } if (isset($flags['showstatus']) && is_string($flags['showstatus']) && $flags['showstatus'] == "cli") { echo word("Scanning: %s", $folder) . "\n"; } $track_paths = array(); $track_filenames = array(); $track_metas = array(); while ($file = readdir($handle)) { if (importSkipFile($file)) { continue; } $fullpath = $folder . '/' . $file; if (is_dir($fullpath)) { $entry = $be->lookupFile($fullpath); if ($entry === false || isset($flags['recursive']) && $flags['recursive']) { $flags2 = $flags; if (sizeof($flags2['hierarchy']) == 0) { $val = 'disk'; } else { $val = array_shift($flags2['hierarchy']); if ($val == 'track') { $val = "disk"; } } $flags2['path'][$val] = $file; $flags2['recursive'] = true; $importerLevel++; SERVICE_IMPORTMEDIA_filesystem($node, $fullpath, $flags2); $importerLevel--; } } else { if (preg_match("/\\.({$ext_graphic})\$/i", $file) && !stristr($file, ".thumb.")) { // An image if (@preg_match("/({$default_art})/i", $file)) { $bestImage = $fullpath; } else { if ($bestImage == "") { $bestImage = $fullpath; } } } else { if (preg_match("/\\.({$playlist_types})\$/i", $file)) { $ext = substr($file, strrpos($file, '.') + 1); if (0 == strcasecmp($ext, 'm3u')) { $m3u_lines = file($fullpath); $is_local_m3u = false; foreach ($m3u_lines as $line) { if ($line == '#') { // TODO: get metadata. continue; } else { if (false === strpos($line, '://')) { $is_local_m3u = true; break; } $mediaref = $line; $medianame = $mediaref; while ($medianame[strlen($medianame) - 1] == '/') { $medianame = substr($medianame, 0, strlen($medianame) - 1); } $medianame = substr($medianame, strrpos($medianame, '/') + 1); $mypath = $flags['path']; $mypath['track'] = $medianame; $track_paths[] = $mypath; $track_filenames[] = $mediaref; $track_metas[] = array(); } } } } else { if (preg_match("/\\.({$audio_types})\$/i", $file) || preg_match("/\\.({$video_types})\$/i", $file)) { $entry = $be->lookupFile($fullpath); if (isset($flags['showstatus']) && !(is_string($flags['showstatus']) && $flags['showstatus'] == "cli")) { if ($_SESSION['jz_import_full_progress'] % 50 == 0 or $_SESSION['jz_import_full_progress'] == 0 or $_SESSION['jz_import_full_progress'] == 1) { showStatus(); } $_SESSION['jz_import_full_progress']++; } if (isset($flags['force']) && $flags['force'] || !is_array($entry)) { $mypath = $flags['path']; $mypath['track'] = $file; if (isset($flags['readtags']) && $flags['readtags']) { $track =& new jzMediaTrack($fullpath); $track->playpath = $fullpath; $meta = $track->getMeta("file"); } else { $meta = false; } $track_paths[] = $mypath; $track_filenames[] = $fullpath; $track_metas[] = $meta; } } } } } } $node->bulkInject($track_paths, $track_filenames, $track_metas); if ($bestImage != "") { $parent->addMainArt($bestImage); } $be->registerFile($folder, $thisPath); if ($parent->getFilePath() != $folder) { $parent->setFilePath($folder); } if ($importerLevel == 0) { $be->removeDeadFiles($folder, $flags['recursive']); } }
function filenameToPath($fp) { $be = new jzBackend(); $reg = $be->lookupFile($fp); if (false !== $reg) { return $reg['path']; } return false; }
function setHTTPAuthUser() { global $http_auth_anon_name, $http_auth_auto_create, $http_auth_newuser_template; if (isset($_SERVER['REMOTE_USER'])) { $username = $_SERVER['REMOTE_USER']; } else { $username = NOBODY; } if (isset($http_auth_anon_name) && $username == $http_auth_anon_name) { $username = NOBODY; } if (($this->id = $this->lookupUID($username)) != false) { return; } if (isset($http_auth_auto_create) && $http_auth_auto_create == "true" && $username != NOBODY) { // auto-create the user w/ random password $this->id = $this->addUser($username, uniqid('P')); } if ($this->id != false) { writeLogData("access", "created user entry for user '" . $username . "'"); if (isset($http_auth_newuser_template) && $http_auth_newuser_template != "") { $be = new jzBackend(); $classes = $be->loadData('userclasses'); if (isset($classes[$http_auth_newuser_template])) { $settings = array(); $settings['template'] = $http_auth_newuser_template; $this->setSettings($settings, $this->id, true); } } return; } // convert user to nobody if (($this->id = $this->lookupUID(NOBODY)) === false) { // create NOBODY $this->id = $this->addUser(NOBODY, ""); } }
/** * Shows the Slick formated chart system * * @author Ross Carlson * @version 01/26/05 * @since 01/26/05 * @param $node The node we are viewing so we can filter */ function showSlickCharts($node, $types = false) { global $album_name_truncate, $img_tiny_play, $display_charts, $chart_timeout_days; $be = new jzBackend(); if ($be->hasFeature('charts') === false) { return; } $display = new jzDisplay(); if ($display->startCache("showSlickCharts", $node, $chart_timeout_days)) { return; } // First let's make sure they even want the charts if ($display_charts != "true") { return; } $smarty = smartySetup(); $title = word("Charts"); if ($node->getName() != "") { $title = word("Charts") . " :: " . $node->getName(); } $smarty->assign('title', $title); $smarty->display(SMARTY_ROOT . 'templates/slick/block-charts.tpl'); // Now lets finish out the cache $display->endCache(); }
/** * Draws the login page. * * @author Ben Dodson <*****@*****.**> * @version 11/3/04 * @since 5/13/04 */ function loginPage($failed = false) { $display =& new jzDisplay(); //$display->preHeader('Login',$this->width,$this->align); echo '<body onLoad="document.getElementById(\'loginform\').field1.focus();"></body>'; $urla = array(); $urla['jz_path'] = isset($_GET['jz_path']) ? $_GET['jz_path'] : ''; ?> <style> body { background-color: #F5F5D0; background: #F5F5D0; font-family: Verdana, Sans; font-size: 10px; color: #9c9b9b; margin: 0 0 0 0; } td { font-family: Verdana, Sans; font-size: 10px; } submit { border: 1px solid black; background: #EFEFCC; color: #000000; font-size: 11px; border-width: 1px; } input { font-family: Verdana, Sans; color: #000000; background-color: #EFEFCC; font-size: 11px; border-width: 1px; } </style> <script language="javascript" src="lib/md5.js"></script> <script language="javascript"> function submitLogin() { if (document.getElementById("loginform").doregister.value == 'true') { return true; } else { // submit the other form // so we can submit a non-cleartext PW without changing browser's stored PW. document.getElementById("loginSecureForm").field1.value = document.getElementById("loginform").field1.value; document.getElementById("loginSecureForm").field2.value = hex_md5(document.getElementById("loginform").field2.value); document.getElementById("loginSecureForm").remember.value = document.getElementById("loginform").remember.value; document.getElementById("loginSecureForm").submit(); return false; } } </script> <body style="background-color: #F5F5D0;"> <table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: #F5F5D0;"> <tr> <td align="center" height="100%" width="100%" style="background-color: #F5F5D0;"> <?php if ($failed) { echo "<center><strong><font color=white>Incorrect password</font></strong></center>"; } ?> <form name="loginSecureForm" id="loginSecureForm" method="POST" action="<?php echo urlize($urla); ?> "> <input type="hidden" name="field1" value=""> <input type="hidden" name="field2" value=""> <input type="hidden" name="remember" value=""> <input type="hidden" name="<?php echo jz_encode('action'); ?> " value="<?php echo jz_encode('login'); ?> "> </form> <form name="loginform" id="loginform" method="POST" action="<?php echo urlize($urla); ?> " onsubmit="return submitLogin()"> <input type="hidden" name="<?php echo jz_encode('action'); ?> " value="<?php echo jz_encode('login'); ?> "> <?php if (!$failed) { echo "<br><br><br>"; } ?> <?php echo word("Username"); ?> <br> <input size="18" type="text" class="jz_input" name="field1" style="width:146px;"> <br> <?php echo word("Password"); ?> <br> <input size="18" type="password" class="jz_input" name="field2" style="width:146px;"> <br> <input type="checkbox" class="jz_checkbox" name="remember"> <?php echo word("Remember me"); ?> <br><br> <input class="jz_submit" type="submit" name="<?php echo jz_encode('submit_login'); ?> " value="<?php echo word("Login"); ?> "> <input type="hidden" name="doregister" value="false" /> <?php $be = new jzBackend(); $data = $be->loadData('registration'); if ($data['allow_registration'] == "true") { ?> <input class="jz_submit" type="submit" name="<?php echo jz_encode('self_register'); ?> " value="<?php echo word("Register"); ?> " onclick="document.getElementById('loginform').doregister.value='true'"> <?php } ?> </form> <br /><br /> <img src="style/images/login-footer-logo.gif" border="0"> <br /><br /> </td> </tr> </table> </body> <?php //this->footer(); }
echo word("Album year"); ?> </nobr> </td> <td width="70%" valign="top"> <input type="text" name="edit_item_year" value="<?php echo $node->getYear(); ?> " class="jz_input" size="4"> </td> </tr> <?php } else { echo '<input type="hidden" name="edit_item_year" value="' . $node->getYear() . '" class="jz_input" size="4">'; } $be = new jzBackend(); if ($be->hasFeature('setID')) { ?> <tr class="<?php echo $row_colors[$i]; $i = 1 - $i; ?> "> <td width="30%" valign="top"> <nobr> <?php echo word("Item ID"); ?> </nobr>
/** * Displays the login/logout link. * * @author Ben Dodson * @version 1/17/05 * @since 1/17/05 * */ function loginLink($logintext = false, $logouttext = false, $registration = true, $regtext = false, $return_link = false) { global $jzUSER; $array = array(); if ($jzUSER->getID() == $jzUSER->lookupUID('NOBODY')) { $array['action'] = "login"; if ($logintext === false) { $text = word("Login"); } else { $text = $logintext; } } else { $array['action'] = "logout"; if ($logouttext === false) { $text = word("Logout"); } else { $text = $logouttext; } } $string = ""; $string .= '<a class="jz_header_table_href" href="' . urlize($array) . '">' . $text . '</a>'; if ($jzUSER->getID() == $jzUSER->lookupUID('NOBODY')) { $be = new jzBackend(); $data = $be->loadData('registration'); if ($data['allow_registration'] == "true") { if ($regtext === false) { $regtext = word("Register"); } $array['action'] = "register"; $string .= ' | '; $string .= '<a class="jz_header_table_href" href="' . urlize($array) . '">' . $regtext . '</a>'; } } if ($return_link) { return $string; } else { echo $string; } }
/** * 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; } }
$display->settingsTextbox("keyword_radio", "keyword_radio", $settings_array); $display->settingsTextbox("keyword_random", "keyword_random", $settings_array); $display->settingsTextbox("keyword_play", "keyword_play", $settings_array); $display->settingsTextbox("keyword_track", "keyword_track", $settings_array); $display->settingsTextbox("keyword_album", "keyword_album", $settings_array); $display->settingsTextbox("keyword_artist", "keyword_artist", $settings_array); $display->settingsTextbox("keyword_genre", "keyword_genre", $settings_array); $display->settingsTextbox("keyword_lyrics", "keyword_lyrics", $settings_array); $display->settingsTextbox("keyword_limit", "keyword_limit", $settings_array); $display->settingsTextbox("keyword_id", "keyword_id", $settings_array); break; case "extauth": $display->settingsCheckbox(word("Enable REMOTE_USER"), "http_auth_enable", $settings_array); $display->settingsTextbox(word("Anonymous REMOTE_USER"), "http_auth_anon_name", $settings_array); $display->settingsCheckbox(word("Auto-Create New Users"), "http_auth_auto_create", $settings_array); $be = new jzBackend(); $keys = array_keys($be->loadData('userclasses')); $display->settingsDropdown(word("New User Template:"), 'http_auth_newuser_template', $keys, $settings_array); break; default: $this->closeBlock(); return; } /* foreach ($settings_array as $key => $val) { // The settingsTextbox (and other) functions update the array for us // on a form submit. No other form handling is needed, // other than to write the data back to the file! // Plus, settings aren't modified if they aren't in the form. if ($key == "jinzora_skin") { $display->settingsDropdownDirectory($key,$key,$include_dir."style","dir",$settings_array);
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; }
die('Security breach detected.'); } /** * Displays the Add Podcast Subscribe tool * * @author Ross Carlson * @since 11/02/05 * @version 11/02/05 * @param $node The node that we are viewing **/ global $include_path, $podcast_folder; // Let's start the page header $this->displayPageTop("", word("Subscribe to Podcast")); $this->openBlock(); $display = new jzDisplay(); $be = new jzBackend(); // Did they want to update a podcast if (isset($_GET['feed_path'])) { if ($_GET['sub_action'] == "update") { $_POST['edit_podcast_add'] = "TRUE"; $_POST['edit_podcast_path'] = $_GET['feed_path']; $_POST['edit_podcast_title'] = $_GET['feed_title']; $_POST['edit_podcast_url'] = $_GET['feed_url']; $_POST['edit_podcast_max'] = $_GET['feed_number']; } } // Did the subscribe? if (isset($_POST['edit_podcast_add'])) { // Let's track this podcast $pData = $be->loadData("podcast"); $i = count($pData) + 1;
die('Security breach detected.'); } /** * Displays the site/location news block text to be edited * * @author Ross Carlson, Ben Dodson * @version 01/27/05 * @since 01/27/05 * @param $node The node we are looking at */ global $jzUSER, $node; if (!checkPermission($jzUSER, "admin", $node->getPath("String"))) { echo word("Insufficient permissions."); return; } $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']))); }
/** * Actually sends the data in the specified file. * * * @author Ben Dodson, PHP.net * @version 11/11/04 * @since 11/11/04 */ function streamFile($path, $name, $limit = false, $resample = "", $download = false, $contentTypeFor = false) { global $always_resample, $allow_resample, $always_resample_rate, $jzUSER; // Let's ignore if they abort, that way we'll know when the track stops... ignore_user_abort(TRUE); $jzSERVICES = new jzServices(); $jzSERVICES->loadStandardServices(); $status = false; if ($limit === false) { $speed_limit = 1 * 1024; } else { $speed_limit = $limit; } // limit is passed as a param because we may want to limit it for downloads // but not for streaming / image viewing. // Also, we may want to write a different function for resampling, // but I don't know yet. // IF NO SPEED LIMIT: // the 'speed_limit' from above is the amount // of buffer used while sending the file. // but with no speed limit, there is no 'sleep' issued. // this makes seeking in a file much faster. // Let's get the extension of the real file $extArr = explode(".", $path); $ext = $extArr[count($extArr) - 1]; if (!is_file($path) || connection_status() != 0) { return false; } $meta = $jzSERVICES->getTagData($path); $do_resample = false; if (!isNothing($resample)) { $do_resample = true; } if ($allow_resample == "true" && stristr($always_resample, $ext)) { $do_resample = true; } if ($meta['type'] == "mp3") { if (!isNothing($resample) && $resample >= $meta['bitrate']) { $do_resample = false; } } if ($download) { $do_resample = false; } // Are they resampling or transcoding? if ($do_resample) { // Ok, if resampling isn't set let's go with the default if ($resample == "") { $resample = $always_resample_rate; } // Now let's load up the resampling service $jzSERVICES = new jzServices(); $jzSERVICES->loadService("resample", "resample"); $jzSERVICES->resampleFile($path, $name, $resample); // Now let's unset what they are playing $be = new jzBackend(); $be->unsetPlaying($_GET['jz_user'], $_GET['sid']); return; } // Now we need to know if this is an ID3 image or not // First let's get their limit $limit = "7"; $size = filesize($path); $range = getContentRange($size); if ($range !== false) { $range_from = $range[0]; $range_to = $range[1]; } else { $range_from = 0; $range_to = $size - 1; } $ps3 = false; $allheaders = getallheaders(); if (isset($allheaders['User-Agent']) && $allheaders['User-Agent'] == "PLAYSTATION 3") { $ps3 = true; } if ($ps3) { // ps3 is picky and bizarre. if ($range_from > $size) { // This happens if the ps3 thinks the file // is larger than it is, and sending a // This is supposed to be a read of the id3v1 tag at // the end of a file (128 bytes), or the lyrics tag // (138 bytes) $requested = $range_to - $range_from + 1; $range_from = $size - $requested; $range_to = $size - 1; header("HTTP/1.1 206 Partial content"); } else { if ($range_from == 0 && $size == $range_to + 1) { header("HTTP/1.1 200 OK"); } else { header("HTTP/1.1 206 Partial content"); header("CONTENT-RANGE: bytes {$range_from}-{$range_to}/{$size}"); } } header("transferMode.dlna.org: Streaming"); header("contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=017000 00000000000000000000000000"); header("Accept-Ranges: bytes"); header("Connection: keep-alive"); header("Content-Length: " . ($size - $range_from)); } else { if ($range === false) { // Content length has already been sent header("Content-Length: " . (string) $size); } else { header("HTTP/1.1 206 Partial Content"); header("Accept-Range: bytes"); header("Content-Length: " . ($size - $range_from)); header("Content-Range: bytes {$range_from}" . "-" . $range_to . "/{$size}"); } } if ($contentTypeFor !== false) { sendContentType($contentTypeFor); } if (!$ps3) { header("Content-Disposition: inline; filename=\"" . $name . "\""); header("Expires: " . gmdate("D, d M Y H:i:s", mktime(date("H") + 2, date("i"), date("s"), date("m"), date("d"), date("Y"))) . " GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s", filemtime($path)) . " GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); } if ($file = fopen($path, 'rb')) { @set_time_limit(0); fseek($file, $range_from); while (!feof($file) and connection_status() == 0 and ($cur_pos = ftell($file)) < $range_to + 1) { print fread($file, min(1024 * $speed_limit, $range_to + 1 - $cur_pos)); flush(); if ($limit !== false) { sleep(1); } } $status = connection_status() == 0; fclose($file); @set_time_limit(30); } // Now let's unset what they are playing $be = new jzBackend(); $be->unsetPlaying($_GET['jz_user'], $_GET['sid']); return $status; }
$resample = false; } switch ($_GET['action']) { // play a track: case "play": if (!(isset($_GET['jz_path']) || isset($_GET['file']))) { exit; } // send file directly, not with path: if (isset($_GET['file'])) { if (preg_match("/\\.({$audio_types})\$/i", $_GET['fname'])) { sendMedia($_GET['file'], $_GET['fname'], $resample); } exit; } else { $be = new jzBackend(); $el =& new jzMediaTrack($_GET['jz_path'], "id"); if ($jzUSER->getSetting('force_clips')) { $_GET['cl'] = true; } if (isset($_GET['cl'])) { // Send a clip $meta = $el->getMeta(); $title = $meta['artist'] . " - " . $el->getName(); sendClip($el); exit; } // Is the track locked/do they have permission? if (!canPlay($el, $jzUSER)) { sendMedia("playlists/messages/media-locked.mp3", word("Track Locked")); exit;
/** * * 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 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; } }
echo $MENU_BUTTON; echo ' '; $this->closeButton(); } $this->closeBlock(); return; } } } } $this->closeBlock(); return; } // SELF-REGISTRATION: if ($_GET['subaction'] == "registration") { $be = new jzBackend(); $data = $be->loadData('registration'); if (!is_array($data)) { $data = array(); } $classes = $be->loadData('userclasses'); if (!is_array($classes)) { $urla = array(); $urla['action'] = "popup"; $urla['ptype'] = "usermanager"; $urla['subaction'] = "editclasses"; $urla['subsubaction'] = "add"; echo word("<p>You must set up a user template before enabling user registration.</p>"); echo '<p><a href="' . urlize($urla) . '">' . word("Click here to do add a user template.") . '</a></p>'; return; }
$retval = $be->install(); ?> </td> </tr> </table> <br> <div class="go"> <span class="goToNext"> <?php if ($retval > 0) { if (isset($_POST['default_cms_access'])) { $_POST['default_access'] = $_POST['default_cms_access']; } // install completed. Add our users to the table. // A default user class: $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);
/** * Shows the site news * * @author Ross Carlson * @version 01/26/05 * @since 01/26/05 * @param $node the Node we are viewing */ function siteNews($node) { // Let's setup our objects $be = new jzBackend(); if (!is_object($node)) { return; } if ($node->getName() == "") { $news = "site-news"; } else { $news = $node->getName() . "-news"; } $news = $be->loadData($news); if ($news == "") { return; } // Now let's display the news return $news; }
function SERVICE_IMPORTMEDIA_id3tags($node, $root_path = false, $flags = array()) { global $ext_graphic, $default_art, $audio_types, $video_types; $be = new jzBackend(); $root = new jzMediaNode(); if (isset($flags['recursive']) && $flags['recursive'] === false || $root_path === false) { /* if ($node === false) { $node = new jzMediaNode(); } $tracks = $node->getSubNodes("tracks"); foreach ($tracks as $track) { $fname = $track->getFileName("host"); $entry = $be->lookupFile($fname); if (!is_array($entry)) { echo "Error in SERVICE_IMPORTMEDIA_id3tags. File added but does not exist in registry."; return; } if ($entry['fs_sync'] && !file_exists($fname)) { $be->unregisterFile($fname); $root->removeMedia($track); } // TODO: CHECK THE ABOVE!!! CHECK UNREGISTERFILE! // TODO: check modified time and move file if needed. } */ return false; } $directory_list = array(); $directory_list[] = $root_path; if (isset($flags['showstatus']) && $flags['showstatus'] && !(is_string($flags['showstatus']) && $flags['showstatus'] == "cli")) { $_SESSION['jz_import_full_progress'] = 0; } while (sizeof($directory_list) > 0) { $cur_dir = array_shift($directory_list); if (isset($flags['showstatus']) && is_string($flags['showstatus']) && $flags['showstatus'] == "cli") { echo word("Scanning: %s", $cur_dir) . "\n"; } $bestImage = ""; $albums = array(); $track_paths = array(); $track_filenames = array(); $track_metas = array(); if (!($handle = opendir($cur_dir))) { continue; } //die("Could not access directory $dir"); while ($file = readdir($handle)) { if ($file == "." || $file == "..") { continue; } $fullpath = $cur_dir . "/" . $file; if (is_dir($fullpath)) { $directory_list[] = $fullpath; } else { if (preg_match("/\\.({$ext_graphic})\$/i", $file) && !stristr($file, ".thumb.")) { // An image if (@preg_match("/({$default_art})/i", $file)) { $bestImage = $fullpath; } else { if ($bestImage == "") { $bestImage = $fullpath; } } } else { if (preg_match("/\\.({$audio_types})\$/i", $file) || preg_match("/\\.({$video_types})\$/i", $file)) { $entry = $be->lookupFile($fullpath); if (isset($flags['showstatus']) && $flags['showstatus'] && !(is_string($flags['showstatus']) && $flags['showstatus'] == "cli")) { if ($_SESSION['jz_import_full_progress'] % 50 == 0 or $_SESSION['jz_import_full_progress'] == 0 or $_SESSION['jz_import_full_progress'] == 1) { showStatus(); } $_SESSION['jz_import_full_progress']++; } if (is_array($entry) && $entry['added'] < filemtime($fullpath)) { // moved file $track =& new jzMediaTrack($fullpath); $track->playpath = $fullpath; $meta = $track->getMeta("file"); $arr = array(); if (isset($meta['genre'])) { $arr['genre'] = $meta['genre']; } if (isset($meta['subgenre'])) { $arr['subgenre'] = $meta['subgenre']; } if (isset($meta['artist'])) { $arr['artist'] = $meta['artist']; } if (isset($meta['album'])) { $arr['album'] = $meta['album']; } if (isset($meta['disk'])) { $arr['disk'] = $meta['disk']; } if (isset($meta['filename'])) { $arr['track'] = $meta['filename']; } $old = new jzMediaTrack($entry['path']); $child = $root->moveMedia($old, $arr); if ($child !== false) { $album = $child->getAncestor("album"); if ($album !== false) { $albums[$album->getPath("String")] = true; } } } else { if ($entry === false || isset($flags['force']) && $flags['force'] === true) { // Set path so when getFileName is called and the filepath was not found, // we get the correct path. $track =& new jzMediaTrack($fullpath); $track->playpath = $fullpath; $meta = $track->getMeta("file"); $arr = array(); if (isset($meta['genre'])) { $arr['genre'] = $meta['genre']; } if (isset($meta['subgenre'])) { $arr['subgenre'] = $meta['subgenre']; } if (isset($meta['artist'])) { $arr['artist'] = $meta['artist']; } if (isset($meta['album'])) { $arr['album'] = $meta['album']; } if (isset($meta['disk'])) { $arr['disk'] = $meta['disk']; } if (isset($meta['filename'])) { $arr['track'] = $meta['filename']; } $track_paths[] = $arr; $track_filenames[] = $fullpath; $track_metas[] = $meta; } } } } } } // while reading dir $art_dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . "images" . DIRECTORY_SEPARATOR; if (sizeof($track_paths) > 0) { $results = $root->bulkInject($track_paths, $track_filenames, $track_metas); for ($i = 0; $i < sizeof($results); $i++) { if ($results[$i] !== false) { $album = $results[$i]->getAncestor("album"); if ($album !== false) { $albums[$album->getPath("String")] = true; $newalbum = new jzMediaNode($album->getPath("String")); // If we have album art in the tag, add it. if ($track_metas[$i]['pic_data'] != "") { $artloc = realpath($art_dir) . DIRECTORY_SEPARATOR . "art_" . $newalbum->getID() . ".jpg"; if ($artloc !== false) { $filehandle = fopen($artloc, "wb"); fwrite($filehandle, $track_metas[$i]['pic_data']); fclose($filehandle); $newalbum->addMainArt("data" . DIRECTORY_SEPARATOR . "images" . DIRECTORY_SEPARATOR . "art_" . $newalbum->getID() . ".jpg"); } } } } } } } if (isset($flags['showstatus']) && is_string($flags['showstatus']) && $flags['showstatus'] == "cli") { echo word("Scanning for removed media.") . "\n"; } $be->removeDeadFiles(); }
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)); }
* * - Contributors - * Please see http://www.jinzora.org/team.html * * - Code Purpose - * Builds a zero-configuration jukebox * * @since 2/9/05 * @author Ben Dodson <*****@*****.**> */ // Quickbox instance $POLL_TIME = 2; // blech $include_path = '../'; require_once '../jzBackend.php'; $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);