summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-12-03 05:53:50 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-12-03 05:53:50 +0000
commit28f7ad7026a864479feb92007315a22096c9e6d2 (patch)
treeff5a1b7de9fbfa35f22e00fb1f615aeb7734486f /lib
parent552c3cedd78263ce385d0ac47b02ccd22ea474b3 (diff)
downloadampache-28f7ad7026a864479feb92007315a22096c9e6d2.tar.gz
ampache-28f7ad7026a864479feb92007315a22096c9e6d2.tar.bz2
ampache-28f7ad7026a864479feb92007315a22096c9e6d2.zip
broke some stuff, fixed some stuff... commiting before I turn of this box
Diffstat (limited to 'lib')
-rw-r--r--lib/class/browse.class.php14
-rw-r--r--lib/class/registration.class.php2
-rw-r--r--lib/class/stream.class.php89
-rw-r--r--lib/preferences.php2
-rw-r--r--lib/stream.lib.php93
5 files changed, 101 insertions, 99 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
diff --git a/lib/preferences.php b/lib/preferences.php
index 89468242..c81a3360 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -110,7 +110,7 @@ function update_preferences($pref_id=0) {
/* Some preferences require some extra checks to be performed */
switch ($name) {
case 'sample_rate':
- $value = validate_bitrate($value);
+ $value = Stream::validate_bitrate($value);
break;
/* MD5 the LastFM & MyStrands so it's not plainTXT */
case 'lastfm_pass':
diff --git a/lib/stream.lib.php b/lib/stream.lib.php
index 5d6448c0..30721837 100644
--- a/lib/stream.lib.php
+++ b/lib/stream.lib.php
@@ -19,60 +19,6 @@
*/
-/**
- * gc_now_playing
- * this is a garbage collection function for now playing this is called every time something
- * is streamed
- * @package General
- * @catagory Now Playing
- */
-function gc_now_playing() {
-
- // Delete expired songs
- $sql = "DELETE FROM `now_playing` WHERE `expire` < '$time'";
- $db_result = Dba::query($sql);
-
- // 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";
- $db_results = Dba::query($sql);
-
-} // gc_now_playing
-
-/**
- * insert_now_playing
- * This function takes care of inserting the now playing data
- * we use this function because we need to do thing differently
- * depending upon which play is actually streaming
- */
-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
- */
-function clear_now_playing() {
-
- $sql = "TRUNCATE `now_playing`";
- $db_results = Dba::query($sql);
-
- return true;
-
-} // clear_now_playing
-
/**
* show_now_playing
* shows the now playing template
@@ -135,43 +81,4 @@ function check_lock_songs($song_id) {
} // check_lock_songs
-/**
- * validate_bitrate
- * this function takes a bitrate and returns a valid one
- * @package Stream
- * @catagory Downsample
- */
-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
-
?>