summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-05-26 08:28:09 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-05-26 08:28:09 +0000
commit97bcd214044e30b5078052ee0c523b63966d6833 (patch)
tree3710825f857adcb0d1926c9063bbc11adb678dc4
parent13ae6a0371ae26023880a0ad69b3b1587db8dd76 (diff)
downloadampache-97bcd214044e30b5078052ee0c523b63966d6833.tar.gz
ampache-97bcd214044e30b5078052ee0c523b63966d6833.tar.bz2
ampache-97bcd214044e30b5078052ee0c523b63966d6833.zip
added direct links back in, added batch download to single artist view, removed useless cruft
-rw-r--r--config/ampache.cfg.php.dist6
-rwxr-xr-xdocs/CHANGELOG8
-rw-r--r--lib/class/access.class.php3
-rw-r--r--lib/class/api.class.php14
-rw-r--r--lib/class/database_object.abstract.php6
-rw-r--r--lib/class/metadata.class.php149
-rw-r--r--lib/class/rating.class.php13
-rw-r--r--lib/class/stream.class.php17
-rw-r--r--lib/class/vauth.class.php2
-rw-r--r--lib/class/xmlrpcserver.class.php5
-rw-r--r--lib/init.php1
-rw-r--r--lib/preferences.php2
-rw-r--r--modules/infotools/openstrands.class.php725
-rw-r--r--modules/plugins/OpenStrands.plugin.php66
-rw-r--r--server/stats.ajax.php80
-rw-r--r--server/xml.server.php2
-rw-r--r--templates/show_artist.inc.php22
-rw-r--r--templates/show_song_row.inc.php5
18 files changed, 68 insertions, 1058 deletions
diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist
index 73b33121..61730ea6 100644
--- a/config/ampache.cfg.php.dist
+++ b/config/ampache.cfg.php.dist
@@ -264,12 +264,6 @@ album_art_order = "db,id3,folder,lastfm,amazon"
; DEFAULT: true
show_album_art = "true"
-; MyStrands Developer ID
-; This is needed for any of the OpenStrands functionality to work correctly
-; this is the developer ID you obtained from http://www.mystrands.com/openstrands/overview.vm
-; DEFAULT: false
-;mystrands_developer_key = ""
-
; Amazon Developer Key
; This is needed in order to actually use the amazon album art
; DEFAULT: false
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index 3f3b7082..ce7e772e 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,14 @@
--------------------------------------------------------------------------
v.3.5-Alpha1
+ - Added Batch Download to single Artist view
+ - Added back in the direct links on songs, requires download set
+ to enabled as it's essentially the same thing except with
+ now playing information tied to it
+ - Bumped API Version to 350001 and require that a version is sent
+ with handshake to indicate the application will work
+ - Removed the MyStrands plugin as did not provide good data, and does
+ not appear to have been used
- Added Catalog Prefix config option used to determine which prefixes
should not be used for sorting
- Merged Browse Menu with Home
diff --git a/lib/class/access.class.php b/lib/class/access.class.php
index 64719141..113735ae 100644
--- a/lib/class/access.class.php
+++ b/lib/class/access.class.php
@@ -140,6 +140,9 @@ class Access {
public static function check_function($type) {
switch ($type) {
+ case 'download':
+ return Config::get('download');
+ break ;
case 'batch_download':
if (!function_exists('gzcompress')) {
debug_event('gzcompress','ZLIB Extensions not loaded, batch download disabled','3');
diff --git a/lib/class/api.class.php b/lib/class/api.class.php
index 5ff54906..09cb9997 100644
--- a/lib/class/api.class.php
+++ b/lib/class/api.class.php
@@ -26,7 +26,7 @@
*/
class Api {
- public static $version = '340001';
+ public static $version = '350001';
/**
* constructor
@@ -45,7 +45,12 @@ class Api {
* can take a username, if non is passed the ACL must be non-use
* specific
*/
- public static function handshake($timestamp,$passphrase,$ip,$username='') {
+ public static function handshake($timestamp,$passphrase,$ip,$username='',$version) {
+
+ if (intval($version) < self::$version) {
+ debug_event('API','Login Failed version too old','1');
+ return false;
+ }
// If the timestamp is over 2hr old sucks to be them
if ($timestamp < (time() - 14400)) {
@@ -88,9 +93,7 @@ class Api {
$token = vauth::session_create($data);
// Insert the token into the streamer
- $stream = new Stream();
- $stream->user_id = $client->id;
- $stream->insert_session($token);
+ Stream::insert_session($token,$client->id);
debug_event('API','Login Success, passphrase matched','1');
// We need to also get the 'last update' of the catalog information in an RFC 2822 Format
@@ -122,6 +125,7 @@ class Api {
} // end while
debug_event('API','Login Failed, unable to match passphrase','1');
+ return false;
} // handhsake
diff --git a/lib/class/database_object.abstract.php b/lib/class/database_object.abstract.php
index 5aaf6cac..871232ea 100644
--- a/lib/class/database_object.abstract.php
+++ b/lib/class/database_object.abstract.php
@@ -36,10 +36,10 @@ abstract class database_object {
* this checks the cache to see if the specified object is there
*/
public static function is_cached($index,$id) {
+
+ $is_cached = isset(self::$object_cache[$index][$id]);
- $is_array = isset(self::$object_cache[$index][$id]);
-
- return $is_array;
+ return $is_cached;
} // is_cached
diff --git a/lib/class/metadata.class.php b/lib/class/metadata.class.php
deleted file mode 100644
index ca7da903..00000000
--- a/lib/class/metadata.class.php
+++ /dev/null
@@ -1,149 +0,0 @@
-<?php
-/*
-
- Copyright 2001 - 2007 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
- as published by the Free Software Foundation; version 2
- of the License.
-
- 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.
-
-*/
-
-/**
- * metadata class
- * This class is a abstraction layer for getting
- * meta data for any object in Ampache, this includes
- * album art, lyrics, id3tags, recommendations etc
- * it makes use of Object::construct_from_array() as needed
- */
-class metadata {
-
- /**
- * constructor
- * We don't use this, as its really a static class
- */
- private function __construct() {
-
- // Rien a faire
-
- } // constructor
-
- /**
- * recommend_similar
- * This takes the input and returns an array of objects construct_from_array()'d
- */
- public static function recommend_similar($type,$id,$limit='') {
-
- // For now it's only mystrands
- OpenStrands::set_auth_token(Config::get('mystrands_developer_key'));
- $openstrands = new OpenStrands(Config::get('mystrands_user'),Config::get('mystrands_pass'));
-
- // Make sure auth worked
- if (!$openstrands) { return false; }
-
- switch ($type) {
- case 'artist':
- $artist = new Artist($id);
- $seed = array('name'=>array($artist->name));
- $results = $openstrands->recommend_artists($seed,$limit);
- break;
- }
-
- $objects = array();
-
- foreach ($results as $item) {
- switch ($type) {
- case 'artist':
- $data['name'] = $item['ArtistName'];
- $data['uid'] = $item['__attributes']['ArtistID'];
- $data['mystrands_url'] = $item['URI'];
- $data['links'] = "<a target=\"_blank\" href=\"" . $item['URI'] . "\">" . get_user_icon('world_link','MyStrands Link') . "</a>";
-
- // Do a search for this artist in our instance
- $artist_id = Catalog::check_artist($data['name'],1);
- if ($artist_id) {
- $artist = new Artist($artist_id);
- $artist->format();
- $data['links'] .= "<a href=\"$artist->f_link\">" . get_user_icon('ampache','Ampache') . "</a>";
- }
-
- $objects[] = Artist::construct_from_array($data);
- break;
- } // end switch on type
- } // end foreach
-
- return $objects;
-
- } // recommend_similar
-
- /**
- * find_missing_tracks
- * This returns an array of song objects using the construct_from_array() that are
- * not in the specified album.
- */
- public static function find_missing_tracks($album_id) {
-
- // Build our object
- $album = new Album($album_id);
- $album->format();
- $objects = array();
-
- // For now it's only mystrands
- OpenStrands::set_auth_token(Config::get('mystrands_developer_key'));
- $openstrands = new OpenStrands(Config::get('mystrands_user'),Config::get('mystrands_pass'));
-
- if (!$openstrands) { return false; }
-
- // Setup the string we're going to pass
- if ($album->artist_count == '1') { $artist_name = $album->artist_name; }
- else { $artist_name = "Various"; }
-
- $data[] = array('artist'=>$artist_name,'album'=>$album->full_name);
-
- // First find the album on mystrands
- $result = $openstrands->match_albums($data);
-
- if (!$result) { return false; }
-
- $mystrands_id = $result['0']['__attributes']['AlbumId'];
-
- if (!$mystrands_id) { return false; }
-
- $tracks = $openstrands->lookup_album_tracks($mystrands_id,Openstrands::$alias);
-
- $object = array();
-
- // Recurse the data we've found and check the local album
- foreach ($tracks as $track) {
- if (!$album->has_track($track['TrackName'])) {
- $data['title'] = $track['TrackName'];
- $data['track'] = $track['TrackNumber'];
- $data['disc'] = $track['DiscNumber'];
- $data['artist'] = $track['ArtistName'];
- $data['links'] = "<a target=\"_blank\" href=\"" . $track['URI'] . "\">" . get_user_icon('world_link','MyStrands') . "</a>";
- // If we've got a purchase URL
- if ($track['UserPurchaseURI']) {
- $data['links'] .= "<a target=\"_blank\" href=\"" . $track['UserPurchaseURI'] . "\">" . get_user_icon('money',_('Buy Track from MyStrands')) . "</a>";
- }
- $objects[] = Album::construct_from_array($data);
- }
- } // end foreach
-
- return $objects;
-
- } // find_missing_tracks
-
-} // metadata
-
-?>
diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php
index 086084ea..3f317187 100644
--- a/lib/class/rating.class.php
+++ b/lib/class/rating.class.php
@@ -68,20 +68,19 @@ class Rating extends database_object {
$user_id = Dba::escape($GLOBALS['user']->id);
$idlist = '(' . implode(',', $ids) . ')';
- $sql = "SELECT `rating`, `object_id` FROM `rating` WHERE `user`='$user_id' AND `object_id` IN $idlist " .
+ $sql = "SELECT `rating`, `object_id`,`rating`.`rating` FROM `rating` WHERE `user`='$user_id' AND `object_id` IN $idlist " .
"AND `object_type`='$type'";
$db_results = Dba::query($sql);
while ($row = Dba::fetch_assoc($db_results)) {
- $rating[$row['id']] = $row['rating'];
+ $results[$row['object_id']] = intval($row['rating']);
}
- $user_cache_name = 'rating_' . $type . '_user';
-
foreach ($ids as $id) {
- parent::add_to_cache($user_cache_name,$id,intval($rating[$id]));
- } // end foreach
+ parent::add_to_cache('rating_' . $type . '_user',$id,intval($results[$id]));
+ }
+ return true;
} // build_cache
@@ -92,8 +91,6 @@ class Rating extends database_object {
*/
public function get_user($user_id) {
- $id = intval($this->id);
-
if (parent::is_cached('rating_' . $this->type . '_user',$id)) {
return parent::get_from_cache('rating_' . $this->type . '_user',$id);
}
diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php
index 7582b9e2..dece1a7b 100644
--- a/lib/class/stream.class.php
+++ b/lib/class/stream.class.php
@@ -39,6 +39,9 @@ class Stream {
// Generate once an object is constructed
public static $session;
+ // Let's us tell if the session has been activated
+ private static $session_inserted;
+
/**
* Constructor for the stream class takes a type and an array
* of song ids
@@ -69,7 +72,7 @@ class Stream {
}
// We're starting insert the session into session_stream
- if (!$this->insert_session()) {
+ if (!self::insert_session()) {
debug_event('stream','Session Insertion failure, aborting','3');
return false;
}
@@ -106,6 +109,10 @@ class Stream {
*/
public static function get_session() {
+ if (!self::$session_inserted) {
+ self::insert_session(self::$session);
+ }
+
return self::$session;
} // get_session
@@ -114,18 +121,21 @@ class Stream {
* insert_session
* This inserts a row into the session_stream table
*/
- public function insert_session($sid='') {
+ public static function insert_session($sid='',$uid='') {
$sid = $sid ? Dba::escape($sid) : Dba::escape(self::$session);
+ $uid = $uid ? Dba::escape($uid) : Dba::escape($GLOBALS['user']->id);
$expire = time() + Config::get('stream_length');
$sql = "INSERT INTO `session_stream` (`id`,`expire`,`user`) " .
- "VALUES('$sid','$expire','$this->user_id')";
+ "VALUES('$sid','$expire','$uid')";
$db_results = Dba::query($sql);
if (!$db_results) { return false; }
+ self::$session_inserted = true;
+
return true;
} // insert_session
@@ -679,7 +689,6 @@ class Stream {
} // clear_now_playing
-
/**
* auto_init
* This is called on class load it sets the session
diff --git a/lib/class/vauth.class.php b/lib/class/vauth.class.php
index d5ee590d..410b2155 100644
--- a/lib/class/vauth.class.php
+++ b/lib/class/vauth.class.php
@@ -88,6 +88,8 @@ class vauth {
*/
public static function write($key,$value) {
+ // If we'd set NO_SESSION never run this
+ if (NO_SESSION == 1) { return true; }
$length = Config::get('session_length');
$value = Dba::escape($value);
diff --git a/lib/class/xmlrpcserver.class.php b/lib/class/xmlrpcserver.class.php
index fc903aaf..3801dc09 100644
--- a/lib/class/xmlrpcserver.class.php
+++ b/lib/class/xmlrpcserver.class.php
@@ -141,10 +141,7 @@ class xmlRpcServer {
return new xmlrpcresp(0,'503','Key/IP Mis-match Access Denied');
}
- $stream = new Stream();
- $stream->user_id = '-1';
-
- if (!$stream->insert_session($key)) {
+ if (!Stream::insert_session($key,'-1')) {
debug_event('XMLSERVER','Failed to create stream session','1');
return new xmlrpcresp(0,'503','Failed to Create Stream Session','1');
}
diff --git a/lib/init.php b/lib/init.php
index 71297258..7c6e3896 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -135,7 +135,6 @@ require_once $prefix . '/modules/getid3/getid3.php';
require_once $prefix . '/modules/infotools/Snoopy.class.php';
require_once $prefix . '/modules/infotools/AmazonSearchEngine.class.php';
require_once $prefix . '/modules/infotools/lastfm.class.php';
-require_once $prefix . '/modules/infotools/openstrands.class.php';
//require_once $prefix . '/modules/infotools/jamendoSearch.class.php';
/* Temp Fixes */
diff --git a/lib/preferences.php b/lib/preferences.php
index 786e9a38..ad5dc3ca 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -59,7 +59,6 @@ function update_preferences($pref_id=0) {
break;
/* MD5 the LastFM & MyStrands so it's not plainTXT */
case 'lastfm_pass':
- case 'mystrands_pass':
/* If it's our default blanking thing then don't use it */
if ($value == '******') { unset($_REQUEST[$name]); break; }
$value = md5($value);
@@ -241,7 +240,6 @@ function create_preference_input($name,$value) {
} // foreach themes
echo "</select>\n";
break;
- case 'mystrands_pass':
case 'lastfm_pass':
echo "<input type=\"password\" size=\"16\" name=\"$name\" value=\"******\" />";
break;
diff --git a/modules/infotools/openstrands.class.php b/modules/infotools/openstrands.class.php
deleted file mode 100644
index 4410a279..00000000
--- a/modules/infotools/openstrands.class.php
+++ /dev/null
@@ -1,725 +0,0 @@
-<?php
-/*
-
- Copyright (c) 2001 - 2007 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
- as published by the Free Software Foundation; version 2
- of the License.
-
- 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.
-
-*/
-
-/**
- * Ampache openStrands Class, Version 0.1
- * This class interacts with the OpenStrands API (http://mystrands.com)
- * It requires a valid authtoken, and on creation of an instance requires
- * a valid username and password, Password is expected as an MD5 hash for
- * security reasons
- *
- * This class returns the XML data as a array of key'd arrays, attributes
- * are stored in [][__attributes] = array(); Any questions, recommendations
- * bugfixes or the like please contact mystrands@ampache.org or visit us on
- * irc.ampache.org #ampache
- *
- * There are some bugs in this library, and some things that are a little
- * redundent, I will be fixing it in future releases.
- *
- * - Karl Vollmer
- *
- * REQUIREMENTS:
- * - fopen wrappers enabled to allow file_get_contents(URL);
- * - PHP5
- */
-class openStrands {
-
- public static $base_url = 'https://www.mystrands.com/services';
- private static $auth_token = '';
- private static $authenticated=false;
-
- // Some settings to prevent stupid users, or abusive queries
- public $limit = '10'; // Limit results set total, when possible
- public static $alias; // Store the users alias here after authing
- private $filter = ''; // The filter for this instance of the class
-
- // Stuff dealing with our internal XML parser
- public $_parser; // The XML parser
- public $_grabtags; // Tags to grab the contents of
- public $_currentTag; // Stupid hack to make things come out right
- public $_containerTag; // This is the 'highest' level tag we care about, everything falls under it
- public $_key; // Element count
-
- /**
- * Constructor
- * This takes a username and password, and verifys that this account
- * exists before it will let the person actually try to run any operations
- */
- public function __construct($username,$password) {
-
- // Check to see if we've already authenticated
- if (self::$authenticated) { return true; }
- if (!self::$auth_token) { echo 'No Auth Token, quiting'; return false; }
-
- // Trust them enough to let them try once
- self::$authenticated = true;
-
- // Test login with the provided credientials
- $auth_data = $this->user_validate($username,$password);
-
- if (!$auth_data) {
- self::$authenticated = false;
- }
- else {
- self::$authenticated = true;
- self::$alias = $auth_data['0']['Alias'];
- }
-
-
- } // __construct
-
- /**
- * user_validate
- * This takes a username, password and returns a key'd array of the
- * result data
- */
- public function user_validate($username,$password) {
-
- $username = urlencode($username);
- $password = urlencode($password);
-
- $xml_doc = self::run_query("/user/validate?username=$username&hexPass=$password");
-
- // Set the right parent
- $this->_containerTag = 'User';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // user_validate
-
- /**
- * user_lookup_profile
- * This takes a username and the md5 password and returns the users profile information
- */
- public function user_lookup_profile($username,$password) {
-
- $username = urlencode($username);
- $password = urlencode($password);
-
- $xml_doc = self::run_query("/user/lookup/profile?username=$username&hexPass=$password");
-
- // Set the right parent
- $this->_containerTag = 'User';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // user_lookup_profile
-
- /**
- * lookup_artists
- * This returns the data for a given mystrands artist (based on ID)
- * If it's an array of ids pass as [] = ID, [] = ID
- */
- public function lookup_artists($ids) {
-
- // This allows multiple artists in a single query
- // so build the string if needed
- if (is_array($ids)) {
- foreach ($ids as $id) {
- $string .= '&id=' . intval($id);
- }
- $string = ltrim($string,'&');
- $string = '?' . $string;
- }
- else {
- $string = '?id=' . intval($ids);
- }
-
- $xml_doc = self::run_query("/lookup/artists$string");
-
- // Set the right parent
- $this->_containerTag = 'SimpleArtist';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // lookup_artists
-
- /**
- * lookup_albums
- * This returns the data for a given mystrands album (based on ID)
- * If it's an array of ids pass as [] = ID, [] = ID
- * You can optionally pass an alias to this, if you do you can get
- * the 'buy' links as UserPurchaseURI
- */
- public function lookup_albums($ids,$alias='') {
-
- // This allows multiple albums in a single query,
- // so build it accordingly
- if (is_array($ids)) {
- foreach ($ids as $id) {
- $string .= '&id=' . intval($id);
- }
- $string = ltrim($string,'&');
- $string = '?' . $string;
- }
- else {
- $string = '?id=' . intval($ids);
- }
-
- // If they have passed an alias
- if ($alias) {
- $string .= '&alias=' . urlencode($alias);
- }
-
- $xml_doc = self::run_query("/lookup/albums$string");
-
- // Set the right parent
- $this->_containerTag = 'SimpleAlbum';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // lookup_albums
-
- /**
- * lookup_tracks
- * This returns the data for a given mystrands track (based on ID)
- * If it's an array of ids pass as [] = ID, [] = ID
- * This can take an optional alias, if passed UserPurchaseURI will
- * be returned
- */
- public function lookup_tracks($ids,$alias='') {
-
- // This allows for multiple entires, so build accordingly
- if (is_array($ids)) {
- foreach ($ids as $id) {
- $string .= '&id=' . intval($id);
- }
- $string = ltrim($string,'&');
- $string = '?' . $string;
- } // end if array
- else {
- $string = '?id=' . intval($ids);
- }
-
- // If they have passed an alias
- if ($alias) {
- $string .= '&alias=' . urlencode($alias);
- }
-
- $xml_doc = self::run_query("/lookup/tracks$string");
-
- // Set the parent
- $this->_containerTag = 'SimpleTrack';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // lookup_tracks
-
- /**
- * lookup_album_tracks
- * This takes a album ID and then returns the track list for it
- */
- public function lookup_album_tracks($mystrands_album_id,$alias='') {
-
- $mystrands_album_id = intval($mystrands_album_id);
-
- if ($alias) {
- $alias_txt = '&alias=' . urlencode($alias);
- }
-
- $xml_doc = self::run_query("/lookup/album/tracks?id=$mystrands_album_id$alias_txt");
-
- // Set the right parent
- $this->_containerTag = 'AlbumTrack';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // lookup_album_tracks
-
- /**
- * lookup_artist_albums
- * This returns a list of the albums for a given artist ID you can
- * pass an optional limit and offset
- */
- public function lookup_artist_albums($artist_id,$limit='',$offset='') {
-
- $artist_id = intval($artist_id);
-
- $limit = $limit ? intval($limit) : $this->limit;
- $offset = $offset ? intval($offset) : '0';
-
- $xml_doc = self::run_query("/lookup/artist/albums?id=$artist_id&num=$limit&skip=$offset");
-
- // Set the container
- $this->_containerTag = 'SimpleAlbum';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // lookup_artist_albums
-
- /**
- * search_albums
- * This searches for albums of the given name in MyStrands
- */
- public function search_albums($name,$limit='',$offset='') {
-
- $name = urlencode($name);
-
- $limit = $limit ? intval($limit) : $this->limit;
- $offset = $offset ? intval($offset) : '0';
-
- $xml_doc = self::run_query("/search/albums?searchText=$name&num=$limit&skip=$offset");
-
- // Set the right parent
- $this->_containerTag = 'SimpleAlbum';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // search_albums
-
- /**
- * search_artists
- * This searches for artists of the given name in MyStrands
- */
- public function search_artists($name,$limit='',$offset='') {
-
- $name = urlencode($name);
-
- $limit = $limit ? intval($limit) : $this->limit;
- $offset = $offset ? intval($offset) : '0';
-
- $xml_doc = self::run_query("/search/artists?searchText=$name&num=$limit&skip=$offset");
-
- // Set the right parent
- $this->_containerTag = 'SimpleArtist';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // search_artists
-
- /**
- * search_tracks
- * This searches for tracks on Mystrands based on the search text
- */
- public function search_tracks($name,$limit='',$offset='') {
-
- $name = urlencode($name);
-
- $limit = $limit ? intval($limit) : $this->limit;
- $offset = $offset ? intval($offset) : '0';
-
- $xml_doc = self::run_query("/search/tracks?searchText=$name&num=$limit&skip=$offset");
-
- // Set the right parent
- $this->_containerTag = 'SimpleTrack';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // search_tracks
-
- /**
- * match_artists
- * This does a best choice match on the artist name(s) passed
- */
- public function match_artists($values) {
-
- // If it's not, turn it into one!
- if (!is_array($values)) { $values = array($values); }
-
- foreach ($values as $value) {
- $artist_text .= '&name=' . urlencode($value);
- }
-
- $artist_text = ltrim($artist_text,'&');
- $artist_text = '?' . $artist_text;
-
- $xml_doc = self::run_query("/match/artists$artist_text");
-
- // Set the right parent
- $this->_containerTag = 'SimpleArtist';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // match_artists
-
- /**
- * match_albums
- * This does its best to match on the album name with an attached artist name
- * This function expects matches paris album,artist as such
- * [0]['artist'] = artist name, [0]['album'] = album name
- */
- public function match_albums($values) {
-
- // We're less forgiving here
- if (!is_array($values)) { return false; }
-
- foreach ($values as $value) {
- if (!$value['artist'] || !$value['album']) { next; }
- $query_text .= '&name=' . urlencode($value['artist']) . '|' . urlencode($value['album']);
- }
-
- $query_text = ltrim($query_text,'&');
- $query_text = '?' . $query_text;
-
- $xml_doc = self::run_query("/match/albums$query_text");
-
- // Set the right parent
- $this->_containerTag = 'SimpleAlbum';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // match_albums
-
- /**
- * match_tracks
- * This expects a trifectum of information as such
- * [0]['artist'] = artist name
- * [0]['album'] = album name
- * [0]['track] = track
- */
- public function match_tracks($values) {
-
- // We're not very forgiving here
- if (!is_array($values)) { return false; }
-
- foreach ($values as $value) {
- if (!$value['artist'] || !$value['album'] || !$value['track']) { next; }
- $query_text .= '&name' . urlencode($value['artist']) . '|' . urlencode($value['album']) . '|' . urlencode($value['track']);
- } // end foreach
-
- $query_text = ltrim($query_text,'&');
- $query_text = '?' . $query_text;
-
- $xml_doc = self::run_query("/match/tracks$query_text");
-
- // Set up the parent
- $this->_containerTag = 'SimpleTrack';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // match_tracks
-
- /**
- * recommend_artists
- * This generates recomendations for other artists, takes at least one artist (ID/Name) as
- * as seed, filters allowed, this user is used unless another alias is passed
- * $values should be ['id'][] = ID, ['id'][] = ID, ['name'][] = NAME, ['name'][] = NAME
- */
- public function recommend_artists($values,$limit='',$offset='',$alias='') {
-
- if (!is_array($values['id'])) { $values['id'] = array(); }
- if (!is_array($values['name'])) { $values['name'] = array(); }
-
- // Build out the ids first
- foreach ($values['id'] as $id) {
- $id_string .= '&id=' . intval($id);
- }
- // Now for z-names
- foreach ($values['name'] as $name) {
- $name_string .= '&name=' . urlencode($name);
- }
-
- // Clean up remaining stuff
- $filters = $this->filter;
- $offset = $offset ? intval($offset) : '0';
- $limit = $limit ? intval($limit) : $this->limit;
- $alias = $alias ? urlencode($alias) : urlencode(self::$alias);
-
- $xml_doc = self::run_query("/recommend/artists?alias=$alias$id_string$name_string&num=$limit&skip=$offset$filters");
-
- $this->_containerTag = 'SimpleArtist';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // recommend_artists
-
- /**
- * recommend_albums
- * This produces recommended albums based on sets of artist|album filters allowed, this user is used unless different
- * alias is passed. Values are integrity checked to the best of my lazyness
- * $values should be ['id'][] = ARTISTID|ALBUMID, ['name'][] = ARTIST|ALBUM
- */
- public function recommend_albums($values,$limit='',$offset='',$alias='') {
-
- if (!is_array($values['id'])) { $values['id'] = array(); }
- if (!is_array($values['name'])) { $values['name'] = array(); }
-
- // Build out the ids first
- foreach ($values['id'] as $id) {
- if (!preg_match("/\d+\|\d+/",$id)) { next; }
- $id_string .= '&id=' . intval($id);
- }
- // Now for z-names
- foreach ($values['name'] as $name) {
- // Only add stuff that's valid
- if (!preg_match("/.+\|.+/",$name)) { next; }
- $name_string .= '&name=' . urlencode($name);
- }
-
- // Clean up remaining stuff
- $filters = $this->filter;
- $offset = $offset ? intval($offset) : '0';
- $limit = $limit ? intval($limit) : $this->limit;
- $alias = $alias ? urlencode($alias) : urlencode(self::$alias);
-
- $xml_doc = self::run_query("/recommend/albums?alias=$alias$id_string$name_string&num=$limit&skip=$offset$filters");
-
- $this->_containerTag = 'SimpleAlbum';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // recommend_albums
-
- /**
- * recommend_tracks
- * This produces recommended tracks based on sets of artist|album|track filters allowed, this user is used unless different
- * alias is passed. Values are integrity checked to the best of my lazyness
- * $values should be ['id'][] = ARTISTID|ALBUMID|TRACKID, ['name'][] = ARTIST|ALBUM|TRACK
- */
- public function recommend_tracks($values,$limit='',$offset='',$alias='') {
-
- if (!is_array($values['id'])) { $values['id'] = array(); }
- if (!is_array($values['name'])) { $values['name'] = array(); }
-
- // Build out the ids first
- foreach ($values['id'] as $id) {
- if (!preg_match("/\d+\|\d+\|\d+/",$id)) { next; }
- $id_string .= '&id=' . intval($id);
- }
- // Now for z-names
- foreach ($values['name'] as $name) {
- // Only add stuff that's valid
- if (!preg_match("/.+\|.+\|.+/",$name)) { next; }
- $name_string .= '&name=' . urlencode($name);
- }
-
- // Clean up remaining stuff
- $filters = $this->filter;
- $offset = $offset ? intval($offset) : '0';
- $limit = $limit ? intval($limit) : $this->limit;
- $alias = $alias ? urlencode($alias) : urlencode(self::$alias);
-
- $xml_doc = self::run_query("/recommend/tracks?alias=$alias$id_string$name_string&num=$limit&skip=$offset$filters");
-
- $this->_containerTag = 'SimpleTrack';
-
- $data = $this->run_parse($xml_doc);
-
- return $data;
-
- } // recommend_tracks
-
- /**
- * set_filter
- * This builds out the filter for this object, it's a per instance filter
- */
- public function set_filter($field,$fuzzy,$level,$values) {
-
- // Make sure they pick a sane field
- switch ($field) {
- case 'Artist':
- case 'Album':
- case 'Year':
- case 'Track':
- case 'Genre':
- case 'PersonalTag':
- case 'CommunityTag':
- case 'PersonalTrackTag':
- case 'CommunityTrackTag':
- case 'PersonalArtistTag':
- case 'CommunityArtistTag':
- case 'UserHistory':
- // We're good
- break;
- default:
- return false;
- break;
- } // end switch on passed filed
-
- $level = intval($level);
-
- // Default to very hard
- if ($level > 9 || $level < 0) { $level = 0; }
-
- // Clean up the fuzzyness
- $fuzzy = make_bool($fuzzy);
- if ($fuzzy) { $fuzzy = 'True'; }
- else { $fuzzy = 'False'; }
-
- if (is_array($values)) {
- foreach ($values as $value) {
- $value_string .= $value;
- }
- }
- else {
- $value_string = $values;
- }
-
- $filter_string = "&filter=$field,$fuzzy,$level|$value_string";
-
- $this->filter .= $filter_string;
-
- } // set_filter
-
- /**
- * set_auth_token
- * This function should be called on load to set the auth_token, if you don't
- * just hardcode it, also allows realtime switching between auth tokens
- * so that users can use their own limits when querying
- */
- public static function set_auth_token($token) {
-
- // Set it
- self::$auth_token = $token;
-
- //FIXME: We should log this event?
-
- } // set_auth_token
-
- /**
- * run_query
- * This builds a URL, runs it and then returns whatever we found
- */
- private static function run_query($action) {
-
- // Stop them if they are not authenticated
- if (!self::$authenticated) { return false; }
-
- // Build the URL
- $url = self::$base_url . $action . '&subscriberId=' . self::$auth_token;
-
- $contents = file_get_contents($url);
-
- return $contents;
-
- } // run_query
-
- /**
- * run_parse
- * This will create the parser, de-fudge the doc
- * and set $this->results to the result data
- */
- public function run_parse($xml_doc) {
-
- // Create the parser
- $this->create_parser();
-
- $this->_key = -1;
- $success = xml_parse($this->_parser,$xml_doc);
-
- if (!$success) {
- return false;
- }
-
- xml_parser_free($this->_parser);
-
- $data = $this->results;
- $this->results = '';
-
- if (!$data) { return array(); }
-
- return $data;
-
- } // run_parse
-
- /**
- * create_parser
- * this sets up an XML Parser
- */
- public function create_parser() {
- $this->_parser = xml_parser_create();
-
- xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
-
- xml_set_object($this->_parser, $this);
-
- xml_set_element_handler($this->_parser, 'start_element', 'end_element');
-
- xml_set_character_data_handler($this->_parser, 'cdata');
-
- } // create_parser
-
- /**
- * start_element
- * This is part of our internal XML parser
- */
- function start_element($parser, $tag, $attributes) {
-
- // If it's our 'parent' object tag then bump the key
- if ($tag == $this->_containerTag) {
- $this->_key++;
- // If we find attributes
- if (count($attributes)) {
- // If it's not already an array, make it one so merge always works
- if (!isset($this->results[$this->_key][__attributes])) {
- $this->results[$this->_key][__attributes] = array();
- }
- $this->results[$this->_key][__attributes] = array_merge($this->results[$this->_key][__attributes],$attributes);
- } // end if there are attributes
- }
- elseif ($this->_key >= '0') {
- $this->_currentTag = $tag;
- } // if key is at least 0
-
- } // start_element
-
- function cdata($parser, $cdata) {
-
- $tag = $this->_currentTag;
-
- if (strlen($tag) AND $this->_key >= 0) {
- $this->results[$this->_key][$tag] .= trim($cdata);
- }
-
-
- } // cdata
-
- function end_element($parser, $tag) {
-
- /* Zero the tag */
- $this->_currentTag = '';
-
- } // end_element
-
-} // end openstrands
-
-?>
diff --git a/modules/plugins/OpenStrands.plugin.php b/modules/plugins/OpenStrands.plugin.php
deleted file mode 100644
index d63e9616..00000000
--- a/modules/plugins/OpenStrands.plugin.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-/*
-
- Copyright (c) 2001 - 2007 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.
-
-*/
-
-class AmpacheOpenStrands {
-
- public $name ='OpenStrands';
- public $description ='Interface with MyStrands, recommendations etc';
- public $url ='http://www.mystrands.com/openstrands/overview.vm';
- public $version ='000001';
- public $min_ampache ='340007';
- public $max_ampache ='340008';
-
- /**
- * Constructor
- * This function does nothing...
- */
- public function __construct() {
-
- return true;
-
- } // PluginLastfm
-
- /**
- * install
- * This is a required plugin function it inserts the required preferences
- * into Ampache
- */
- public function install() {
-
- Preference::insert('mystrands_user','MyStrands Login',' ','25','string','plugins');
- Preference::insert('mystrands_pass','MyStrands Password',' ','25','string','plugins');
-
- } // install
-
- /**
- * uninstall
- * This is a required plugin function it removes the required preferences from
- * the database returning it to its origional form
- */
- function uninstall() {
-
- Preference::delete('mystrands_pass');
- Preference::delete('mystrands_user');
-
- } // uninstall
-
-} // end AmpacheLastfm
-?>
diff --git a/server/stats.ajax.php b/server/stats.ajax.php
index c4c73d03..24af4878 100644
--- a/server/stats.ajax.php
+++ b/server/stats.ajax.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright (c) 2001 - 2007 Ampache.org
+ Copyright (c) Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
@@ -25,84 +25,6 @@
if (AJAX_INCLUDE != '1') { exit; }
switch ($_REQUEST['action']) {
- case 'show_recommend':
- switch ($_REQUEST['type']) {
- case 'artist':
- case 'album':
- case 'track':
- // We're good
- break;
- default:
- $results['rfc3514'] = '0x1';
- break 2;
- } // verifying the type
-
- ob_start();
- show_box_top(_('Recommendations'));
- echo "Loading...";
- $ajax_action = Ajax::action('?page=stats&action=recommend&type=' . $_REQUEST['type'] . '&id=' . $_REQUEST['id'],'show_recommend_refresh');
- Ajax::run($ajax_action);
- show_box_bottom();
- $results['additional_information'] = ob_get_contents();
- ob_end_clean();
- break;
- case 'recommend':
- switch ($_REQUEST['type']) {
- case 'artist':
- $headers = array('name'=>_('Name'),'links'=>_('Links'));
- break;
- case 'album':
- case 'track':
- // We're good
- default:
- $results['rtc3514'] = '0x1';
- break 2;
- }
-
- // Get the recommendations
- $objects = metadata::recommend_similar($_REQUEST['type'],$_REQUEST['id'],'7');
-
- ob_start();
- show_box_top(_('Recommendations'));
- require_once Config::get('prefix') . '/templates/show_objects.inc.php';
- show_box_bottom();
- $results['additional_information'] = ob_get_contents();
- ob_end_clean();
- break;
- case 'show_check_album_tracks':
- ob_start();
- show_box_top(_('Find Missing Tracks'));
- echo "Loading...";
- $ajax_action = Ajax::action('?page=stats&action=check_album_tracks&id=' . $_REQUEST['id'],'show_album_tracks_refresh'); Ajax::run($ajax_action);
- show_box_bottom();
- $results['additional_information'] = ob_get_contents();
- ob_end_clean();
- break;
- case 'check_album_tracks':
-
- // Set the headers
- $headers = array('title'=>_('Title'),'track'=>_('Track'),'artist'=>_('Artist'),'links'=>_('Links'));
-
- // Ask the great and wise metadata
- $objects = metadata::find_missing_tracks($_REQUEST['id']);
-
- if ($error = ob_get_contents()) {
- ob_end_clean();
- ob_start();
- show_box_top(_('Find Missing Tracks'));
- echo $error;
- show_box_bottom();
- $results['additional_information'] = ob_get_contents();
- ob_end_clean();
- break;
- }
- ob_start();
- show_box_top(_('Find Missing Tracks'));
- require_once Config::get('prefix') . '/templates/show_objects.inc.php';
- show_box_bottom();
- $results['additional_information'] = ob_get_contents();
- ob_end_clean();
- break;
default:
$results['rfc3514'] = '0x1';
break;
diff --git a/server/xml.server.php b/server/xml.server.php
index af00ec85..2f4df872 100644
--- a/server/xml.server.php
+++ b/server/xml.server.php
@@ -72,7 +72,7 @@ if ($_REQUEST['action'] != 'handshake') {
switch ($_REQUEST['action']) {
case 'handshake':
// Send the data we were sent to the API class so it can be chewed on
- $token = Api::handshake($_REQUEST['timestamp'],$_REQUEST['auth'],$_SERVER['REMOTE_ADDR'],$_REQUEST['user']);
+ $token = Api::handshake($_REQUEST['timestamp'],$_REQUEST['auth'],$_SERVER['REMOTE_ADDR'],$_REQUEST['user'],$_REQUEST['version']);
if (!$token) {
ob_end_clean();
diff --git a/templates/show_artist.inc.php b/templates/show_artist.inc.php
index 37b9ad40..a2df6045 100644
--- a/templates/show_artist.inc.php
+++ b/templates/show_artist.inc.php
@@ -31,11 +31,25 @@ if (Config::get('ratings')) {
<div id="information_actions">
<ul>
-<li><a href="<?php echo $web_path; ?>/artists.php?action=show_all_songs&amp;artist=<?php echo $artist->id; ?>"><?php echo get_user_icon('view'); ?></a> <?php echo _("Show All Songs By") . " " . $artist->f_name; ?></li>
-<li><?php echo Ajax::button('?action=basket&type=artist&id=' . $artist->id,'add',_('Add'),'add_' . $artist->id); ?><?php echo _('Add All songs By') . ' ' . $artist->f_name; ?></li>
-<li><?php echo Ajax::button('?action=basket&type=artist_random&id=' . $artist->id,'random',_('Random'),'random_' . $artist->id); ?><?php echo _('Add Random Songs By') . ' ' . $artist->f_name; ?></li>
+<li>
+ <a href="<?php echo $web_path; ?>/artists.php?action=show_all_songs&amp;artist=<?php echo $artist->id; ?>"><?php echo get_user_icon('view'); ?></a> <?php echo _("Show All Songs By") . " " . $artist->f_name; ?>
+</li>
+<li>
+ <?php echo Ajax::button('?action=basket&type=artist&id=' . $artist->id,'add',_('Add'),'add_' . $artist->id); ?><?php echo _('Add All songs By') . ' ' . $artist->f_name; ?>
+</li>
+<li>
+ <?php echo Ajax::button('?action=basket&type=artist_random&id=' . $artist->id,'random',_('Random'),'random_' . $artist->id); ?><?php echo _('Add Random Songs By') . ' ' . $artist->f_name; ?>
+</li>
<?php if (Access::check('interface','50')) { ?>
- <li><a href="<?php echo $web_path; ?>/artists.php?action=update_from_tags&amp;artist=<?php echo $artist->id; ?>"><?php echo get_user_icon('cog'); ?></a> <?php echo _('Update from tags'); ?></li>
+<li>
+ <a href="<?php echo $web_path; ?>/artists.php?action=update_from_tags&amp;artist=<?php echo $artist->id; ?>"><?php echo get_user_icon('cog'); ?></a> <?php echo _('Update from tags'); ?>
+</li>
+<?php } ?>
+<?php if (Access::check_function('batch_download')) { ?>
+<li>
+ <a href="<?php echo $web_path; ?>/batch.php?action=artist&id=<?php echo $artist->id; ?>"><?php echo get_user_icon('batch_download'); ?></a>
+ <?php echo _('Download'); ?>
+</li>
<?php } ?>
<li>
<input type="checkbox" id="show_artist_artCB" <?php echo $string = Browse::get_filter('show_art') ? 'checked="checked"' : ''; ?>/> <?php echo _('Show Art'); ?>
diff --git a/templates/show_song_row.inc.php b/templates/show_song_row.inc.php
index dc463470..82b0cf4b 100644
--- a/templates/show_song_row.inc.php
+++ b/templates/show_song_row.inc.php
@@ -21,6 +21,9 @@
?>
<td class="cel_add">
<?php echo Ajax::button('?action=basket&type=song&id=' . $song->id,'add',_('Add'),'add_' . $song->id); ?>
+ <?php if (Access::check_function('download')) { ?>
+ <a href="<?php echo $song->get_url(); ?>"><?php echo get_user_icon('link'); ?></a>
+ <?php } ?>
</td>
<td class="cel_song"><?php echo $song->f_link; ?></td>
<td class="cel_artist"><?php echo $song->f_artist_link; ?></td>
@@ -37,7 +40,7 @@
<?php echo get_user_icon('comment',_('Post Shout')); ?>
</a>
<?php } ?>
- <?php if (Config::get('download')) { ?>
+ <?php if (Access::check_function('download')) { ?>
<a href="<?php echo Config::get('web_path'); ?>/stream.php?action=download&amp;song_id=<?php echo $song->id; ?>">
<?php echo get_user_icon('download',_('Download')); ?>
</a>