summaryrefslogtreecommitdiffstats
path: root/lib/class
diff options
context:
space:
mode:
Diffstat (limited to 'lib/class')
-rw-r--r--lib/class/browse.class.php14
-rw-r--r--lib/class/registration.class.php2
-rw-r--r--lib/class/stream.class.php89
3 files changed, 100 insertions, 5 deletions
diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php
index 020f486b..2fb346f5 100644
--- a/lib/class/browse.class.php
+++ b/lib/class/browse.class.php
@@ -117,6 +117,7 @@ class Browse {
switch($type) {
case 'user':
case 'playlist':
+ case 'playlist_song':
case 'song':
case 'catalog':
case 'album':
@@ -142,6 +143,7 @@ class Browse {
switch ($_SESSION['browse']['type']) {
+ case 'playlist_song':
case 'song':
$valid_array = array('title','year','track','time');
break;
@@ -280,6 +282,7 @@ class Browse {
case 'playlist':
$sql = "SELECT `playlist`.`id` FROM `playlist` ";
break;
+ case 'playlist_song':
case 'song':
default:
$sql = "SELECT `song`.`id` FROM `song` ";
@@ -534,7 +537,7 @@ class Browse {
if (count($object_ids) > self::$start) {
$object_ids = array_slice($object_ids,self::$start,$limit);
}
-
+print_r($object_ids);
// Format any matches we have so we can show them to the masses
$match = $_SESSION['browse']['filter']['alpha_match'] ? ' (' . $_SESSION['browse']['filter']['alpha_match'] . ')' : '';
@@ -568,7 +571,7 @@ class Browse {
show_box_bottom();
break;
case 'live_stream':
- show_box_top(_('Radion Stations') . $match, $class);
+ show_box_top(_('Radio Stations') . $match, $class);
require_once Config::get('prefix') . '/templates/show_live_streams.inc.php';
show_box_bottom();
break;
@@ -577,6 +580,13 @@ class Browse {
require_once Config::get('prefix') . '/templates/show_playlists.inc.php';
show_box_bottom();
break;
+ case 'playlist_song':
+ // We need a playlist for this one man this is a hack, should figure out a better way
+ $playlist = $GLOBALS['playlist'];
+ show_box_top(_('Playlist Songs') . $match,$class);
+ require_once Config::get('prefix') . '/templates/show_playlist_songs.inc.php';
+ show_box_bottom();
+ break;
case 'catalog':
show_box_top(_('Catalogs'), $class);
require_once Config::get('prefix') . '/templates/show_catalogs.inc.php';
diff --git a/lib/class/registration.class.php b/lib/class/registration.class.php
index 7b964b7f..7b3f344c 100644
--- a/lib/class/registration.class.php
+++ b/lib/class/registration.class.php
@@ -59,7 +59,7 @@ class Registration {
// Check to see if the admin should be notified
if (Config::get('admin_notify_reg')) {
$body = "A new user has registered\n\n" .
- "The following values were entered.\n\n"
+ "The following values were entered.\n\n" .
"Username:$username\nFullname:$fullname\nE-mail:$mail\n\n";
mail(Config::get('mail_from'),$subject,$body,$headers);
}
diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php
index ab274bf3..3b5d24cb 100644
--- a/lib/class/stream.class.php
+++ b/lib/class/stream.class.php
@@ -577,11 +577,11 @@ class Stream {
}
/* Validate the bitrate */
- $sample_rate = validate_bitrate($sample_rate);
+ $sample_rate = self::validate_bitrate($sample_rate);
/* Never Upsample a song */
if (($sample_rate*1000) > $song->bitrate) {
- $sample_rate = validate_bitrate($song->bitrate)/1000;
+ $sample_rate = self::validate_bitrate($song->bitrate)/1000;
$sample_ratio = '1';
}
else {
@@ -623,6 +623,91 @@ class Stream {
} // start_downsample
+ /**
+ * validate_bitrate
+ * this function takes a bitrate and returns a valid one
+ */
+ public static function validate_bitrate($bitrate) {
+
+ // Setup an array of valid bitrates for Lame (yea yea, others might be different :P)
+ $valid_rate = array('32','40','56','64','80','96','112','128','160','192','224','256','320');
+
+ /* Round to standard bitrates */
+ $sample_rate = 8*(floor($bitrate/8));
+
+ if (in_array($sample_rate,$valid_rate)) {
+ return $sample_rate;
+ }
+
+ /* See if it's less than the lowest one */
+ if ($sample_rate < $valid_rate['0']) {
+ return $valid_rate['0'];
+ }
+
+ /* Check to see if it's over 320 */
+ if ($sample_rate > 320) {
+ return '320';
+ }
+
+ foreach ($valid_rate as $key=>$rate) {
+ $next_key = $key+1;
+
+ if ($sample_rate > $rate AND $sample_rate < $valid_rate[$next_key]) {
+ return $rate;
+ }
+ } // end foreach
+
+ } // validate_bitrate
+
+
+ /**
+ * gc_now_playing
+ * This will garbage collect the now playing data,
+ * this is done on every play start
+ */
+ public static function gc_now_playing() {
+
+ // Remove any now playing entries for session_streams that have been GC'd
+ $sql = "DELETE FROM `now_playing` USING `now_playing` " .
+ "LEFT JOIN `session_stream` ON `session_stream`.`id`=`now_playing`.`id` " .
+ "WHERE `session_stream`.`id` IS NULL OR `now_playing`.`expire` < '" . time() . "'";
+ $db_results = Dba::query($sql);
+
+ } // gc_now_playing
+
+ /**
+ * insert_now_playing
+ * This will insert the now playing data
+ * This fucntion is used by the /play/index.php song
+ * primarily, but could be used by other people
+ */
+ public static function insert_now_playing($song_id,$uid,$song_length,$sid) {
+
+ $time = time()+$song_length;
+ $session_id = Dba::escape($sid);
+
+ // Do a replace into ensuring that this client always only has a single row
+ $sql = "REPLACE INTO `now_playing` (`id`,`song_id`, `user`, `expire`)" .
+ " VALUES ('$session_id','$song_id', '$uid', '$time')";
+ $db_result = Dba::query($sql);
+
+ } // insert_now_playing
+
+ /**
+ * clear_now_playing
+ * There really isn't anywhere else for this function, shouldn't have deleted it in the first
+ * place
+ */
+ public static function clear_now_playing() {
+
+ $sql = "TRUNCATE `now_playing`";
+ $db_results = Dba::query($sql);
+
+ return true;
+
+ } // clear_now_playing
+
+
/**
* auto_init
* This is called on class load it sets the session