summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2009-03-15 16:16:04 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2009-03-15 16:16:04 +0000
commitfdb7c58cb160c5f8f0f0327c11cba93226e062f6 (patch)
tree6cf57a740799a3a9b9dc9a035ccb66e1e54b053f
parent86ff429b366080b9203e5ddb1740339c64013853 (diff)
downloadampache-fdb7c58cb160c5f8f0f0327c11cba93226e062f6.tar.gz
ampache-fdb7c58cb160c5f8f0f0327c11cba93226e062f6.tar.bz2
ampache-fdb7c58cb160c5f8f0f0327c11cba93226e062f6.zip
fix typo causing height to not display on art retrival, update to db allowing gc of tmp_browse, add extension to api album art image urls
-rwxr-xr-xdocs/CHANGELOG8
-rw-r--r--lib/class/album.class.php34
-rw-r--r--lib/class/core.class.php2
-rw-r--r--lib/class/query.class.php10
-rw-r--r--lib/class/stream.class.php55
-rw-r--r--lib/class/update.class.php30
-rw-r--r--lib/class/vauth.class.php4
-rw-r--r--lib/class/xmldata.class.php2
-rw-r--r--lib/init.php1
-rw-r--r--lib/stream.lib.php85
-rw-r--r--lib/ui.lib.php16
-rw-r--r--play/index.php5
-rw-r--r--search.php1
-rw-r--r--templates/show_localplay_status.inc.php2
-rw-r--r--templates/show_now_playing.inc.php6
-rw-r--r--templates/show_now_playing_row.inc.php20
16 files changed, 161 insertions, 120 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index 82d73401..91b90ef7 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,7 +4,13 @@
--------------------------------------------------------------------------
v.3.5-Alpha3
- - Added get lyrics and album art using http proxy server #313 + username, password patch
+ - Add extension to image urls for the API will add to others as
+ needed due to additional query requirement. Needed to fix
+ some DLNA devices
+ - Fixed typo that caused the height of album art not to display
+ - Modified database and added GC for tmp_browse table
+ - Added get lyrics and album art using http proxy server #313
+ + username, password patch
- Added lyricswiki link Ticket #70
- Updated README language
- Updated getid3 library 2.0.0b4 to 2.0.0b5
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index 438a9033..017e8147 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -959,6 +959,40 @@ class Album extends database_object {
} // get_image_from_source
+ /**
+ * get_art_url
+ * This returns the art URL for the album
+ */
+ public static function get_art_url($album_id,$sid=false) {
+
+ $sid = $sid ? scrub_out($sid) : session_id();
+
+ $sql = "SELECT `art_mime`,`thumb_mime` FROM `album_data` WHERE `album_id`='" . Dba::escape($album_id) . "'";
+ $db_results = Dba::read($sql);
+
+ $row = Dba::fetch_assoc($db_results);
+
+ $mime = $row['thumb_mime'] ? $row['thumb_mime'] : $row['art_mime'];
+
+ switch ($type) {
+ case 'image/gif':
+ $type = 'gif';
+ break;
+ case 'image/png':
+ $type = 'png';
+ break;
+ default:
+ case 'image/jpeg':
+ $type = 'jpg';
+ break;
+ } // end type translation
+
+ $name = 'art.' . $type;
+
+ Config::get('web_path') . '/image.php?id=' . scrub_out($album_id) . '&auth=' . $sid . '&name=' . $name;
+
+ } // get_art_url
+
} //end of album class
?>
diff --git a/lib/class/core.class.php b/lib/class/core.class.php
index c1d07e86..d93b542a 100644
--- a/lib/class/core.class.php
+++ b/lib/class/core.class.php
@@ -106,7 +106,7 @@ class Core {
if (!$width || !$height) { return false; }
- return array('width'=>$width,'heigh'=>$height);
+ return array('width'=>$width,'height'=>$height);
} // image_dimensions
diff --git a/lib/class/query.class.php b/lib/class/query.class.php
index b1155d1f..9b219f4b 100644
--- a/lib/class/query.class.php
+++ b/lib/class/query.class.php
@@ -521,9 +521,10 @@ class Query {
if (!self::is_simple()) {
// If not then we're going to need to read from the database :(
- $sid = session_id() . '::' . self::$type;
+ $sid = session_id();
+ $type = Dba::escape(self::$type);
- $sql = "SELECT `data` FROM `tmp_browse` WHERE `sid`='$sid'";
+ $sql = "SELECT `data` FROM `tmp_browse` WHERE `sid`='$sid' AND `type`='$type'";
$db_results = Dba::read($sql);
$row = Dba::fetch_assoc($db_results);
@@ -1195,10 +1196,11 @@ class Query {
// Only do this if it's a not a simple browse
if (!self::is_simple()) {
- $sid = session_id() . '::' . self::$type;
+ $sid = Dba::escape(session_id());
$data = Dba::escape(serialize($object_ids));
+ $type = Dba::escape(self::$type);
- $sql = "REPLACE INTO `tmp_browse` SET `data`='$data', `sid`='$sid'";
+ $sql = "REPLACE INTO `tmp_browse` SET `data`='$data', `sid`='$sid',`type`='$type'";
$db_results = Dba::write($sql);
self::$total_objects = count($object_ids);
diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php
index 5676490b..d4853780 100644
--- a/lib/class/stream.class.php
+++ b/lib/class/stream.class.php
@@ -722,14 +722,15 @@ class Stream {
* 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,$length,$sid,$type) {
+ public static function insert_now_playing($oid,$uid,$length,$sid,$type) {
$time = time()+$length;
$session_id = Dba::escape($sid);
+ $object_type = 'song';
// 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')";
+ $sql = "REPLACE INTO `now_playing` (`id`,`object_id`,`object_type`, `user`, `expire`)" .
+ " VALUES ('$session_id','$oid','$object_type', '$uid', '$time')";
$db_result = Dba::write($sql);
} // insert_now_playing
@@ -749,6 +750,54 @@ class Stream {
} // clear_now_playing
/**
+ * get_now_playing
+ * This returns the now playing information
+ */
+ public static function get_now_playing($filter=NULL) {
+
+ $sql = "SELECT `session_stream`.`agent`,`now_playing`.* " .
+ "FROM `now_playing` " .
+ "LEFT JOIN `session_stream` ON `session_stream`.`id`=`now_playing`.`id` " .
+ "ORDER BY `now_playing`.`expire` DESC";
+ $db_results = Dba::read($sql);
+
+ $results = array();
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $type = $row['object_type'];
+ $media = new $type($row['object_id']);
+ $media->format();
+ $client = new User($row['user']);
+ $results[] = array('media'=>$media,'client'=>$client,'agent'=>$row['agent'],'expire'=>$row['expire']);
+ } // end while
+
+ return $results;
+
+ } // get_now_playing
+
+ /**
+ * check_lock_media
+ * This checks to see if the media is already being played, if it is then it returns false
+ * else return true
+ */
+ public static function check_lock_media($media_id,$type) {
+
+ $media_id = Dba::escape($media_id);
+ $type = Dba::escape($type);
+
+ $sql = "SELECT `object_id` FROM `now_playing` WHERE `object_id`='$media_id' AND `object_type`='$type'";
+ $db_results = Dba::read($sql);
+
+ if (Dba::num_rows($db_results)) {
+ debug_event('Stream','Unable to play media currently locked by another user','3');
+ return false;
+ }
+
+ return true;
+
+ } // check_lock_media
+
+ /**
* auto_init
* This is called on class load it sets the session
*/
diff --git a/lib/class/update.class.php b/lib/class/update.class.php
index e850556d..938d979c 100644
--- a/lib/class/update.class.php
+++ b/lib/class/update.class.php
@@ -315,9 +315,13 @@ class Update {
$version[] = array('version'=>'350007','description'=>$update_string);
- $update_string = '- Modify Now Playing table to handle Videos';
+ $update_string = '- Modify Now Playing table to handle Videos<br />' .
+ '- Modify tmp_browse to make it easier to prune<br />' .
+ '- Add missing indexes to the _data tables<br />' .
+ '- Drop unused song.hash<br />' .
+ '- Add addition_time and update_time to video table<br />';
- //$version[] = array('version'=>'350008','description'=>$update_string);
+ $version[] = array('version'=>'350008','description'=>$update_string);
return $version;
@@ -365,7 +369,7 @@ class Update {
/* Nuke All Active session before we start the mojo */
$sql = "TRUNCATE session";
- $db_results = Dba::query($sql);
+ $db_results = Dba::write($sql);
// Prevent the script from timing out, which could be bad
set_time_limit(0);
@@ -1708,18 +1712,27 @@ class Update {
*/
public static function update_350008() {
- $sql = "ALTER TABLE `now_playing` ALTER `song_id` `object_id` INT( 11 ) UNSIGNED NOT NULL";
+ $sql = "ALTER TABLE `now_playing` CHANGE `song_id` `object_id` INT( 11 ) UNSIGNED NOT NULL";
$db_results = Dba::write($sql);
$sql = "ALTER TABLE `now_playing` ADD `object_type` VARCHAR ( 255 ) NOT NULL AFTER `object_id`";
$db_results = Dba::write($sql);
+ $sql = "ALTER TABLE `now_playing` ADD INDEX ( `expire` )";
+ $db_results = Dba::write($sql);
+
$sql = "ALTER TABLE `video` ADD `addition_time` INT( 11 ) UNSIGNED NOT NULL AFTER `mime`";
$db_results = Dba::write($sql);
$sql = "ALTER TABLE `video` ADD `update_time` INT( 11 ) UNSIGNED NULL AFTER `addition_time`";
$db_results = Dba::write($sql);
+ $sql = "ALTER TABLE `video` ADD INDEX (`addition_time`)";
+ $db_results = Dba::write($sql);
+
+ $sql = "ALTER TABLE `video` ADD INDEX (`update_time`)";
+ $db_results = Dba::write($sql);
+
$sql = "ALTER TABLE `artist_data` ADD INDEX ( `art_mime` )";
$db_results = Dba::write($sql);
@@ -1727,10 +1740,15 @@ class Update {
$db_results = Dba::write($sql);
$sql = "ALTER TABLE `tmp_browse` ADD `type` VARCHAR ( 255 ) NOT NULL AFTER `sid`";
- $db_results = Dba::wirte($sql);
+ $db_results = Dba::write($sql);
+ $sql = "ALTER TABLE `tmp_browse` ADD INDEX (`type)";
+ $db_results = Dba::write($sql);
+
+ $sql = "ALTER TABLE `song` DROP `hash`";
+ $db_results = Dba::write($sql);
- //self::set_version('db_version','350008');
+ self::set_version('db_version','350008');
} // update_350008
diff --git a/lib/class/vauth.class.php b/lib/class/vauth.class.php
index 28c9d915..f9e614f9 100644
--- a/lib/class/vauth.class.php
+++ b/lib/class/vauth.class.php
@@ -137,6 +137,10 @@ class vauth {
$sql = "DELETE FROM `session` WHERE `expire` < '" . time() . "'";
$db_results = Dba::write($sql);
+ $sql = "DELETE FROM `tmp_browse` USING `tmp_browse` LEFT JOIN `session` ON `session`.`id`=`tmp_browse`.`sid` " .
+ "WHERE `session`.`id` IS NULL";
+ $db_results = Dba::write($sql);
+
return true;
} // gc
diff --git a/lib/class/xmldata.class.php b/lib/class/xmldata.class.php
index cfb8805f..c25a5560 100644
--- a/lib/class/xmldata.class.php
+++ b/lib/class/xmldata.class.php
@@ -319,7 +319,7 @@ class xmlData {
$rating = new Rating($song_id,'song');
- $art_url = Config::get('web_path') . '/image.php?id=' . $song->album . '&auth=' . scrub_out($_REQUEST['auth']);
+ $art_url = Album::get_art_url($song->album,$_REQUEST['auth']);
$string .= "<song id=\"$song->id\">\n" .
"\t<title><![CDATA[$song->title]]></title>\n" .
diff --git a/lib/init.php b/lib/init.php
index f6ffc311..26cc6fc0 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -130,7 +130,6 @@ require_once $prefix . '/lib/ui.lib.php';
require_once $prefix . '/lib/gettext.php';
require_once $prefix . '/lib/batch.lib.php';
require_once $prefix . '/lib/themes.php';
-require_once $prefix . '/lib/stream.lib.php';
require_once $prefix . '/lib/xmlrpc.php';
require_once $prefix . '/lib/class/localplay.abstract.php';
require_once $prefix . '/lib/class/database_object.abstract.php';
diff --git a/lib/stream.lib.php b/lib/stream.lib.php
deleted file mode 100644
index 8cc92d50..00000000
--- a/lib/stream.lib.php
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-/*
-
- Copyright Ampache.org
- All Rights Reserved
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-
-/**
- * show_now_playing
- * shows the now playing template
- */
-function show_now_playing() {
-
- // GC!
- Stream::gc_session();
- Stream::gc_now_playing();
-
- $web_path = Config::get('web_path');
- $results = get_now_playing();
- require Config::get('prefix') . '/templates/show_now_playing.inc.php';
-
-} // show_now_playing
-
-/**
- * get_now_playing
- * gets the now playing information
- */
-function get_now_playing($filter='') {
-
- $sql = "SELECT `session_stream`.`agent`,`now_playing`.`song_id`,`now_playing`.`user`,`now_playing`.`expire` " .
- "FROM `now_playing` " .
- "LEFT JOIN `session_stream` ON `session_stream`.`id`=`now_playing`.`id` " .
- "ORDER BY `now_playing`.`expire` DESC";
- $db_results = Dba::query($sql);
-
- $results = array();
-
- /* While we've got stuff playing */
- while ($r = Dba::fetch_assoc($db_results)) {
- $song = new Song($r['song_id']);
- $song->format();
- $np_user = new User($r['user']);
- $results[] = array('song'=>$song,'user'=>$np_user,'agent'=>$r['agent'],'expire'=>$r['expire']);
- } // end while
-
- return $results;
-
-} // get_now_playing
-
-
-/**
- * check_lock_songs
- * This checks to see if the song is already playing, if it is then it prevents the user
- * from streaming it
- */
-function check_lock_songs($song_id) {
-
- $sql = "SELECT `song_id` FROM `now_playing` " .
- "WHERE `song_id` = '$song_id'";
- $db_results = Dba::query($sql);
-
- if (Dba::num_rows($db_results)) {
- debug_event('lock_songs','Song Already Playing, skipping...','5');
- return false;
- }
-
- return true;
-
-} // check_lock_songs
-
-?>
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index 93e8aeed..5a451a74 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -844,5 +844,21 @@ function toggle_visible($element) {
} // toggle_visible
+/**
+ * show_now_playing
+ * This shows the now playing templates and does some garbage colleciont
+ * this should really be somewhere else
+ */
+function show_now_playing() {
+
+ Stream::gc_session();
+ Stream::gc_now_playing();
+
+ $web_path = Config::get('web_path');
+ $results = Stream::get_now_playing();
+ require_once Config::get('prefix') . '/templates/show_now_playing.inc.php';
+
+} // show_now_playing
+
?>
diff --git a/play/index.php b/play/index.php
index d3a3579b..d3596699 100644
--- a/play/index.php
+++ b/play/index.php
@@ -175,9 +175,8 @@ if (!make_bool($media->enabled)) {
// If we are running in Legalize mode, don't play songs already playing
if (Config::get('lock_songs')) {
- if (!check_lock_songs($media->id)) {
- debug_event('Play','Song ' . $media->id . ' is currently being played and lock songs is enabled','1');
- exit();
+ if (!Stream::check_lock_media($media->id,get_class($media))) {
+ exit;
}
}
diff --git a/search.php b/search.php
index ae2fa297..9857f8c9 100644
--- a/search.php
+++ b/search.php
@@ -45,7 +45,6 @@ switch ($_REQUEST['action']) {
$results = run_search($_REQUEST);
Browse::set_type('song');
Browse::reset();
- Browse::save_objects($results);
Browse::show_objects($results);
break;
case 'save_as_track':
diff --git a/templates/show_localplay_status.inc.php b/templates/show_localplay_status.inc.php
index 3fb554be..567149cf 100644
--- a/templates/show_localplay_status.inc.php
+++ b/templates/show_localplay_status.inc.php
@@ -23,7 +23,7 @@ $status = $localplay->status();
$now_playing = $status['track_title'] ? $status['track_title'] . ' - ' . $status['track_album'] . ' - ' . $status['track_artist'] : '';
?>
<?php Ajax::start_container('localplay_status'); ?>
-<?php show_box_top(_('Localplay Control')); ?>
+<?php show_box_top(_('Localplay Control') . ' - '. strtoupper($localplay->type)); ?>
<?php echo _('Now Playing'); ?>:<i><?php echo $now_playing; ?></i>
<div id="information_actions">
<ul>
diff --git a/templates/show_now_playing.inc.php b/templates/show_now_playing.inc.php
index 9f043cc1..b5fa60e8 100644
--- a/templates/show_now_playing.inc.php
+++ b/templates/show_now_playing.inc.php
@@ -33,12 +33,12 @@ $link = Config::get('use_rss') ? ' ' . AmpacheRSS::get_display('nowplaying') : '
<?php show_box_top(_('Now Playing') . $link); ?>
<?php
foreach ($results as $item) {
- $song = $item['song'];
- $np_user = $item['user'];
+ $media = $item['media'];
+ $np_user = $item['client'];
$agent = $item['agent'];
/* If we've gotten a non-song object just skip this row */
- if (!is_object($song)) { continue; }
+ if (!is_object($media)) { continue; }
if (!$np_user->fullname) { $np_user->fullname = "Ampache User"; }
?>
<div class="np_row">
diff --git a/templates/show_now_playing_row.inc.php b/templates/show_now_playing_row.inc.php
index a9e98e9e..1bdc164f 100644
--- a/templates/show_now_playing_row.inc.php
+++ b/templates/show_now_playing_row.inc.php
@@ -20,9 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Prepare the variables */
-$title = scrub_out(truncate_with_ellipsis($song->title));
-$album = scrub_out(truncate_with_ellipsis($song->f_album_full));
-$artist = scrub_out(truncate_with_ellipsis($song->f_artist_full));
+$title = scrub_out(truncate_with_ellipsis($media->title));
+$album = scrub_out(truncate_with_ellipsis($media->f_album_full));
+$artist = scrub_out(truncate_with_ellipsis($media->f_artist_full));
?>
<div class="np_group">
<div class="np_cell cel_username">
@@ -34,8 +34,8 @@ $artist = scrub_out(truncate_with_ellipsis($song->f_artist_full));
<div class="np_cell cel_rating">
<label><?php echo _('Rating'); ?></label>
- <div id="rating_<?php echo $song->id; ?>_song">
- <?php Rating::show($song->id,'song'); ?>
+ <div id="rating_<?php echo $media->id; ?>_song">
+ <?php Rating::show($media->id,'song'); ?>
</div>
</div>
</div>
@@ -43,21 +43,21 @@ $artist = scrub_out(truncate_with_ellipsis($song->f_artist_full));
<div class="np_group">
<div class="np_cell cel_song">
<label><?php echo _('Song'); ?></label>
- <a title="<?php echo scrub_out($song->title); ?>" href="<?php echo $web_path; ?>/stream.php?action=single_song&amp;song_id=<?php echo $song->id; ?>">
+ <a title="<?php echo scrub_out($media->title); ?>" href="<?php echo $web_path; ?>/stream.php?action=single_song&amp;song_id=<?php echo $song->id; ?>">
<?php echo $title; ?>
</a>
</div>
<div class="np_cell cel_album">
<label><?php echo _('Album'); ?></label>
- <a title="<?php echo scrub_out($song->f_album_full); ?>" href="<?php echo $web_path; ?>/albums.php?action=show&amp;album=<?php echo $song->album; ?>">
+ <a title="<?php echo scrub_out($media->f_album_full); ?>" href="<?php echo $web_path; ?>/albums.php?action=show&amp;album=<?php echo $song->album; ?>">
<?php echo $album; ?>
</a>
</div>
<div class="np_cell cel_artist">
<label><?php echo _('Artist'); ?></label>
- <a title="<?php echo scrub_out($song->f_artist_full); ?>" href="<?php echo $web_path; ?>/artists.php?action=show&amp;artist=<?php echo $song->artist; ?>">
+ <a title="<?php echo scrub_out($media->f_artist_full); ?>" href="<?php echo $web_path; ?>/artists.php?action=show&amp;artist=<?php echo $song->artist; ?>">
<?php echo $artist; ?>
</a>
</div>
@@ -66,8 +66,8 @@ $artist = scrub_out(truncate_with_ellipsis($song->f_artist_full));
<?php if (Config::get('show_album_art')) { ?>
<div class="np_group">
<div class="np_cell cel_albumart">
- <a target="_blank" href="<?php echo $web_path; ?>/image.php?id=<?php echo $song->album; ?>&amp;type=popup&amp;sid=<?php echo session_id(); ?>" onclick="popup_art('<?php echo $web_path; ?>/image.php?id=<?php echo $song->album; ?>&amp;type=popup&amp;sid=<?php echo session_id(); ?>'); return false;">
- <img align="middle" src="<?php echo $web_path; ?>/image.php?id=<?php echo $song->album; ?>&amp;thumb=1&amp;sid=<?php echo session_id(); ?>" alt="<?php echo scrub_out($song->f_album_full); ?>" title="<?php echo scrub_out($song->f_album_full); ?>" height="75" width="75" />
+ <a target="_blank" href="<?php echo $web_path; ?>/image.php?id=<?php echo $media->album; ?>&amp;type=popup&amp;sid=<?php echo session_id(); ?>" onclick="popup_art('<?php echo $web_path; ?>/image.php?id=<?php echo $song->album; ?>&amp;type=popup&amp;sid=<?php echo session_id(); ?>'); return false;">
+ <img align="middle" src="<?php echo $web_path; ?>/image.php?id=<?php echo $media->album; ?>&amp;thumb=1&amp;sid=<?php echo session_id(); ?>" alt="<?php echo scrub_out($song->f_album_full); ?>" title="<?php echo scrub_out($song->f_album_full); ?>" height="75" width="75" />
</a>
</div>
</div>