diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/artist.lib.php | 31 | ||||
-rw-r--r-- | lib/class/artist.class.php | 29 | ||||
-rw-r--r-- | lib/class/rating.class.php | 24 | ||||
-rw-r--r-- | lib/class/user.class.php | 69 | ||||
-rw-r--r-- | lib/init.php | 1 | ||||
-rw-r--r-- | lib/rating.lib.php | 7 | ||||
-rw-r--r-- | lib/xmlrpc.php | 8 |
7 files changed, 108 insertions, 61 deletions
diff --git a/lib/artist.lib.php b/lib/artist.lib.php index f2857921..79440cd8 100644 --- a/lib/artist.lib.php +++ b/lib/artist.lib.php @@ -78,12 +78,19 @@ function show_artists ($match = '') { // If there isn't a view object we need to create a new one.. else { + + // Pull in the min object count + $min_object_count = conf('min_object_count'); + $min_join = " LEFT JOIN song ON song.artist=artist.id"; + $min_group = "GROUP BY song.artist HAVING COUNT(song.id) > $min_object_count"; + + if ( isset($match) && $match != '' ) { - $query = "SELECT id,name FROM artist " . - " WHERE name LIKE '$match%' "; + $query = "SELECT artist.id,artist.name FROM artist $min_join" . + " WHERE artist.name LIKE '$match%' $min_group"; } else { - $query = "SELECT id FROM artist "; + $query = "SELECT artist.id FROM `artist` $min_join $min_group"; } $db_results = mysql_query($query, $dbh); @@ -102,22 +109,20 @@ function show_artists ($match = '') { $artists = $match; $_SESSION['view_script'] = false; } - +debug_event('foo',$view->sql,'3'); $db_results = mysql_query($view->sql, $dbh); - while ($r = @mysql_fetch_array($db_results)) { - //FIXME: This seriously needs to be updated to use the artist object - $artist_info = get_artist_info($r[0]); - $artist = format_artist($artist_info); - // Only Add this artist if there is information to go along with it - if ($artist_info) { - $artists[] = $artist; - } + + // Get the artist object + while ($r = mysql_fetch_assoc($db_results)) { + $artist = new Artist($r['id']); + $artist->format(); + $artists[] = $artist; } if (count($artists)) { /* Ack horrible hack :( */ $GLOBALS['view'] = $view; - require ( conf('prefix') . "/templates/show_artists.inc"); + require conf('prefix') . '/templates/show_artists.inc.php'; } } // show_artists diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php index fbbca4d1..c89eb271 100644 --- a/lib/class/artist.class.php +++ b/lib/class/artist.class.php @@ -176,14 +176,14 @@ class Artist { } // get_count - /*! - @function format_artist - @discussion this function takes an array of artist - information and reformats the relevent values - so they can be displayed in a table for example - it changes the title into a full link. - */ - function format_artist() { + /** + * format + * this function takes an array of artist + * information and reformats the relevent values + * so they can be displayed in a table for example + * it changes the title into a full link. + */ + function format() { /* Combine prefix and name, trim then add ... if needed */ $name = scrub_out(truncate_with_ellipse(trim($this->prefix . " " . $this->name))); @@ -196,8 +196,21 @@ class Artist { $this->link = "<a href=\"" . conf('web_path') . "/artists.php?action=show&artist=" . $this->id . "\" title=\"" . $this->full_name . "\">" . $name . "</a>"; $this->name = $this->link; + // Get the counts + $this->get_count(); + return true; + } // format + + /** + * format_artist + * DEFUNCT, do not use anymore + */ + function format_artist() { + + $this->format(); + } // format_artist /*! diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php index e79ea0ef..32a85253 100644 --- a/lib/class/rating.class.php +++ b/lib/class/rating.class.php @@ -1,13 +1,12 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + 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; either version 2 - of the License, or (at your option) any later version. + 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 @@ -44,12 +43,15 @@ class Rating { $this->id = intval($id); $this->type = sql_escape($type); - if (intval($id) > 1) { + // Check for the users rating + if ($rating = $this->get_user($GLOBALS['user']->id)) { + $this->rating = $rating; + } + else { $this->get_average(); } - else { - $this->rating='0'; - } + + return true; } // Rating @@ -58,11 +60,11 @@ class Rating { * Get the user's rating this is based off the currently logged * in user. It returns the value */ - function get_user($username) { + function get_user($user_id) { - $username = sql_escape($username); + $user_id = sql_escape($user_id); - $sql = "SELECT rating FROM ratings WHERE user='$username' AND object_id='$this->id' AND object_type='$this->type'"; + $sql = "SELECT rating FROM ratings WHERE user='$user_id' AND object_id='$this->id' AND object_type='$this->type'"; $db_results = mysql_query($sql, dbh()); $results = mysql_fetch_assoc($db_results); diff --git a/lib/class/user.class.php b/lib/class/user.class.php index c03a3969..a14863a5 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -1,13 +1,12 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + 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; either version 2 - of the License, or (at your option) any later version. + 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 @@ -25,7 +24,6 @@ */ - class User { //Basic Componets @@ -247,7 +245,8 @@ class User { /* Find everything they've rated at 4+ */ $sql = "SELECT object_id,user_rating FROM ratings " . - "WHERE user='" . sql_escape($user_id) . "' AND user_rating >='4' AND object_type = '" . sql_escape($type) . "' ORDER BY user_rating DESC"; + "WHERE user='" . sql_escape($user_id) . "' AND user_rating >='4' AND " . + "object_type = '" . sql_escape($type) . "' ORDER BY user_rating DESC"; $db_results = mysql_query($sql,dbh()); while ($r = mysql_fetch_assoc($db_results)) { @@ -470,8 +469,8 @@ class User { function update_access($new_access) { /* Prevent Only User accounts */ - if ($new_access == '25') { - $sql = "SELECT username FROM user WHERE (access='admin' OR access='100') AND username != '$this->username'"; + if ($new_access < '100') { + $sql = "SELECT `id` FROM user WHERE `access`='100' AND `id` != '$this->id'"; $db_results = mysql_query($sql, dbh()); if (!mysql_num_rows($db_results)) { return false; } } @@ -500,8 +499,7 @@ class User { function update_stats($song_id) { $song_info = new Song($song_id); - //FIXME:: User uid reference - $user = $this->uid; + $user = $this->id; if (!$song_info->file) { return false; } @@ -603,8 +601,9 @@ class User { @discussion updates a users password */ function update_password($new_password) { - - $sql = "UPDATE user SET password=PASSWORD('$new_password') WHERE username='$this->username'"; + + $new_password = sql_escape($new_password); + $sql = "UPDATE user SET password=PASSWORD('$new_password') WHERE `id`='$this->id'"; $db_results = mysql_query($sql, dbh()); return true; @@ -628,7 +627,7 @@ class User { /* Calculate their total Bandwidth Useage */ $sql = "SELECT song.size FROM song LEFT JOIN object_count ON song.id=object_count.object_id " . - "WHERE object_count.user='$this->uid' AND object_count.object_type='song'"; + "WHERE object_count.user='$this->id' AND object_count.object_type='song'"; $db_results = mysql_query($sql, dbh()); while ($r = mysql_fetch_assoc($db_results)) { @@ -959,7 +958,7 @@ class User { */ function delete_stats() { - $sql = "DELETE FROM object_count WHERE userid='" . $this->username . "'"; + $sql = "DELETE FROM object_count WHERE user='" . $this->id . "'"; $db_results = mysql_query($sql, dbh()); } // delete_stats @@ -975,7 +974,7 @@ class User { admin */ if ($this->has_access(100)) { - $sql = "SELECT username FROM user WHERE (access='admin' OR access='100') AND username !='" . sql_escape($this->username) . "'"; + $sql = "SELECT `id` FROM user WHERE `access`='100' AND id !='" . sql_escape($this->id) . "'"; $db_results = mysql_query($sql, dbh()); if (!mysql_num_rows($db_results)) { return false; @@ -983,22 +982,34 @@ class User { } // if this is an admin check for others // Delete their playlists - $sql = "DELETE FROM playlist WHERE user='$this->username'"; + $sql = "DELETE FROM playlist WHERE user='$this->id'"; $db_results = mysql_query($sql, dbh()); // Delete any stats they have - $sql = "DELETE FROM object_count WHERE userid='$this->username'"; + $sql = "DELETE FROM object_count WHERE user='$this->id'"; $db_results = mysql_query($sql, dbh()); + // Delete their ratings + $sql = "DELETE FROM `ratings` WHERE `user`='$this->id'"; + $db_results = mysql_query($sql,dbh()); + + // Delete their tags + $sql = "DELETE FROM `tag_map` WHERE `user`='$this->id'"; + $db_results = mysql_query($sql,dbh()); + + // Clean out the tags + $sql = "DELETE FROM `tags` USING `tag_map` LEFT JOIN `tag_map` ON tag_map.id=tags.map_id AND tag_map.id IS NULL"; + $db_results = mysql_query($sql,dbh()); + // Delete their preferences - $sql = "DELETE FROM preferences WHERE user='$this->username'"; + $sql = "DELETE FROM preferences WHERE user='$this->id'"; $db_results = mysql_query($sql, dbh()); // Delete the user itself - $sql = "DELETE FROM user WHERE username='$this->username'"; + $sql = "DELETE FROM user WHERE `id`='$this->id'"; $db_results = mysql_query($sql, dbh()); - $sql = "DELETE FROM session WHERE username='$this->username'"; + $sql = "DELETE FROM session WHERE username='" . sql_escape($this->username) . "'"; $db_results = mysql_query($sql, dbh()); return true; @@ -1100,6 +1111,24 @@ class User { } // activate_user + /*! + @function is_xmlrpc + @discussion checks to see if this is a valid + xmlrpc user + */ + function is_xmlrpc() { + + /* If we aren't using XML-RPC return true */ + if (!conf('xml_rpc')) { + return false; + } + + //FIXME: Ok really what we will do is check the MD5 of the HTTP_REFERER + //FIXME: combined with the song title to make sure that the REFERER + //FIXME: is in the access list with full rights + return true; + + } // is_xmlrpc } //end user class diff --git a/lib/init.php b/lib/init.php index 6d8c9158..01d0c6c4 100644 --- a/lib/init.php +++ b/lib/init.php @@ -137,7 +137,6 @@ require_once(conf('prefix') . '/lib/themes.php'); require_once(conf('prefix') . '/lib/stream.lib.php'); require_once(conf('prefix') . '/lib/playlist.lib.php'); require_once(conf('prefix') . '/lib/democratic.lib.php'); -require_once(conf('prefix') . '/modules/lib.php'); require_once(conf('prefix') . '/modules/catalog.php'); require_once(conf('prefix') . "/modules/id3/getid3/getid3.php"); require_once(conf('prefix') . '/modules/id3/vainfo.class.php'); diff --git a/lib/rating.lib.php b/lib/rating.lib.php index 676a37eb..ee589618 100644 --- a/lib/rating.lib.php +++ b/lib/rating.lib.php @@ -1,13 +1,12 @@ <?php /* - Copyright 2001 - 2006 Ampache.org + 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; either version 2 - of the License, or (at your option) any later version. + 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 diff --git a/lib/xmlrpc.php b/lib/xmlrpc.php index 8e016f60..a0c3d2b8 100644 --- a/lib/xmlrpc.php +++ b/lib/xmlrpc.php @@ -1,13 +1,12 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + 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; either version 2 - of the License, or (at your option) any later version. + 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 @@ -116,6 +115,7 @@ function remote_song_query($params) { while ($r = mysql_fetch_object($db_results)) { $song = new Song($r->id); + $song->fill_ext_info(); $song->album = $song->get_album_name(); $song->artist = $song->get_artist_name(); $song->genre = $song->get_genre_name(); |