diff options
-rwxr-xr-x | docs/CHANGELOG | 1 | ||||
-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 | ||||
-rw-r--r-- | lib/debug.lib.php | 28 | ||||
-rw-r--r-- | lib/general.lib.php | 1 | ||||
-rw-r--r-- | lib/init.php | 4 | ||||
-rw-r--r-- | lib/preferences.php | 18 | ||||
-rw-r--r-- | modules/localplay/mpd.controller.php | 17 | ||||
-rw-r--r-- | templates/footer.inc | 1 | ||||
-rw-r--r-- | templates/show_test.inc | 11 | ||||
-rw-r--r-- | templates/show_tv_adminctl.inc.php | 8 | ||||
-rw-r--r-- | tv.php | 3 |
15 files changed, 153 insertions, 37 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 4fac79a4..0b341a7d 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,7 @@ -------------------------------------------------------------------------- v.3.3.3-Beta1 + - Fixed an issue with multi-value config options on test.php - Changed default site_charset to UTF-8 in ampache.cfg.php.dist - Fixed some <? in show_test.inc (Thx apex) - Added Plugin Interface under Admin --> Modules 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()); diff --git a/lib/debug.lib.php b/lib/debug.lib.php index 04e77887..cccfd8e6 100644 --- a/lib/debug.lib.php +++ b/lib/debug.lib.php @@ -225,22 +225,6 @@ function check_config_values($conf) { } // check_config_values /*! - @function show_compare_config - @discussion shows the difference between ampache.cfg - and ampache.cfg.dst -*/ -function show_compare_config($prefix) { - - // Live Config File - $live_config = $prefix . "/config/ampache.cfg.php"; - - // Generic Config File - $generic_config = $prefix . "/config/ampache.cfg.dist"; - -} // show_compare_config - - -/*! @function debug_read_config @discussion this is the same as the read config function except it will pull config values with a # before them @@ -328,8 +312,16 @@ function debug_compare_configs($config,$dist_config) { foreach ($dist_results as $key=>$value) { if (!isset($results[$key])) { - $missing[$key] = $value; - } + /* If it's an array we need to split it out */ + if (is_array($value)) { + foreach ($value as $element) { + $missing[$key][] = $element; + } + } + else { + $missing[$key] = $value; + } // end else not array + } // if it's not set } // end foreach conf diff --git a/lib/general.lib.php b/lib/general.lib.php index b6c7c3fc..f49acb85 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -864,6 +864,7 @@ function get_languages() { case 'es_ES'; $name = 'Español'; break; case 'fr_FR'; $name = 'Français'; break; case 'it_IT'; $name = 'Italiano'; break; + case 'is_IS'; $name = 'Íslenska'; break; case 'nl_NL'; $name = 'Nederlands'; break; case 'tr_TR'; $name = _('Turkish'); break; case 'zh_CN'; $name = _('Simplified Chinese') . " (简体中文)"; break; diff --git a/lib/init.php b/lib/init.php index 5a9895fb..d645f0ae 100644 --- a/lib/init.php +++ b/lib/init.php @@ -112,6 +112,10 @@ if (!$results['user_ip_cardinality']) { if (!$results['local_length']) { $results['local_length'] = '9000'; } +/* Default it for now until I can get the auto-config updater working */ +if (!$results['tag_order']) { + $results['tag_order'] = array('id3v2','id3v1','vorbiscomment','quicktime','file'); +} /* Variables needed for vauth Module */ diff --git a/lib/preferences.php b/lib/preferences.php index ac18479c..6d1d5a5a 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -368,6 +368,24 @@ function get_preference_id($name) { } // get_preference_id /** + * get_preference_name + * This does the inverse of the above function and returns the preference name from the ID + * This is usefull for doing... the opposite of above. Amazing isn't it. + */ +function get_preference_name($id) { + + $id = sql_escape($id); + + $sql = "SELECT name FROM preferences WHERE id='$id'"; + $db_results = mysql_query($sql,dbh()); + + $results = mysql_fetch_assoc($db_results); + + return $results['name']; + +} // get_preference_name + +/** * insert_preference * This creates a new preference record in the * preferences table this is used by the modules diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php index 1d850b48..b782b17c 100644 --- a/modules/localplay/mpd.controller.php +++ b/modules/localplay/mpd.controller.php @@ -77,6 +77,7 @@ class AmpacheMpd { /* Optional Functions */ $map['move'] = 'move'; $map['delete_all'] = 'clear_playlist'; + $map['add_url'] = 'add_url'; return $map; @@ -127,6 +128,22 @@ class AmpacheMpd { } // add_songs + /** + * add_url + * This adds urls directly to the playlist, recieves an array of urls + */ + function add_url($urls) { + + foreach ($urls as $url) { + if (is_null($this->_mpd->PlAdd($url))) { + debug_event('mpd_add','Error: Unable to add $url to MPD ' . $this->_mpd->errStr,'1'); + } + + } // end foreach + + return true; + + } // add_url /** * delete_songs diff --git a/templates/footer.inc b/templates/footer.inc index fc9752cb..727d7bb1 100644 --- a/templates/footer.inc +++ b/templates/footer.inc @@ -24,5 +24,6 @@ </td></tr></table> </div> <!-- end id="content"--> </div> <!-- end id="maincontainer"--> +<div id="footer-content"> </div> </body> </html> diff --git a/templates/show_test.inc b/templates/show_test.inc index f44e806a..f455021c 100644 --- a/templates/show_test.inc +++ b/templates/show_test.inc @@ -219,9 +219,16 @@ $row_classes = array('even','odd'); <td> <?php if (count($difference)) { echo _('Ampache.cfg.php is missing the following:'); - echo "<br /><dl>\n"; + echo "<br /><dl style=\"text-align:left;\">\n"; foreach ($difference as $key=>$value) { - echo "\t<dd>$key = \"$value\"</dd>\n"; + if (is_array($value)) { + foreach ($value as $element) { + echo "\t<dd>$key = \"$element\"</dd>\n"; + } + } + else { + echo "\t<dd>$key = \"$value\"</dd>\n"; + } } echo "</dl><br />\n"; } else { ?> diff --git a/templates/show_tv_adminctl.inc.php b/templates/show_tv_adminctl.inc.php index b71c82fc..7b84fa2c 100644 --- a/templates/show_tv_adminctl.inc.php +++ b/templates/show_tv_adminctl.inc.php @@ -35,18 +35,12 @@ else { <?php echo _('Democratic Play Active'); ?> <form method="post" style="Display:inline;" action="<?php echo conf('web_path'); ?>/tv.php?action=send_playlist&tmp_playlist_id=<?php echo scrub_out($tmp_playlist->id); ?>" enctype="multipart/form-data"> <select name="play_type"> - <?php - $controllers = get_localplay_controllers(); - foreach ($controllers as $controller) { - ?> - <option value="__<?php echo $controller; ?>"><?php echo ucfirst($controller); ?></option> - <?php } // end foreach ?> + <option value="localplay"><?php echo _('Localplay'); ?></option> <option value="stream"><?php echo _('Stream'); ?></option> <option value="downsample"><?php echo _('Downsample'); ?></option> </select> <input type="submit" value="<?php echo _('Play'); ?>" /> </form> -<a href="<?php echo $tmp_playlist->get_vote_url(); ?>"><?php echo _('Play'); ?></a><br /> <?php echo _('Base Playlist'); ?>: <form method="post" style="Display:inline;" action="<?php echo conf('web_path'); ?>/tv.php?action=update_playlist&playlist_id=<?php echo $tmp_playlist->base_playlist; ?>" enctype="multipart/form-data"> <?php show_playlist_dropdown($tmp_playlist->base_playlist); ?> @@ -55,10 +55,11 @@ switch ($action) { access_denied(); break; } + $stream_type = scrub_in($_REQUEST['play_type']); $tmp_playlist = new tmpPlaylist($_REQUEST['tmp_playlist_id']); $stream = new Stream($stream_type,array()); - $stream->manual_url_add($tmp_playlist->get_vote_url()); + $stream->manual_url_add(unhtmlentities($tmp_playlist->get_vote_url())); $stream->start(); break; case 'update_playlist': |