summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--admin/catalog.php17
-rwxr-xr-xdocs/CHANGELOG1
-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
-rw-r--r--play/index.php4
-rw-r--r--templates/show_playlist.inc.php6
9 files changed, 114 insertions, 114 deletions
diff --git a/admin/catalog.php b/admin/catalog.php
index f7c599d5..9473b03e 100644
--- a/admin/catalog.php
+++ b/admin/catalog.php
@@ -72,26 +72,23 @@ switch ($_REQUEST['action']) {
break;
case 'full_service':
ob_end_flush();
- $catalog = new Catalog();
/* Make sure they aren't in demo mode */
- if (Config::get('demo_mode')) { break; }
+ if (Config::get('demo_mode')) { access_denied(); break; }
if (!$_REQUEST['catalogs']) {
- $_REQUEST['catalogs'] = $catalog->get_catalog_ids();
+ $_REQUEST['catalogs'] = Catalog::get_catalog_ids();
}
/* This runs the clean/verify/add in that order */
foreach ($_REQUEST['catalogs'] as $catalog_id) {
- echo "<div class=\"confirmation-box\">";
$catalog = new Catalog($catalog_id);
$catalog->clean_catalog();
$catalog->count = 0;
$catalog->verify_catalog();
$catalog->count = 0;
$catalog->add_to_catalog();
- echo "</div>";
}
- $url = conf('web_path') . '/admin/index.php';
+ $url = Config::get('web_path') . '/admin/index.php';
$title = _('Catalog Updated');
$body = '';
show_confirmation($title,$body,$url);
@@ -201,7 +198,7 @@ switch ($_REQUEST['action']) {
}
break;
case 'clear_stats':
- if (Config::get('demo_mode')) { break; }
+ if (Config::get('demo_mode')) { access_denied(); break; }
Catalog::clear_stats();
$url = Config::get('web_path') . '/admin/index.php';
@@ -218,8 +215,8 @@ switch ($_REQUEST['action']) {
require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
break;
case 'clear_now_playing':
- if (Config::get('demo_mode')) { break; }
- clear_now_playing();
+ if (Config::get('demo_mode')) { access_denied(); break; }
+ Stream::clear_now_playing();
show_confirmation(_('Now Playing Cleared'),_('All now playing data has been cleared'),Config::get('web_path') . '/admin/index.php');
break;
case 'show_disabled':
@@ -235,7 +232,7 @@ switch ($_REQUEST['action']) {
break;
case 'show_delete_catalog':
/* Stop the demo hippies */
- if (Config::get('demo_mode')) { break; }
+ if (Config::get('demo_mode')) { access_denied(); break; }
$catalog = new Catalog($_REQUEST['catalog_id']);
$nexturl = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&amp;catalog_id=' . scrub_out($_REQUEST['catalog_id']);
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index 181e629d..a68ebda1 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,7 @@
--------------------------------------------------------------------------
v.3.4-Alpha4
+ - Fixed error on catalog Update All
- Fixed Public registration page, and simplified logic
- Added 'Add' button to recently played
- Limited Rightbar to only 100 items, adds last row indicating any
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
-
?>
diff --git a/play/index.php b/play/index.php
index f97c1e07..2d9c2935 100644
--- a/play/index.php
+++ b/play/index.php
@@ -146,7 +146,7 @@ if (!$song->file OR ( !is_readable($song->file) AND $catalog->catalog_type != 'r
/* Run Garbage Collection on Now Playing */
-gc_now_playing();
+Stream::gc_now_playing();
// If we are running in Legalize mode, don't play songs already playing
if (Config::get('lock_songs')) {
@@ -257,7 +257,7 @@ else {
} // else not downsampling
// Put this song in the now_playing table
-insert_now_playing($song->id,$uid,$song->time,$sid);
+Stream::insert_now_playing($song->id,$uid,$song->time,$sid);
if ($start) {
debug_event('seek','Content-Range header recieved, skipping ahead ' . $start . ' bytes out of ' . $song->size,'5');
diff --git a/templates/show_playlist.inc.php b/templates/show_playlist.inc.php
index 8637a3e6..a1855c79 100644
--- a/templates/show_playlist.inc.php
+++ b/templates/show_playlist.inc.php
@@ -33,11 +33,11 @@ $web_path = Config::get('web_path');
</ul>
</div>
<?php show_box_bottom(); ?>
-<?php show_box_top(); ?>
<div id="browse_content">
<?php
$object_ids = $playlist->get_items();
- require_once Config::get('prefix') . '/templates/show_playlist_songs.inc.php';
+ Browse::set_type('playlist_song');
+ Browse::save_objects($object_ids);
+ Browse::show_objects($object_ids);
?>
</div>
-<?php show_box_bottom(); ?>