diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-12-05 04:43:13 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-12-05 04:43:13 +0000 |
commit | ca34aa1edeb011baed4e2a6fabe56d90c0ba314d (patch) | |
tree | 19ef4bdd32a97f1effc6e50d2e06dba74fb398ba /lib/class | |
parent | afe3b2fcb0183426c34620dfe2d68ed41f84d1d9 (diff) | |
download | ampache-ca34aa1edeb011baed4e2a6fabe56d90c0ba314d.tar.gz ampache-ca34aa1edeb011baed4e2a6fabe56d90c0ba314d.tar.bz2 ampache-ca34aa1edeb011baed4e2a6fabe56d90c0ba314d.zip |
* Prevent Album art set on demo because people put porn in there :(
* Fix Push functionality for the Democratic view stuff
* Add footer div definition per Apex's request
* Fix Config display with multi-value elements
* Added plugin checking to update.php wq
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/album.class.php | 5 | ||||
-rw-r--r-- | lib/class/localplay.class.php | 20 | ||||
-rw-r--r-- | lib/class/stream.class.php | 57 | ||||
-rw-r--r-- | lib/class/update.class.php | 4 | ||||
-rw-r--r-- | lib/class/user.class.php | 12 |
5 files changed, 89 insertions, 9 deletions
diff --git a/lib/class/album.class.php b/lib/class/album.class.php index 50d7d490..12c668ae 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -385,6 +385,11 @@ class Album { */ function insert_art($image, $mime) { + /* Have to disable this for Demo because people suck and try to + * insert PORN :( + */ + if (conf('demo_mode')) { return false; } + // Check for PHP:GD and if we have it make sure this image is of some size if (function_exists('ImageCreateFromString')) { $im = @ImageCreateFromString($image); diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php index 9dbc7958..ba5c3c2a 100644 --- a/lib/class/localplay.class.php +++ b/lib/class/localplay.class.php @@ -165,6 +165,7 @@ class Localplay { $this->_function_map['delete_all'] = $data['delete_all']; $this->_function_map['randomize'] = $data['randomize']; $this->_function_map['move'] = $data['move']; + $this->_function_map['add_url'] = $data['add_url']; } // _map_functions @@ -249,6 +250,25 @@ class Localplay { } // add /** + * add_url + * This directly adds an array of URLs to the localplay module. This is really how I should + * have done add, will migrate to this eventually + */ + function add_url($urls) { + + $function = $this->_function_map['add_url']; + + if (!$this->_player->$function($urls)) { + debug_event('localplay','Error Unable to add urls, check ' . $this->type . ' controller','1'); + return false; + } + + + return true; + + } // add_url + + /** * repeat * This turns the repeat feature of a localplay method on or * off, takes a 0/1 value diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php index 6a5599a2..254a0fd4 100644 --- a/lib/class/stream.class.php +++ b/lib/class/stream.class.php @@ -19,16 +19,20 @@ */ -/*! - @header Stream Class -*/ - +/** + * Stream + * This class is used to generate the Playlists and pass them on + * With Localplay this actually just sends the commands to the localplay + * module in question. It has two sources for data + * songs (array of ids) and urls (array of full urls) + */ class Stream { /* Variables from DB */ var $type; var $web_path; var $songs = array(); + var $urls = array(); var $sess; /*! @@ -84,7 +88,7 @@ class Stream { */ function manual_url_add($url) { - + $this->urls[] = $url; } // manual_url_add @@ -98,6 +102,8 @@ class Stream { header("Cache-control: public"); header("Content-Disposition: filename=playlist.m3u"); header("Content-Type: audio/x-mpegurl;"); + + /* Foreach songs */ foreach ($this->songs as $song_id) { $song = new Song($song_id); if ($song->type == ".flac") { $song->type = ".ogg"; } @@ -107,6 +113,11 @@ class Stream { echo "$this->web_path/play/index.php?song=$song_id&uid=$this->user_id&sid=$this->sess&ds=$ds&stupidwinamp=." . $song->type . "\n"; } // end foreach + /* Foreach the additional URLs */ + foreach ($this->urls as $url) { + echo "$url\n"; + } + } // simple_m3u /*! @@ -133,6 +144,12 @@ class Stream { echo $song->get_url() . "\n"; } // end foreach + /* Foreach URLS */ + foreach ($this->urls as $url) { + echo "#EXTINF: URL-Add\n"; + echo $url . "\n"; + } + } // create_m3u /*! @@ -141,12 +158,15 @@ class Stream { */ function create_pls() { + /* Count entries */ + $total_entries = count($this->songs) + count($this->urls); + // Send the client a pls playlist header("Cache-control: public"); header("Content-Disposition: filename=playlist.pls"); header("Content-Type: audio/x-scpls;"); echo "[Playlist]\n"; - echo "NumberOfEntries=" . count($this->songs) . "\n"; + echo "NumberOfEntries=$total_entries\n"; foreach ($this->songs as $song_id) { $i++; $song = new Song($song_id); @@ -157,6 +177,15 @@ class Stream { echo "Title" . $i . "=$song_name\n"; echo "Length" . $i . "=-1\n"; } // end foreach songs + + /* Foreach Additional URLs */ + foreach ($this->urls as $url) { + $i++; + echo "File" . $i ."=$url\n"; + echo "Title". $i . "=AddedURL\n"; + echo "Length" . $i . "=-1\n"; + } // end foreach urls + echo "Version=2\n"; } // create_pls @@ -188,6 +217,15 @@ class Stream { } // end foreach + /* Foreach urls */ + foreach ($this->urls as $url) { + echo "<ENTRY>\n"; + echo "<TITLE>AddURL</TITLE>\n"; + echo "<AUTHOR>AddURL</AUTHOR>\n"; + echo "<REF HREF=\"$url\" />\n"; + echo "</ENTRY>\n"; + } // end foreach + echo "</ASX>\n"; } // create_asx @@ -280,6 +318,12 @@ class Stream { $localplay = init_localplay(); $localplay->connect(); $localplay->add($this->songs); + + /* Check for Support */ + if ($localplay->has_function('add_url')) { + $localplay->add_url($this->urls); + } + $localplay->play(); header("Location: " . return_referer()); @@ -315,7 +359,6 @@ class Stream { } // foreach songs } // create_ram - } //end of stream class diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 41d56f3d..9375883b 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -2093,6 +2093,10 @@ class Update { while ($r = mysql_fetch_assoc($db_results)) { $user->fix_preferences($r['username']); } // while results + + /* Drop the unused user_catalog table */ + $sql = "DROP TABLE `user_catalog`"; + $db_results = mysql_query($sql,dbh()); $this->set_version('db_version','333002'); diff --git a/lib/class/user.class.php b/lib/class/user.class.php index 9c8572af..fefca81f 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -248,6 +248,7 @@ class User { /** * update_preference + * //FIXME: Unused at this point, should be removed or used * updates a single preference if the query fails * it attempts to insert the preference instead * @package User @@ -255,14 +256,21 @@ class User { * @todo Do a has_preference_access check */ function update_preference($preference_id, $value, $username=0) { - + + if (!has_preference_access(get_preference_name($preference_id))) { + return false; + } + if (!$username) { $username = $this->username; } if (!conf('use_auth')) { $username = '-1'; } - $value = sql_escape($value); + $value = sql_escape($value); + $preference_id = sql_escape($preference_id); + $username = sql_escape($username); + $sql = "UPDATE user_preference SET value='$value' WHERE user='$username' AND preference='$preference_id'"; $db_results = @mysql_query($sql, dbh()); |