diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2009-05-18 17:34:22 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2009-05-18 17:34:22 +0000 |
commit | d84e62dba716114b799a618cbfd2b14ec61ed1f9 (patch) | |
tree | 1dc58dc8636fd369d3862cb0048004fab19f2233 /lib | |
parent | 5bd82180f5470c4ce255d02b7aa36c476db1cd99 (diff) | |
download | ampache-d84e62dba716114b799a618cbfd2b14ec61ed1f9.tar.gz ampache-d84e62dba716114b799a618cbfd2b14ec61ed1f9.tar.bz2 ampache-d84e62dba716114b799a618cbfd2b14ec61ed1f9.zip |
api fixes, added librefm scrobbler (untested) and fixed minor error in header file with rtl vs ltr languages also removed dead RioPlayer plugin
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/scrobbler.class.php | 10 | ||||
-rw-r--r-- | lib/class/tag.class.php | 37 | ||||
-rw-r--r-- | lib/class/update.class.php | 16 | ||||
-rw-r--r-- | lib/class/user.class.php | 8 | ||||
-rw-r--r-- | lib/class/xmldata.class.php | 4 | ||||
-rw-r--r-- | lib/preferences.php | 2 |
6 files changed, 65 insertions, 12 deletions
diff --git a/lib/class/scrobbler.class.php b/lib/class/scrobbler.class.php index 6c4b1e0f..f2b56c7c 100644 --- a/lib/class/scrobbler.class.php +++ b/lib/class/scrobbler.class.php @@ -30,12 +30,13 @@ class scrobbler { public $submit_url; public $queued_tracks; public $reset_handshake = false; + public $scrobble_host = 'post.audioscrobbler.com'; /** * Constructor * This is the constructer it takes a username and password */ - public function __construct($username, $password,$host='',$port='',$url='',$challenge='') { + public function __construct($username, $password,$host='',$port='',$url='',$challenge='',$scrobble_host='') { $this->error_msg = ''; $this->username = trim($username); @@ -45,6 +46,7 @@ class scrobbler { $this->submit_port = $port; $this->submit_url = $url; $this->queued_tracks = array(); + if ($scrobble_host) { $this->scrobble_host = $scrobble_host; } } // scrobbler @@ -73,7 +75,7 @@ class scrobbler { */ public function handshake() { - $as_socket = fsockopen('post.audioscrobbler.com', 80, $errno, $errstr, 2); + $as_socket = fsockopen($this->scrobble_host, 80, $errno, $errstr, 2); if(!$as_socket) { $this->error_msg = $errstr; return false; @@ -86,7 +88,7 @@ class scrobbler { $get_string = "GET /?hs=true&p=1.2&c=apa&v=0.1&u=$username&t=$timestamp&a=$auth_token HTTP/1.1\r\n"; fwrite($as_socket, $get_string); - fwrite($as_socket, "Host: post.audioscrobbler.com\r\n"); + fwrite($as_socket, "Host: $this->scrobble_host\r\n"); fwrite($as_socket, "Accept: */*\r\n\r\n"); $buffer = ''; @@ -202,7 +204,7 @@ class scrobbler { fwrite($as_socket, $action); fwrite($as_socket, "Host: ".$this->submit_host."\r\n"); fwrite($as_socket, "Accept: */*\r\n"); - fwrite($as_socket, "User-Agent: Ampache/3.4\r\n"); + fwrite($as_socket, "User-Agent: Ampache/3.6\r\n"); fwrite($as_socket, "Content-type: application/x-www-form-urlencoded\r\n"); fwrite($as_socket, "Content-length: ".strlen($query_str)."\r\n\r\n"); diff --git a/lib/class/tag.class.php b/lib/class/tag.class.php index 44d91c9b..c6dcf13d 100644 --- a/lib/class/tag.class.php +++ b/lib/class/tag.class.php @@ -349,18 +349,20 @@ class Tag extends database_object { /** * get_object_tags * Display all tags that apply to maching target type of the specified id + * UNUSED */ public static function get_object_tags($type, $id) { if (!self::validate_type($type)) { return array(); } + + $id = Dba::escape($id); - $sql = "SELECT DISTINCT `tag_map`.`id`, `tag`.`name`, `tag_map`.`user` FROM `tag` " . - "LEFT JOIN `tag_map` ON `tag_map`.`id`=`tag`.`map_id` " . - "LEFT JOIN `$type` ON `$type`.`id`=`tag_map`.`object_id` " . - "WHERE `tag_map`.`object_type`='$type'"; + $sql = "SELECT `tag_map`.`id`, `tag`.`name`, `tag_map`.`user` FROM `tag` " . + "LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` " . + "WHERE `tag_map`.`object_type`='$type' AND `tag_map`.`object_id`='$id'"; $results = array(); - $db_results = Dba::query($sql); + $db_results = Dba::read($sql); while ($row = Dba::fetch_assoc($db_results)) { $results[] = $row; @@ -371,6 +373,31 @@ class Tag extends database_object { } // get_object_tags /** + * get_tag_objects + * This gets the objects from a specified tag and returns an array of object ids, nothing more + */ + public static function get_tag_objects($type,$tag_id) { + + if (!self::validate_type($type)) { return array(); } + + $tag_id = Dba::escape($id); + + $sql = "SELECT DISTINCT `tag_map`.`object_id` FROM `tag_map` " . + "WHERE `tag_map`.`tag_id`='$tag_id' AND `tag_map`.`object_type`='$type'"; + $db_results = Dba::read($sql); + + $results = array(); + + while ($row = Dba::fetch_assoc($db_results)) { + $results[] = $row['object_id']; + } + + return $results; + + + } // get_tag_objects + + /** * get_tags * This is a non-object non type depedent function that just returns tags * we've got, it can take filters (this is used by the tag cloud) diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 57283f56..5a36b253 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -1762,7 +1762,23 @@ class Update { */ public static function update_360001() { + // Remove any RIO related information from the database as the plugin has been removed + $sql = "DELETE FROM `update_info` WHERE `key` LIKE 'Plugin_Ri%'"; + $db_results = Dba::write($sql); + + $sql = "DELETE FROM `preference` WHERE `name` LIKE 'rio_%'"; + $db_results = Dba::write($sql); + + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::query($sql); + + User::fix_preferences('-1'); + + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // while we're fixing the useres stuff + // self::set_version('db_version','360001'); } // update_360001 diff --git a/lib/class/user.class.php b/lib/class/user.class.php index a8d58ed4..0b5f6c44 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -561,6 +561,14 @@ class User extends database_object { } } // end if is_installed + // Check and see if librefm is loaded and run scrobblizing + if (Plugin::is_installed('Libre.FM')) { + $librefm = new Plugin('Librefm'); + if ($lastfm->_plugin->load($this->prefs,$this->id)) { + $lastfm->_plugin->submit($song_info,$this->id); + } + } // end if is_installed + // Do this last so the 'last played checks are correct' Stats::insert('song',$song_id,$user); Stats::insert('album',$song_info->album,$user); diff --git a/lib/class/xmldata.class.php b/lib/class/xmldata.class.php index c9a11112..5fa58e71 100644 --- a/lib/class/xmldata.class.php +++ b/lib/class/xmldata.class.php @@ -179,7 +179,6 @@ class xmlData { $tags = array_splice($tags,self::$offset,self::$limit); } - $string = ''; foreach ($tags as $tag_id) { @@ -190,12 +189,11 @@ class xmlData { "\t<albums>" . intval($counts['album']) . "</albums>\n" . "\t<artists>" . intval($counts['artist']) . "</artists>\n" . "\t<songs>" . intval($counts['songs']) . "</songs>\n" . - "\t<videos>" . intval($counts['video']) . "</video>\n" . + "\t<videos>" . intval($counts['video']) . "</videos>\n" . "\t<playlists>" . intval($count['playlist']) . "</playlists>\n" . "\t<stream>" . intval($count['live_stream']) . "</stream>\n" . "</tag>\n"; } // end foreach - $final = self::_header() . $string . self::_footer(); diff --git a/lib/preferences.php b/lib/preferences.php index 1e721216..26e8c422 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -58,6 +58,7 @@ function update_preferences($pref_id=0) { $value = Stream::validate_bitrate($value); break; /* MD5 the LastFM & MyStrands so it's not plainTXT */ + case 'librefm_pass': case 'lastfm_pass': /* If it's our default blanking thing then don't use it */ if ($value == '******') { unset($_REQUEST[$name]); break; } @@ -244,6 +245,7 @@ function create_preference_input($name,$value) { echo "</select>\n"; break; case 'lastfm_pass': + case 'librefm_pass': echo "<input type=\"password\" size=\"16\" name=\"$name\" value=\"******\" />"; break; case 'playlist_method': |